diff options
| author | Richard M. Stallman | 2001-11-22 00:08:32 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2001-11-22 00:08:32 +0000 |
| commit | ecafbba26bcac902cdd75895030e7b1c7e5e71b7 (patch) | |
| tree | ae1d5146fadd6109f1b8898e483f6331e901a7c3 | |
| parent | 1ff74324b1dc43d61f1326b1296c0ba3e7086b92 (diff) | |
| download | emacs-ecafbba26bcac902cdd75895030e7b1c7e5e71b7.tar.gz emacs-ecafbba26bcac902cdd75895030e7b1c7e5e71b7.zip | |
(which-function): Call imenu--make-index-alist
if necessary to get a list of functions.
(which-function-imenu-failed): New variable.
(which-func-update): Handle all visible windows.
(which-func-update-1): New subroutine broken out of which-func-update.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/which-func.el | 41 |
2 files changed, 35 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0a842a59c66..596e010d931 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | 2001-11-21 Richard M. Stallman <rms@gnu.org> | 1 | 2001-11-21 Richard M. Stallman <rms@gnu.org> |
| 2 | 2 | ||
| 3 | * which-func.el (which-function): Call imenu--make-index-alist | ||
| 4 | if necessary to get a list of functions. | ||
| 5 | (which-function-imenu-failed): New variable. | ||
| 6 | (which-func-update): Handle all visible windows. | ||
| 7 | (which-func-update-1): New subroutine broken out of which-func-update. | ||
| 8 | |||
| 3 | * files.el (temporary-file-directory, null-device) | 9 | * files.el (temporary-file-directory, null-device) |
| 4 | (small-temporary-file-directory): Definitions moved up. | 10 | (small-temporary-file-directory): Definitions moved up. |
| 5 | 11 | ||
diff --git a/lisp/which-func.el b/lisp/which-func.el index f183fd0e2a4..c594945d89e 100644 --- a/lisp/which-func.el +++ b/lisp/which-func.el | |||
| @@ -153,17 +153,24 @@ It creates the Imenu index for the buffer, if necessary." | |||
| 153 | (setq which-func-mode nil)))) | 153 | (setq which-func-mode nil)))) |
| 154 | 154 | ||
| 155 | (defun which-func-update () | 155 | (defun which-func-update () |
| 156 | ;; Update the string containing the current function. | 156 | "Update the Which-Function mode display for all windows." |
| 157 | (when which-func-mode | 157 | (walk-windows 'which-func-update-1 nil 'visible)) |
| 158 | (condition-case info | 158 | |
| 159 | (progn | 159 | (defun which-func-update-1 (window) |
| 160 | (setq which-func-current (or (which-function) which-func-unknown)) | 160 | "Update the Which-Function mode display for window WINDOW." |
| 161 | (unless (string= which-func-current which-func-previous) | 161 | (save-selected-window |
| 162 | (force-mode-line-update) | 162 | (select-window window) |
| 163 | (setq which-func-previous which-func-current))) | 163 | ;; Update the string containing the current function. |
| 164 | (error | 164 | (when which-func-mode |
| 165 | (which-func-mode -1) | 165 | (condition-case info |
| 166 | (error "Error in which-func-update: %s" info))))) | 166 | (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)))))) | ||
| 167 | 174 | ||
| 168 | ;;;###autoload | 175 | ;;;###autoload |
| 169 | (defalias 'which-func-mode 'which-function-mode) | 176 | (defalias 'which-func-mode 'which-function-mode) |
| @@ -192,12 +199,22 @@ and off otherwise." | |||
| 192 | (dolist (buf (buffer-list)) | 199 | (dolist (buf (buffer-list)) |
| 193 | (with-current-buffer buf (setq which-func-mode nil))))) | 200 | (with-current-buffer buf (setq which-func-mode nil))))) |
| 194 | 201 | ||
| 202 | (defvar which-function-imenu-failed nil | ||
| 203 | "Locally t in a buffer if `imenu--make-index-alist' found nothing there.") | ||
| 204 | |||
| 195 | (defun which-function () | 205 | (defun which-function () |
| 196 | "Return current function name based on point. | 206 | "Return current function name based on point. |
| 197 | Uses `imenu--index-alist' or `add-log-current-defun-function'. | 207 | Uses `imenu--index-alist' or `add-log-current-defun-function'. |
| 198 | If no function name is found, return nil." | 208 | If no function name is found, return nil." |
| 199 | (let (name) | 209 | (let (name) |
| 200 | ;; First try using imenu support. | 210 | ;; 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. | ||
| 201 | (when (and (boundp 'imenu--index-alist) imenu--index-alist) | 218 | (when (and (boundp 'imenu--index-alist) imenu--index-alist) |
| 202 | (let ((pair (car-safe imenu--index-alist)) | 219 | (let ((pair (car-safe imenu--index-alist)) |
| 203 | (rest (cdr-safe imenu--index-alist))) | 220 | (rest (cdr-safe imenu--index-alist))) |