From b91d816c2b622d8e0e63d2555441aa78a2065682 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Fri, 10 Jun 2016 14:10:12 -0700 Subject: [PATCH] always flatten imenu indexes --- dotfiles/emacs.d/README.org | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dotfiles/emacs.d/README.org b/dotfiles/emacs.d/README.org index 3c19b43a..d41d1dff 100644 --- a/dotfiles/emacs.d/README.org +++ b/dotfiles/emacs.d/README.org @@ -285,6 +285,15 @@ I like my imenu indexes flat so I don't have to press enter multiple times to fi (imalison:flatten-imenu-index (funcall original-imenu-function)))))) #+END_SRC +By advising ~imenu--make-index-alist~ with ~imalison:flatten-imenu-index~ we make it so that imenu indexes are always flattened. This is still experimental, so copy to your own dotfiles with caution. +#+BEGIN_SRC emacs-lisp + (defun imalison:flatten-imenu-index-with-function + (index-build-function &rest args) + (imalison:flatten-imenu-index (apply index-build-function args))) + + (advice-add 'imenu--make-index-alist + :around 'imalison:flatten-imenu-index-with-function) +#+END_SRC ** An emacs version predicate builder: #+BEGIN_SRC emacs-lisp (defmacro imalison:emacs-version-predicate (major-version minor-version) @@ -990,7 +999,6 @@ I use helm for almost all emacs completion (org-notify-start 10))) (setq org-imenu-depth 10) - (add-hook 'org-mode-hook 'flatten-current-imenu-index-function) (use-package org-bullets :config (progn @@ -1414,7 +1422,6 @@ I use helm for almost all emacs completion (put 'use-package 'lisp-indent-function 1) ;; reduce indentation for use-package (add-hook 'emacs-lisp-mode-hook 'imenu-elisp-sections) - (add-hook 'emacs-lisp-mode-hook 'flatten-current-imenu-index-function) (add-hook 'emacs-lisp-mode-hook (lambda () (setq indent-tabs-mode nil) (setq show-trailing-whitespace t)))