From 2d3ae5d5e68a21e51105168b1d9503f28e9e98c3 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Sat, 25 Mar 2023 09:13:40 -0700 Subject: [PATCH] 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.) --- lisp/erc/erc-compat.el | 22 ++++++++++++++++++++++ lisp/erc/erc-dcc.el | 8 ++++++++ 2 files changed, 30 insertions(+) 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." -- 2.39.2