From 6b331f127a7c4f1c4085521ea74c68f644f93cce Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Mon, 22 Apr 2024 18:11:24 -0700 Subject: [PATCH 2/2] [5.6.1] Add lisp-imenu-generic-expression for ERC hacking * lisp/erc/erc-backend.el (define-erc-response-handler): Add `doc-string' to `declare' specification. * lisp/erc/erc-imenu.el (erc-imenu-add-devel-patterns(): Add locally autoloaded function for defining `imenu' patterns when hacking on ERC. --- lisp/erc/erc-backend.el | 1 + lisp/erc/erc-imenu.el | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index e72fa036f17..311e3a624e6 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -1662,6 +1662,7 @@ define-erc-response-handler ([&or integerp symbolp] &rest [&or integerp symbolp])] &optional sexp sexp def-body)) + (doc-string 2) (indent defun)) (if (numberp name) (setq name (intern (format "%03i" name)))) (setq aliases (mapcar (lambda (a) diff --git a/lisp/erc/erc-imenu.el b/lisp/erc/erc-imenu.el index 68c7895e2dd..c6cb5655e2d 100644 --- a/lisp/erc/erc-imenu.el +++ b/lisp/erc/erc-imenu.el @@ -163,6 +163,29 @@ erc-imenu--disable-which-func (erc-with-all-buffers-of-server nil nil (setq which-func-mode nil))) +;;;###autoload +(defun erc-imenu-add-devel-patterns () + "Tell `imenu' about ERC-defined macros." + ;; This currently produces results like "ERC response FOO BAR". I'd + ;; obviously be nicer to end up with "erc-response-FOO" and + ;; "erc-response-BAR", possibly as separate items. Likewise for + ;; modules: "erc-foo-mode" instead of "ERC module foo". + (cl-pushnew `("ERC response" + ,(rx bol (* (syntax whitespace)) + "(define-erc-response-handler (" (group (+ nonl)) ")") + 1) + lisp-imenu-generic-expression + :test #'equal) + (cl-pushnew `("ERC module" + ,(rx bol (* (syntax whitespace)) + ;; Lisp-mode-symbol. + "(define-erc-module " (group (+ (| (syntax word) + (syntax symbol) + (: "\\" nonl))))) + 1) + lisp-imenu-generic-expression + :test #'equal)) + (provide 'erc-imenu) ;;; erc-imenu.el ends here -- 2.47.1