diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2023-03-11 13:51:00 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2023-03-11 13:52:11 -0700 |
commit | 87f5a21570517f3ce282874ca243dee55236055c (patch) | |
tree | 55f4d16f0deabc518120116f4a076b795cdf37e5 | |
parent | a39a00745e117cbf61f3a29f753849c5a91cfb80 (diff) | |
download | dotfiles-87f5a21570517f3ce282874ca243dee55236055c.tar.gz |
replace default value of lisp-mode's imenu-generic-expression
-rw-r--r-- | .emacs.d/init.el | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 955f0e22..3d650c34 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -4330,13 +4330,29 @@ mutt's review view, after exiting EDITOR." ;; Unconditionally unbinding should be safe as always use Paredit for Lisp. (define-key lisp-mode-shared-map "\177" nil) -;; Add an `imenu-generic-expression' entry for macros from Consfigurator and -;; from my consfig. Would be better to somehow use .dir-locals.el. -(defun spw/lisp-mode-imenu-setup () - (cl-pushnew '(nil - "^\\s-*(def\\(?:ine-[a-z-]*athenet-\\(?:router\\|container\\)\ -\\|prop\\(?:list\\|spec\\)?\\|host\\)\\s-+\\([-A-Za-z0-9.+]+\\)" 1) - imenu-generic-expression)) +;; Catch custom defining forms, and include them at the top level of the menu. +;; We completely replace the default value, rather than appending to the list, +;; because a basic expression to find custom defining forms will also find +;; everything that the default value finds, and indeed merge them into the top +;; level of the menu, anyway. +(when (get 'lisp-mode-symbol 'rx-definition) ; for Emacs 28 + (setq lisp-imenu-generic-expression + (rx-let ((spc (in blank ?\n)) + (sym (| word (syntax symbol)))) + `((nil ,(rx bol (0+ blank) ?\( (opt "spw/") (opt "cl-") "def" + (| (1+ word) + (: "ine-" + ;; Require symbol constituents next, but we don't + ;; want to index calls to `define-key' ... + ;; There is also `define-abbrev'. + (| (: (in "a-jl-z0-9-") (0+ sym)) + (: ?k (opt (in "a-df-z0-9-") (0+ sym))) + (: "ke" (opt (in "a-xz0-9-") (0+ sym))) + (: "key" (1+ sym))))) + (1+ spc) (opt ?') (group lisp-mode-symbol) + ;; Exclude declarations like (defvar FOO) in Elisp. + (1+ spc) (not ?\))) + 1))))) (defun spw/consfig-indentation-hints () (put 'spwcrontab 'common-lisp-indent-function '1) @@ -4351,9 +4367,6 @@ mutt's review view, after exiting EDITOR." (with-eval-after-load 'slime-cl-indent (activate-consfigurator-indentation-hints))) -(with-eval-after-load 'lisp-mode - (add-to-list 'lisp-mode-hook #'spw/lisp-mode-imenu-setup)) - ;; Without xscheme, the *scheme* buffer is not Paredit-compatible. (with-eval-after-load 'scheme (require 'xscheme)) |