From dc1fb5b94cf89f6cc3fc903e2caa1a42a83aa216 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sat, 29 Nov 2014 01:40:29 -0500 Subject: Wrap imenu to add rescan as prefix argument --- lisp/init-general.el | 12 +++++++++++- lisp/init-view.el | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lisp/init-general.el b/lisp/init-general.el index 5f3876c..eb82345 100644 --- a/lisp/init-general.el +++ b/lisp/init-general.el @@ -54,7 +54,17 @@ (global-unset-key (kbd "M-{")) (global-set-key (kbd "M-[") 'backward-paragraph) -(global-set-key (kbd "C-c j") 'imenu) + +(defun km/imenu (rescan) + "Call `imenu', rescanning if RESCAN is non-nil" + (interactive "P") + (when rescan + ;; Taken from `imenu-choose-buffer-index'. + (imenu--cleanup) + (setq imenu--index-alist nil)) + (call-interactively #'imenu)) + +(global-set-key (kbd "C-c j") 'km/imenu) ;; Taken from ;; http://milkbox.net/note/single-file-master-emacs-configuration/. diff --git a/lisp/init-view.el b/lisp/init-view.el index e76cefa..c849183 100644 --- a/lisp/init-view.el +++ b/lisp/init-view.el @@ -9,6 +9,6 @@ (define-key view-mode-map "b" 'backward-word) (define-key view-mode-map "]" 'forward-paragraph) (define-key view-mode-map "[" 'backward-paragraph) - (define-key view-mode-map "j" 'imenu)) + (define-key view-mode-map "j" 'km/imenu)) (provide 'init-view) -- cgit v1.2.3