diff options
Diffstat (limited to 'lisp/erc/erc-dcc.el')
-rw-r--r-- | lisp/erc/erc-dcc.el | 74 |
1 files changed, 30 insertions, 44 deletions
diff --git a/lisp/erc/erc-dcc.el b/lisp/erc/erc-dcc.el index e72d8fbe3db..234b4b5a71d 100644 --- a/lisp/erc/erc-dcc.el +++ b/lisp/erc/erc-dcc.el @@ -1,4 +1,4 @@ -;;; erc-dcc.el --- CTCP DCC module for ERC +;;; erc-dcc.el --- CTCP DCC module for ERC -*- lexical-binding: t; -*- ;; Copyright (C) 1993-1995, 1998, 2002-2004, 2006-2021 Free Software ;; Foundation, Inc. @@ -55,12 +55,6 @@ ;; Require at run-time too to silence compiler. (require 'pcomplete) -;;;###autoload(autoload 'erc-dcc-mode "erc-dcc") -(define-erc-module dcc nil - "Provide Direct Client-to-Client support for ERC." - ((add-hook 'erc-server-401-functions 'erc-dcc-no-such-nick)) - ((remove-hook 'erc-server-401-functions 'erc-dcc-no-such-nick))) - (defgroup erc-dcc nil "DCC stands for Direct Client Communication, where you and your friend's client programs connect directly to each other, @@ -71,9 +65,14 @@ Using DCC get and send, you can transfer files directly from and to other IRC users." :group 'erc) +;;;###autoload(autoload 'erc-dcc-mode "erc-dcc") +(define-erc-module dcc nil + "Provide Direct Client-to-Client support for ERC." + ((add-hook 'erc-server-401-functions #'erc-dcc-no-such-nick)) + ((remove-hook 'erc-server-401-functions #'erc-dcc-no-such-nick))) + (defcustom erc-dcc-verbose nil "If non-nil, be verbose about DCC activity reporting." - :group 'erc-dcc :type 'boolean) (defconst erc-dcc-connection-types @@ -120,7 +119,8 @@ All values of the list must be uppercase strings.") ;; more: the entry data from erc-dcc-list for this particular process. (defvar erc-dcc-connect-function 'erc-dcc-open-network-stream) -(defun erc-dcc-open-network-stream (procname buffer addr port entry) +(defun erc-dcc-open-network-stream (procname buffer addr port _entry) + ;; FIXME: Time to try activating this again!? (if nil; (fboundp 'open-network-stream-nowait) ;; this currently crashes ;; cvs emacs (open-network-stream-nowait procname buffer addr port) @@ -286,7 +286,6 @@ The result is also a string." "IP address to listen on when offering files. Should be set to a string or nil. If nil, automatic detection of the host interface to use will be attempted." - :group 'erc-dcc :type (list 'choice (list 'const :tag "Auto-detect" nil) (list 'string :tag "IP-address" :valid-regexp erc-dcc-ipv4-regexp))) @@ -295,7 +294,6 @@ the host interface to use will be attempted." "IP address to use for outgoing DCC offers. Should be set to a string or nil. If nil, use the value of `erc-dcc-listen-host'." - :group 'erc-dcc :type (list 'choice (list 'const :tag "Same as erc-dcc-listen-host" nil) (list 'string :tag "IP-address" :valid-regexp erc-dcc-ipv4-regexp))) @@ -306,7 +304,6 @@ Should be set to a string or nil. If nil, use the value of You might want to set `erc-dcc-auto-masks' for this. `auto' - Automatically accept the request and begin downloading the file `ignore' - Ignore incoming DCC Send requests completely." - :group 'erc-dcc :type '(choice (const ask) (const auto) (const ignore))) (defun erc-dcc-get-host (proc) @@ -323,7 +320,6 @@ If variable `erc-dcc-host' is non-nil, use it. Otherwise call (defcustom erc-dcc-port-range nil "If nil, any available user port is used for outgoing DCC connections. If set to a cons, it specifies a range of ports to use in the form (min . max)" - :group 'erc-dcc :type '(choice (const :tag "Any port" nil) (cons :tag "Port range" @@ -335,7 +331,6 @@ If set to a cons, it specifies a range of ports to use in the form (min . max)" accepted automatically. A user identifier has the form \"nick!login@host\". For instance, to accept all incoming DCC send offers automatically, add the string \".*!.*@.*\" to this list." - :group 'erc-dcc :type '(repeat regexp)) (defun erc-dcc-server (name filter sentinel) @@ -391,7 +386,6 @@ the accepted connection." (defcustom erc-dcc-get-default-directory nil "Default directory for incoming DCC file transfers. If this is nil, then the current value of `default-directory' is used." - :group 'erc-dcc :type '(choice (const nil :tag "Default directory") directory)) ;;;###autoload @@ -468,7 +462,7 @@ where FOO is one of CLOSE, GET, SEND, LIST, CHAT, etc." 'dcc-chat-offer ?n nick) t)))) -(defun erc-dcc-do-CLOSE-command (proc &optional type nick) +(defun erc-dcc-do-CLOSE-command (_proc &optional type nick) "Close a connection. Usage: /dcc close type nick. At least one of TYPE and NICK must be provided." ;; disambiguate type and nick if only one is provided @@ -540,7 +534,7 @@ PROC is the server process." (defvar-local erc-dcc-byte-count nil) -(defun erc-dcc-do-LIST-command (proc) +(defun erc-dcc-do-LIST-command (_proc) "This is the handler for the /dcc list command. It lists the current state of `erc-dcc-list' in an easy to read manner." (let ((alist erc-dcc-list) @@ -703,7 +697,6 @@ the matching regexp, or nil if none found." `ask' - Report the Chat request, and wait for the user to manually accept it `auto' - Automatically accept the request and open a new chat window `ignore' - Ignore incoming DCC chat requests completely." - :group 'erc-dcc :type '(choice (const ask) (const auto) (const ignore))) (defun erc-dcc-handle-ctcp-chat (proc query nick login host to) @@ -757,13 +750,11 @@ the matching regexp, or nil if none found." (defcustom erc-dcc-block-size 1024 "Block size to use for DCC SEND sessions." - :group 'erc-dcc :type 'integer) (defcustom erc-dcc-pump-bytes nil "If set to an integer, keep sending until that number of bytes are unconfirmed." - :group 'erc-dcc :type '(choice (const nil) integer)) (define-inline erc-dcc-get-parent (proc) @@ -837,7 +828,6 @@ bytes sent." '(erc-dcc-display-send erc-dcc-send-block) "Hook run whenever the remote end of a DCC SEND offer connected to your listening port." - :group 'erc-dcc :type 'hook) (defun erc-dcc-nick (plist) @@ -900,7 +890,6 @@ other client." (defcustom erc-dcc-receive-cache (* 1024 512) "Number of bytes to let the receive buffer grow before flushing it." - :group 'erc-dcc :type 'integer) (defvar-local erc-dcc-file-name nil) @@ -942,12 +931,12 @@ and making the connection." (set-process-coding-system proc 'binary 'binary) (set-buffer-file-coding-system 'binary t) - (set-process-filter proc 'erc-dcc-get-filter) - (set-process-sentinel proc 'erc-dcc-get-sentinel) + (set-process-filter proc #'erc-dcc-get-filter) + (set-process-sentinel proc #'erc-dcc-get-sentinel) (setq entry (plist-put entry :start-time (erc-current-time))) (setq entry (plist-put entry :peer proc))))) -(defun erc-dcc-append-contents (buffer file) +(defun erc-dcc-append-contents (buffer _file) "Append the contents of BUFFER to FILE. The contents of the BUFFER will then be erased." (with-current-buffer buffer @@ -1000,7 +989,7 @@ rather than every 1024 byte block, but nobody seems to care." proc (erc-pack-int received-bytes))))))) -(defun erc-dcc-get-sentinel (proc event) +(defun erc-dcc-get-sentinel (proc _event) "This is the process sentinel for CTCP DCC SEND connections. It shuts down the connection and notifies the user that the transfer is complete." @@ -1025,25 +1014,21 @@ transfer is complete." (defcustom erc-dcc-chat-buffer-name-format "DCC-CHAT-%s" "Format to use for DCC Chat buffer names." - :group 'erc-dcc :type 'string) (defcustom erc-dcc-chat-mode-hook nil "Hook calls when `erc-dcc-chat-mode' finished setting up the buffer." - :group 'erc-dcc :type 'hook) (defcustom erc-dcc-chat-connect-hook nil "" - :group 'erc-dcc :type 'hook) (defcustom erc-dcc-chat-exit-hook nil "" - :group 'erc-dcc :type 'hook) -(defun erc-cmd-CREQ (line &optional force) +(defun erc-cmd-CREQ (line &optional _force) "Set or get the DCC chat request flag. Possible values are: ask, auto, ignore." (when (string-match "^\\s-*\\(auto\\|ask\\|ignore\\)?$" line) @@ -1058,7 +1043,7 @@ Possible values are: ask, auto, ignore." erc-dcc-chat-request))) t))) -(defun erc-cmd-SREQ (line &optional force) +(defun erc-cmd-SREQ (line &optional _force) "Set or get the DCC send request flag. Possible values are: ask, auto, ignore." (when (string-match "^\\s-*\\(auto\\|ask\\|ignore\\)?$" line) @@ -1075,7 +1060,7 @@ Possible values are: ask, auto, ignore." (defun pcomplete/erc-mode/CREQ () (pcomplete-here '("auto" "ask" "ignore"))) -(defalias 'pcomplete/erc-mode/SREQ 'pcomplete/erc-mode/CREQ) +(defalias 'pcomplete/erc-mode/SREQ #'pcomplete/erc-mode/CREQ) (define-obsolete-variable-alias 'erc-dcc-chat-filter-hook 'erc-dcc-chat-filter-functions "24.3") @@ -1087,19 +1072,19 @@ the unprocessed output.") (defvar erc-dcc-chat-mode-map (let ((map (make-sparse-keymap))) - (define-key map (kbd "RET") 'erc-send-current-line) - (define-key map "\t" 'completion-at-point) + (define-key map (kbd "RET") #'erc-send-current-line) + (define-key map "\t" #'completion-at-point) map) "Keymap for `erc-dcc-mode'.") (define-derived-mode erc-dcc-chat-mode fundamental-mode "DCC-Chat" "Major mode for wasting time via DCC chat." (setq mode-line-process '(":%s") - erc-send-input-line-function 'erc-dcc-chat-send-input-line + erc-send-input-line-function #'erc-dcc-chat-send-input-line erc-default-recipients '(dcc)) - (add-hook 'completion-at-point-functions 'erc-complete-word-at-point nil t)) + (add-hook 'completion-at-point-functions #'erc-complete-word-at-point nil t)) -(defun erc-dcc-chat-send-input-line (recipient line &optional force) +(defun erc-dcc-chat-send-input-line (recipient line &optional _force) "Send LINE to the remote end. Argument RECIPIENT should always be the symbol dcc, and force is ignored." @@ -1150,14 +1135,14 @@ other client." (setq erc-input-marker (make-marker)) (erc-display-prompt buffer (point-max)) (set-process-buffer proc buffer) - (add-hook 'kill-buffer-hook 'erc-dcc-chat-buffer-killed nil t) + (add-hook 'kill-buffer-hook #'erc-dcc-chat-buffer-killed nil t) (run-hook-with-args 'erc-dcc-chat-connect-hook proc) buffer)) (defun erc-dcc-chat-accept (entry parent-proc) "Accept an incoming DCC connection and open a DCC window." - (let* ((nick (erc-extract-nick (plist-get entry :nick))) - buffer proc) + (let* (;; (nick (erc-extract-nick (plist-get entry :nick))) + proc) ;; buffer (setq proc (funcall erc-dcc-connect-function "dcc-chat" nil @@ -1167,9 +1152,10 @@ other client." ;; XXX: connected, should we kill the ip/port properties? (setq entry (plist-put entry :peer proc)) (setq entry (plist-put entry :parent parent-proc)) - (set-process-filter proc 'erc-dcc-chat-filter) - (set-process-sentinel proc 'erc-dcc-chat-sentinel) - (setq buffer (erc-dcc-chat-setup entry)))) + (set-process-filter proc #'erc-dcc-chat-filter) + (set-process-sentinel proc #'erc-dcc-chat-sentinel) + ;; (setq buffer + (erc-dcc-chat-setup entry))) ;; ) (defun erc-dcc-chat-filter (proc str) (let ((orig-buffer (current-buffer))) |