diff options
| -rw-r--r-- | lisp/imenu.el | 15 | ||||
| -rw-r--r-- | lisp/progmodes/which-func.el | 8 |
2 files changed, 15 insertions, 8 deletions
diff --git a/lisp/imenu.el b/lisp/imenu.el index 158718b08a9..717ac633665 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el | |||
| @@ -348,6 +348,12 @@ Don't move point." | |||
| 348 | ;;; Lisp | 348 | ;;; Lisp |
| 349 | ;;; | 349 | ;;; |
| 350 | 350 | ||
| 351 | (define-error 'imenu-unavailable "imenu unavailable") | ||
| 352 | |||
| 353 | (defun imenu-unavailable-error (format &rest args) | ||
| 354 | (signal 'imenu-unavailable | ||
| 355 | (list (apply #'format-message format args)))) | ||
| 356 | |||
| 351 | (defun imenu-example--lisp-extract-index-name () | 357 | (defun imenu-example--lisp-extract-index-name () |
| 352 | ;; Example of a candidate for `imenu-extract-index-name-function'. | 358 | ;; Example of a candidate for `imenu-extract-index-name-function'. |
| 353 | ;; This will generate a flat index of definitions in a lisp file. | 359 | ;; This will generate a flat index of definitions in a lisp file. |
| @@ -590,7 +596,8 @@ See `imenu--index-alist' for the format of the index alist." | |||
| 590 | (funcall imenu-create-index-function)))) | 596 | (funcall imenu-create-index-function)))) |
| 591 | (imenu--truncate-items imenu--index-alist))) | 597 | (imenu--truncate-items imenu--index-alist))) |
| 592 | (or imenu--index-alist noerror | 598 | (or imenu--index-alist noerror |
| 593 | (user-error "No items suitable for an index found in this buffer")) | 599 | (imenu-unavailable-error |
| 600 | "No items suitable for an index found in this buffer")) | ||
| 594 | (or imenu--index-alist | 601 | (or imenu--index-alist |
| 595 | (setq imenu--index-alist (list nil))) | 602 | (setq imenu--index-alist (list nil))) |
| 596 | ;; Add a rescan option to the index. | 603 | ;; Add a rescan option to the index. |
| @@ -704,7 +711,7 @@ The alternate method, which is the one most often used, is to call | |||
| 704 | ((and imenu-generic-expression) | 711 | ((and imenu-generic-expression) |
| 705 | (imenu--generic-function imenu-generic-expression)) | 712 | (imenu--generic-function imenu-generic-expression)) |
| 706 | (t | 713 | (t |
| 707 | (user-error "This buffer cannot use `imenu-default-create-index-function'")))) | 714 | (imenu-unavailable-error "This buffer cannot use `imenu-default-create-index-function'")))) |
| 708 | 715 | ||
| 709 | ;;; | 716 | ;;; |
| 710 | ;;; Generic index gathering function. | 717 | ;;; Generic index gathering function. |
| @@ -956,8 +963,8 @@ See the command `imenu' for more information." | |||
| 956 | `(menu-item ,name ,imenu--menubar-keymap)) | 963 | `(menu-item ,name ,imenu--menubar-keymap)) |
| 957 | (use-local-map newmap) | 964 | (use-local-map newmap) |
| 958 | (add-hook 'menu-bar-update-hook 'imenu-update-menubar))) | 965 | (add-hook 'menu-bar-update-hook 'imenu-update-menubar))) |
| 959 | (user-error "The mode `%s' does not support Imenu" | 966 | (imenu-unavailable-error "The mode `%s' does not support Imenu" |
| 960 | (format-mode-line mode-name)))) | 967 | (format-mode-line mode-name)))) |
| 961 | 968 | ||
| 962 | ;;;###autoload | 969 | ;;;###autoload |
| 963 | (defun imenu-add-menubar-index () | 970 | (defun imenu-add-menubar-index () |
diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el index 81f3b8ff9b2..a8c28130660 100644 --- a/lisp/progmodes/which-func.el +++ b/lisp/progmodes/which-func.el | |||
| @@ -209,11 +209,11 @@ It creates the Imenu index for the buffer, if necessary." | |||
| 209 | (< buffer-saved-size which-func-maxout) | 209 | (< buffer-saved-size which-func-maxout) |
| 210 | (= which-func-maxout 0))) | 210 | (= which-func-maxout 0))) |
| 211 | (setq imenu--index-alist | 211 | (setq imenu--index-alist |
| 212 | (save-excursion (funcall imenu-create-index-function)))) | 212 | (save-excursion (funcall imenu-create-index-function)))) |
| 213 | (imenu-unavailable | ||
| 214 | (setq which-func-mode nil)) | ||
| 213 | (error | 215 | (error |
| 214 | (unless (equal err | 216 | (message "which-func-ff-hook error: %S" err) |
| 215 | '(user-error "This buffer cannot use `imenu-default-create-index-function'")) | ||
| 216 | (message "which-func-ff-hook error: %S" err)) | ||
| 217 | (setq which-func-mode nil)))) | 217 | (setq which-func-mode nil)))) |
| 218 | 218 | ||
| 219 | (defun which-func-update () | 219 | (defun which-func-update () |