Commit 90773e08598e

Vincent Demeester <vincent@sbr.pm>
2020-06-04 14:21:12
config-editing.el: add support for imenu
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 2a84ef4
Changed files (1)
tools
emacs
tools/emacs/config/config-editing.el
@@ -254,5 +254,35 @@ instead.  This command can then be followed by the standard
   :commands (htmlize-paste-it)
   :bind ("C-c e p" . htmlize-paste-it))
 
+(use-package imenu
+  :config
+  (setq-default imenu-use-markers t
+                imenu-auto-rescan t
+                imenu-auto-rescan-maxout 600000
+                imenu-max-item-length 100
+                imenu-use-popup-menu nil
+                imenu-eager-completion-buffer t
+                imenu-space-replacement " "
+                imenu-level-separator "/")
+
+  (defun prot/imenu-vertical ()
+    "Use a vertical Icomplete layout for `imenu'.
+Also configure the value of `orderless-matching-styles' to avoid
+aggressive fuzzy-style matching for this particular command."
+    (interactive)
+    (let ((orderless-matching-styles    ; make sure to check `orderless'
+           '(orderless-literal
+             orderless-regexp
+             orderless-prefixes)))
+      (icomplete-vertical-do (:height (/ (frame-height) 4))
+        (call-interactively 'imenu))))
+
+  :hook ((imenu-after-jump-hook . (lambda ()
+                                    (when (and (eq major-mode 'org-mode)
+                                               (org-at-heading-p))
+                                      (org-show-entry)
+                                      (org-reveal t)))))
+  :bind ("C-'" . prot/imenu-vertical))
+
 (provide 'config-editing)
 ;;; config-editing.el ends here