Mercurial > emacs
comparison lisp/progmodes/which-func.el @ 52691:ccda1b53b035
(which-func-modes): Add ada-mode.
(which-func-functions): New variable.
(which-function): Use that.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 30 Sep 2003 12:53:26 +0000 |
parents | 695cf19ef79e |
children | bd715b02e44e |
comparison
equal
deleted
inserted
replaced
52690:212969e10f09 | 52691:ccda1b53b035 |
---|---|
74 :group 'tools | 74 :group 'tools |
75 :version "20.3") | 75 :version "20.3") |
76 | 76 |
77 (defcustom which-func-modes | 77 (defcustom which-func-modes |
78 '(emacs-lisp-mode c-mode c++-mode perl-mode cperl-mode makefile-mode | 78 '(emacs-lisp-mode c-mode c++-mode perl-mode cperl-mode makefile-mode |
79 sh-mode fortran-mode f90-mode) | 79 sh-mode fortran-mode f90-mode ada-mode) |
80 "List of major modes for which Which Function mode should be used. | 80 "List of major modes for which Which Function mode should be used. |
81 For other modes it is disabled. If this is equal to t, | 81 For other modes it is disabled. If this is equal to t, |
82 then Which Function mode is enabled in any major mode that supports it." | 82 then Which Function mode is enabled in any major mode that supports it." |
83 :group 'which-func | 83 :group 'which-func |
84 :type '(choice (const :tag "All modes" t) | 84 :type '(choice (const :tag "All modes" t) |
204 (with-current-buffer buf (setq which-func-mode nil))))) | 204 (with-current-buffer buf (setq which-func-mode nil))))) |
205 | 205 |
206 (defvar which-function-imenu-failed nil | 206 (defvar which-function-imenu-failed nil |
207 "Locally t in a buffer if `imenu--make-index-alist' found nothing there.") | 207 "Locally t in a buffer if `imenu--make-index-alist' found nothing there.") |
208 | 208 |
209 (defvar which-func-functions nil | |
210 "List of functions for `which-function' to call with no arguments. | |
211 It calls them sequentially, and if any returns non-nil, | |
212 `which-function' uses that name and stops looking for the name.") | |
213 | |
209 (defun which-function () | 214 (defun which-function () |
210 "Return current function name based on point. | 215 "Return current function name based on point. |
211 Uses `imenu--index-alist' or `add-log-current-defun-function'. | 216 Uses `which-function-functions', `imenu--index-alist' |
217 or `add-log-current-defun-function'. | |
212 If no function name is found, return nil." | 218 If no function name is found, return nil." |
213 (let (name) | 219 (let (name) |
220 ;; Try the which-function-functions functions first. | |
221 (let ((hooks which-func-functions)) | |
222 (while hooks | |
223 (let ((value (funcall (car hooks)))) | |
224 (when value | |
225 (setq name value | |
226 hooks nil))) | |
227 (setq hooks (cdr hooks)))) | |
228 | |
214 ;; If Imenu is loaded, try to make an index alist with it. | 229 ;; If Imenu is loaded, try to make an index alist with it. |
215 (when (and (boundp 'imenu--index-alist) (null imenu--index-alist) | 230 (when (and (null name) |
231 (boundp 'imenu--index-alist) (null imenu--index-alist) | |
216 (null which-function-imenu-failed)) | 232 (null which-function-imenu-failed)) |
217 (imenu--make-index-alist) | 233 (imenu--make-index-alist) |
218 (unless imenu--index-alist | 234 (unless imenu--index-alist |
219 (make-local-variable 'which-function-imenu-failed) | 235 (make-local-variable 'which-function-imenu-failed) |
220 (setq which-function-imenu-failed t))) | 236 (setq which-function-imenu-failed t))) |
221 ;; If we have an index alist, use it. | 237 ;; If we have an index alist, use it. |
222 (when (and (boundp 'imenu--index-alist) imenu--index-alist) | 238 (when (and (null name) |
239 (boundp 'imenu--index-alist) imenu--index-alist) | |
223 (let ((alist imenu--index-alist) | 240 (let ((alist imenu--index-alist) |
224 (minoffset (point-max)) | 241 (minoffset (point-max)) |
225 offset elem pair mark) | 242 offset elem pair mark) |
226 (while alist | 243 (while alist |
227 (setq elem (car-safe alist) | 244 (setq elem (car-safe alist) |