Function: erc-dcc-do-GET-command
erc-dcc-do-GET-command is a byte-compiled function defined in
erc-dcc.el.gz.
Signature
(erc-dcc-do-GET-command PROC &rest ARGS)
Documentation
Perform a DCC GET command.
Recognize input conforming to the following usage syntax:
/DCC GET [-t|-s] nick [--] filename
nick The person who is sending the file.
filename The filename to be downloaded. Can be split into multiple
arguments that are then joined by a space.
flags "-t" sets :turbo in erc-dcc-list
"-s" sets :secure in erc-dcc-list
"--" indicates end of options
All of which are optional.
Expect PROC to be the server process and ARGS to contain everything after the subcommand "GET" in the usage description above.
Source Code
;; Defined in /usr/src/emacs/lisp/erc/erc-dcc.el.gz
(defun erc-dcc-do-GET-command (proc &rest args)
"Perform a DCC GET command.
Recognize input conforming to the following usage syntax:
/DCC GET [-t|-s] nick [--] filename
nick The person who is sending the file.
filename The filename to be downloaded. Can be split into multiple
arguments that are then joined by a space.
flags \"-t\" sets `:turbo' in `erc-dcc-list'
\"-s\" sets `:secure' in `erc-dcc-list'
\"--\" indicates end of options
All of which are optional.
Expect PROC to be the server process and ARGS to contain
everything after the subcommand \"GET\" in the usage description
above."
;; Despite the advertised syntax above, we currently respect flags
;; in these positions: [flag] nick [flag] filename [flag]
(let* ((trailing (and-let* ((trailing (member "--" args)))
(setq args (butlast args (length trailing)))
(cdr trailing)))
(args (seq-group-by (lambda (s) (eq ?- (aref s 0))) args))
(flags (prog1 (cdr (assq t args))
(setq args (nconc (cdr (assq nil args)) trailing))))
(nick (pop args))
(file (and args (mapconcat #'identity args " ")))
(elt (erc-dcc-member :nick nick :type 'GET :file file))
(filename (or file (plist-get elt :file) "unknown")))
(if elt
(let* ((file (read-file-name
(format-prompt "Local filename"
(file-name-nondirectory filename))
(or erc-dcc-get-default-directory
default-directory)
(expand-file-name (file-name-nondirectory filename)
(or erc-dcc-get-default-directory
default-directory)))))
(cond ((file-exists-p file)
(if (yes-or-no-p (format "File %s exists. Overwrite? "
file))
(erc-dcc-get-file elt file proc)
(erc-display-message
nil '(notice error) proc
'dcc-get-cmd-aborted
?n nick ?f filename)))
(t
(erc-dcc-get-file elt file proc)))
(when (member "-s" flags)
(setq erc-dcc-list (cons (plist-put elt :secure t)
(delq elt erc-dcc-list))))
(when (member "-t" flags)
(setq erc-dcc-list (cons (plist-put elt :turbo t)
(delq elt erc-dcc-list)))))
(erc-display-message
nil '(notice error) 'active
'dcc-get-notfound ?n nick ?f filename))))