153 |
(setq which-func-mode nil)))) |
(setq which-func-mode nil)))) |
154 |
|
|
155 |
(defun which-func-update () |
(defun which-func-update () |
156 |
;; Update the string containing the current function. |
"Update the Which-Function mode display for all windows." |
157 |
(when which-func-mode |
(walk-windows 'which-func-update-1 nil 'visible)) |
158 |
(condition-case info |
|
159 |
(progn |
(defun which-func-update-1 (window) |
160 |
(setq which-func-current (or (which-function) which-func-unknown)) |
"Update the Which-Function mode display for window WINDOW." |
161 |
(unless (string= which-func-current which-func-previous) |
(save-selected-window |
162 |
(force-mode-line-update) |
(select-window window) |
163 |
(setq which-func-previous which-func-current))) |
;; Update the string containing the current function. |
164 |
(error |
(when which-func-mode |
165 |
(which-func-mode -1) |
(condition-case info |
166 |
(error "Error in which-func-update: %s" info))))) |
(progn |
167 |
|
(setq which-func-current (or (which-function) which-func-unknown)) |
168 |
|
(unless (string= which-func-current which-func-previous) |
169 |
|
(force-mode-line-update) |
170 |
|
(setq which-func-previous which-func-current))) |
171 |
|
(error |
172 |
|
(which-func-mode -1) |
173 |
|
(error "Error in which-func-update: %s" info)))))) |
174 |
|
|
175 |
;;;###autoload |
;;;###autoload |
176 |
(defalias 'which-func-mode 'which-function-mode) |
(defalias 'which-func-mode 'which-function-mode) |
199 |
(dolist (buf (buffer-list)) |
(dolist (buf (buffer-list)) |
200 |
(with-current-buffer buf (setq which-func-mode nil))))) |
(with-current-buffer buf (setq which-func-mode nil))))) |
201 |
|
|
202 |
|
(defvar which-function-imenu-failed nil |
203 |
|
"Locally t in a buffer if `imenu--make-index-alist' found nothing there.") |
204 |
|
|
205 |
(defun which-function () |
(defun which-function () |
206 |
"Return current function name based on point. |
"Return current function name based on point. |
207 |
Uses `imenu--index-alist' or `add-log-current-defun-function'. |
Uses `imenu--index-alist' or `add-log-current-defun-function'. |
208 |
If no function name is found, return nil." |
If no function name is found, return nil." |
209 |
(let (name) |
(let (name) |
210 |
;; First try using imenu support. |
;; If Imenu is loaded, try to make an index alist with it. |
211 |
|
(when (and (boundp 'imenu--index-alist) (null imenu--index-alist) |
212 |
|
(null which-function-imenu-failed)) |
213 |
|
(imenu--make-index-alist) |
214 |
|
(unless imenu--index-alist |
215 |
|
(make-local-variable 'which-function-imenu-failed) |
216 |
|
(setq which-function-imenu-failed t))) |
217 |
|
;; If we have an index alist, use it. |
218 |
(when (and (boundp 'imenu--index-alist) imenu--index-alist) |
(when (and (boundp 'imenu--index-alist) imenu--index-alist) |
219 |
(let ((pair (car-safe imenu--index-alist)) |
(let ((pair (car-safe imenu--index-alist)) |
220 |
(rest (cdr-safe imenu--index-alist))) |
(rest (cdr-safe imenu--index-alist))) |