aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2003-09-30 12:53:26 +0000
committerRichard M. Stallman2003-09-30 12:53:26 +0000
commit35e376af6ac9fce074f4fd7df89487e7ebceb7bc (patch)
treec00fdaf93875e1296f3e956826cde0fbe46564ac
parentf6c57ef6902b38a98dee2e66381a0acfe924c313 (diff)
downloademacs-35e376af6ac9fce074f4fd7df89487e7ebceb7bc.tar.gz
emacs-35e376af6ac9fce074f4fd7df89487e7ebceb7bc.zip
(which-func-modes): Add ada-mode.
(which-func-functions): New variable. (which-function): Use that.
-rw-r--r--lisp/progmodes/which-func.el25
1 files changed, 21 insertions, 4 deletions
diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el
index 1f1930a3241..4ffcddf48bf 100644
--- a/lisp/progmodes/which-func.el
+++ b/lisp/progmodes/which-func.el
@@ -76,7 +76,7 @@
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.
81For other modes it is disabled. If this is equal to t, 81For other modes it is disabled. If this is equal to t,
82then Which Function mode is enabled in any major mode that supports it." 82then Which Function mode is enabled in any major mode that supports it."
@@ -206,20 +206,37 @@ and off otherwise."
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.
211It 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.
211Uses `imenu--index-alist' or `add-log-current-defun-function'. 216Uses `which-function-functions', `imenu--index-alist'
217or `add-log-current-defun-function'.
212If no function name is found, return nil." 218If 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)