aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/erc/erc-backend.el1
-rw-r--r--test/lisp/erc/resources/erc-tests-common.el37
2 files changed, 38 insertions, 0 deletions
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 @@ Would expand to:
1662 ([&or integerp symbolp] 1662 ([&or integerp symbolp]
1663 &rest [&or integerp symbolp])] 1663 &rest [&or integerp symbolp])]
1664 &optional sexp sexp def-body)) 1664 &optional sexp sexp def-body))
1665 (doc-string 2)
1665 (indent defun)) 1666 (indent defun))
1666 (if (numberp name) (setq name (intern (format "%03i" name)))) 1667 (if (numberp name) (setq name (intern (format "%03i" name))))
1667 (setq aliases (mapcar (lambda (a) 1668 (setq aliases (mapcar (lambda (a)
diff --git a/test/lisp/erc/resources/erc-tests-common.el b/test/lisp/erc/resources/erc-tests-common.el
index a9495ecb28d..546e74736b0 100644
--- a/test/lisp/erc/resources/erc-tests-common.el
+++ b/test/lisp/erc/resources/erc-tests-common.el
@@ -410,4 +410,41 @@ faces in the reverse order they appear in an inserted message."
410 410
411 (funcall test (lambda (arg) (setq faces arg))))) 411 (funcall test (lambda (arg) (setq faces arg)))))
412 412
413;; To use this function, add something like
414;;
415;; ("lisp/erc"
416;; (emacs-lisp-mode (eval erc-tests-common-add-imenu-expressions)))
417;;
418;; to your ~/emacs/master/.dir-locals-2.el. Optionally, add the sexp
419;;
420;; (erc-tests-common-add-imenu-expressions)
421;;
422;; to the user option `safe-local-eval-forms', and load this file before
423;; hacking, possibly by autoloading this function in your init.el.
424(defun erc-tests-common-add-imenu-expressions (&optional removep)
425 "Tell `imenu' about ERC-defined macros. With REMOVEP, do the opposite."
426 (interactive "P")
427 ;; This currently produces results like "ERC response FOO BAR", but it
428 ;; would be preferable to end up with "erc-response-FOO" and
429 ;; "erc-response-BAR" instead, possibly as separate items. Likewise
430 ;; for modules: "erc-foo-mode" instead of "ERC module foo".
431 (dolist (item `(("ERC response"
432 ,(rx bol (* (syntax whitespace))
433 "(define-erc-response-handler (" (group (+ nonl)) ")")
434 1)
435 ("ERC module"
436 ,(rx bol (* (syntax whitespace))
437 ;; No `lisp-mode-symbol' in < Emacs 29.
438 "(define-erc-module " (group (+ (| (syntax word)
439 (syntax symbol)
440 (: "\\" nonl)))))
441 1)))
442 ;; This should only run in `emacs-lisp-mode' buffers, which have
443 ;; this variable set locally.
444 (cl-assert (local-variable-p 'imenu-generic-expression))
445 (if removep
446 (setq imenu-generic-expression
447 (remove item imenu-generic-expression))
448 (cl-pushnew item imenu-generic-expression :test #'equal))))
449
413(provide 'erc-tests-common) 450(provide 'erc-tests-common)