Mercurial > emacs
comparison lisp/progmodes/which-func.el @ 89909:68c22ea6027c
Sync to HEAD
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 16 Apr 2004 12:51:06 +0000 |
parents | 375f2633d815 |
children | b9eee0a7bef5 |
comparison
equal
deleted
inserted
replaced
89908:ee1402f7b568 | 89909:68c22ea6027c |
---|---|
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) |
196 (with-current-buffer buf | 196 (with-current-buffer buf |
197 (setq which-func-mode | 197 (setq which-func-mode |
198 (or (eq which-func-modes t) | 198 (or (eq which-func-modes t) |
199 (member major-mode which-func-modes)))))) | 199 (member major-mode which-func-modes)))))) |
200 ;; Turn it off | 200 ;; Turn it off |
201 (cancel-timer which-func-update-timer) | 201 (when (timerp which-func-update-timer) |
202 (cancel-timer which-func-update-timer)) | |
202 (setq which-func-update-timer nil) | 203 (setq which-func-update-timer nil) |
203 (dolist (buf (buffer-list)) | 204 (dolist (buf (buffer-list)) |
204 (with-current-buffer buf (setq which-func-mode nil))))) | 205 (with-current-buffer buf (setq which-func-mode nil))))) |
205 | 206 |
206 (defvar which-function-imenu-failed nil | 207 (defvar which-function-imenu-failed nil |
207 "Locally t in a buffer if `imenu--make-index-alist' found nothing there.") | 208 "Locally t in a buffer if `imenu--make-index-alist' found nothing there.") |
208 | 209 |
210 (defvar which-func-functions nil | |
211 "List of functions for `which-function' to call with no arguments. | |
212 It calls them sequentially, and if any returns non-nil, | |
213 `which-function' uses that name and stops looking for the name.") | |
214 | |
209 (defun which-function () | 215 (defun which-function () |
210 "Return current function name based on point. | 216 "Return current function name based on point. |
211 Uses `imenu--index-alist' or `add-log-current-defun-function'. | 217 Uses `which-function-functions', `imenu--index-alist' |
218 or `add-log-current-defun-function'. | |
212 If no function name is found, return nil." | 219 If no function name is found, return nil." |
213 (let (name) | 220 (let (name) |
221 ;; Try the which-function-functions functions first. | |
222 (let ((hooks which-func-functions)) | |
223 (while hooks | |
224 (let ((value (funcall (car hooks)))) | |
225 (when value | |
226 (setq name value | |
227 hooks nil))) | |
228 (setq hooks (cdr hooks)))) | |
229 | |
214 ;; If Imenu is loaded, try to make an index alist with it. | 230 ;; If Imenu is loaded, try to make an index alist with it. |
215 (when (and (boundp 'imenu--index-alist) (null imenu--index-alist) | 231 (when (and (null name) |
232 (boundp 'imenu--index-alist) (null imenu--index-alist) | |
216 (null which-function-imenu-failed)) | 233 (null which-function-imenu-failed)) |
217 (imenu--make-index-alist) | 234 (imenu--make-index-alist) |
218 (unless imenu--index-alist | 235 (unless imenu--index-alist |
219 (make-local-variable 'which-function-imenu-failed) | 236 (make-local-variable 'which-function-imenu-failed) |
220 (setq which-function-imenu-failed t))) | 237 (setq which-function-imenu-failed t))) |
221 ;; If we have an index alist, use it. | 238 ;; If we have an index alist, use it. |
222 (when (and (boundp 'imenu--index-alist) imenu--index-alist) | 239 (when (and (null name) |
240 (boundp 'imenu--index-alist) imenu--index-alist) | |
223 (let ((alist imenu--index-alist) | 241 (let ((alist imenu--index-alist) |
224 (minoffset (point-max)) | 242 (minoffset (point-max)) |
225 offset elem pair mark) | 243 offset elem pair mark) |
226 (while alist | 244 (while alist |
227 (setq elem (car-safe alist) | 245 (setq elem (car-safe alist) |
251 (funcall which-func-cleanup-function name) | 269 (funcall which-func-cleanup-function name) |
252 name)))) | 270 name)))) |
253 | 271 |
254 (provide 'which-func) | 272 (provide 'which-func) |
255 | 273 |
274 ;;; arch-tag: fa8a55c7-bfe3-4ffc-95ab-01bf21796827 | |
256 ;;; which-func.el ends here | 275 ;;; which-func.el ends here |