Limited the errors from imenu in prog modes

While I had 'simply' addressed the issue that Charles Choi just
mentioned, I thought I would use his better implementation.
This commit is contained in:
Howard Abrams 2026-02-12 13:40:00 -08:00
parent f0bd926f2c
commit 222d904d3e

View file

@ -164,16 +164,20 @@ Ive often called =imenu= to easily jump to a function definition in a file (o
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defun ha-imenu-setup () (defun ha-imenu-setup ()
"Set up the imenu customization. Use in hooks." "Set up the imenu customization. Use in hooks."
(ignore-errors (condition-case err
(imenu-add-menubar-index) (imenu-add-menubar-index)
(setq-local imenu-auto-rescan t) (setq-local imenu-auto-rescan t)
(when (derived-mode-p 'prog-mode) (when (derived-mode-p 'prog-mode)
(setq-local imenu-sort-function 'imenu--sort-by-name)))) (setq-local imenu-sort-function 'imenu--sort-by-name))
(imenu-unavailable
(let ((inhibit-message t))
(message "Warning: %s" (error-message-string err))))))
(add-hook 'org-mode-hook 'ha-imenu-setup) (add-hook 'org-mode-hook 'ha-imenu-setup)
(add-hook 'markdown-mode-hook 'ha-imenu-setup) (add-hook 'markdown-mode-hook 'ha-imenu-setup)
(add-hook 'prog-mode-hook 'ha-imenu-setup)
(add-hook 'makefile-mode-hook 'ha-imenu-setup) (add-hook 'makefile-mode-hook 'ha-imenu-setup)
(add-hook 'prog-mode-hook 'ha-imenu-setup)
#+end_src #+end_src
** File Access ** File Access
*** Remote Files *** Remote Files