From: F. Jason Park Date: Sat, 25 Mar 2023 16:13:40 +0000 (-0700) Subject: Add subcommand erc-cmd-HELP handler to erc-dcc X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2d3ae5d5e68a21e51105168b1d9503f28e9e98c3;p=emacs.git Add subcommand erc-cmd-HELP handler to erc-dcc * lisp/erc/erc-compat.el (erc-compat--28-split-string-shell-command, erc-compat--split-string-shell-command): New functions introduced in Emacs 28 for splitting pcomplete input. * lisp/erc/erc-dcc.el (erc-cmd-DCC): Elect to tokenize line specially. (erc-dcc--cmd-help): Add help handler. (Bug#62444.) --- diff --git a/lisp/erc/erc-compat.el b/lisp/erc/erc-compat.el index 5601ede27a5..e6ae62d3a2e 100644 --- a/lisp/erc/erc-compat.el +++ b/lisp/erc/erc-compat.el @@ -409,6 +409,28 @@ If START or END is negative, it counts from the end." (cons '("\\`irc6?s?://" . erc-compat--29-browse-url-irc) existing)))))) + +;;;; Misc 28.1 + +(defvar comint-file-name-quote-list) +(defvar shell-file-name-quote-list) +(declare-function shell--parse-pcomplete-arguments "shell" nil) + +(defun erc-compat--28-split-string-shell-command (string) + (require 'comint) + (require 'shell) + (with-temp-buffer + (insert string) + (let ((comint-file-name-quote-list shell-file-name-quote-list)) + (car (shell--parse-pcomplete-arguments))))) + +(defmacro erc-compat--split-string-shell-command (string) + ;; Autoloaded in Emacs 28. + (list (if (fboundp 'split-string-shell-command) + 'split-string-shell-command + 'erc-compat--28-split-string-shell-command) + string)) + (provide 'erc-compat) ;;; erc-compat.el ends here diff --git a/lisp/erc/erc-dcc.el b/lisp/erc/erc-dcc.el index 4c557e0e0f9..70683a92ffc 100644 --- a/lisp/erc/erc-dcc.el +++ b/lisp/erc/erc-dcc.el @@ -404,8 +404,16 @@ where FOO is one of CLOSE, GET, SEND, LIST, CHAT, etc." (apropos "erc-dcc-do-.*-command") t)))) +(put 'erc-cmd-DCC 'do-not-parse-args t) (autoload 'pcomplete-erc-all-nicks "erc-pcomplete") +;;;###autoload(put 'erc-cmd-DCC 'erc--cmd-help 'erc-dcc--cmd-help) +(defun erc-dcc--cmd-help (&rest args) + (describe-function + (or (and args (intern-soft (concat "erc-dcc-do-" + (upcase (car args)) "-command"))) + 'erc-cmd-DCC))) + ;;;###autoload (defun pcomplete/erc-mode/DCC () "Provide completion for the /DCC command."