From: Justin Burkett Date: Wed, 15 Jun 2016 02:37:56 +0000 (-0400) Subject: Improve imenu support X-Git-Tag: emacs-29.0.90~1306^2~15^2~277^2 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=75bdb87833625ec33dec6be103bfaee4617511e3;p=emacs.git Improve imenu support Instead of using defvar for lisp-mode-symbol-regexp, wait until lisp-mode is loaded and check for its existence to avoid making use-package the place where this variable is declared. --- diff --git a/lisp/use-package/use-package.el b/lisp/use-package/use-package.el index 8c47678117d..59f26158740 100644 --- a/lisp/use-package/use-package.el +++ b/lisp/use-package/use-package.el @@ -177,19 +177,17 @@ Must be set before loading use-package." :group 'use-package) (when use-package-enable-imenu-support - ;; Not defined in Emacs 24 - (defvar lisp-mode-symbol-regexp - "\\(?:\\sw\\|\\s_\\|\\\\.\\)+") - (add-to-list - 'lisp-imenu-generic-expression - (list "Package" - (purecopy (concat "^\\s-*(" - (eval-when-compile - (regexp-opt - '("use-package" "require") - t)) - "\\s-+\\(" lisp-mode-symbol-regexp "\\)")) - 2))) + (eval-after-load 'lisp-mode + `(let ((sym-regexp (or (bound-and-true-p lisp-mode-symbol-regexp) + "\\(?:\\sw\\|\\s_\\|\\\\.\\)+"))) + (add-to-list + 'lisp-imenu-generic-expression + (list "Packages" + (concat "^\\s-*(" + ,(eval-when-compile + (regexp-opt '("use-package" "require") t)) + "\\s-+\\(" sym-regexp "\\)") + 2))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;