diff options
| author | Alex Branham | 2018-12-11 08:29:50 -0600 |
|---|---|---|
| committer | Alex Branham | 2019-02-22 15:27:06 -0600 |
| commit | 0613e7a38efc3b0534e0ca5c5fa401e2a3bda906 (patch) | |
| tree | 73f4d2842ce8853df9b2e935311c3fe300f5a737 | |
| parent | af047384594c73ed87947d5ecbbfc1032435b769 (diff) | |
| download | emacs-0613e7a38efc3b0534e0ca5c5fa401e2a3bda906.tar.gz emacs-0613e7a38efc3b0534e0ca5c5fa401e2a3bda906.zip | |
which-function: Do not display outdated imenu information
* lisp/progmodes/which-func.el (which-function): Check
`add-log-current-defun' before imenu. Update `imenu--index-alist' if
needed. Bug#33695
| -rw-r--r-- | lisp/progmodes/which-func.el | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el index 40a74d1df62..564e0ff62c4 100644 --- a/lisp/progmodes/which-func.el +++ b/lisp/progmodes/which-func.el | |||
| @@ -272,16 +272,21 @@ It calls them sequentially, and if any returns non-nil, | |||
| 272 | 272 | ||
| 273 | (defun which-function () | 273 | (defun which-function () |
| 274 | "Return current function name based on point. | 274 | "Return current function name based on point. |
| 275 | Uses `which-func-functions', `imenu--index-alist' | 275 | Uses `which-func-functions', `add-log-current-defun'. |
| 276 | or `add-log-current-defun'. | 276 | or `imenu--index-alist' |
| 277 | If no function name is found, return nil." | 277 | If no function name is found, return nil." |
| 278 | (let ((name | 278 | (let ((name |
| 279 | ;; Try the `which-func-functions' functions first. | 279 | ;; Try the `which-func-functions' functions first. |
| 280 | (run-hook-with-args-until-success 'which-func-functions))) | 280 | (run-hook-with-args-until-success 'which-func-functions))) |
| 281 | 281 | ;; Try using add-log support. | |
| 282 | (when (null name) | ||
| 283 | (setq name (add-log-current-defun))) | ||
| 282 | ;; If Imenu is loaded, try to make an index alist with it. | 284 | ;; If Imenu is loaded, try to make an index alist with it. |
| 283 | (when (and (null name) | 285 | (when (and (null name) |
| 284 | (boundp 'imenu--index-alist) (null imenu--index-alist) | 286 | (boundp 'imenu--index-alist) |
| 287 | (or (null imenu--index-alist) | ||
| 288 | ;; Update if outdated | ||
| 289 | (/= (buffer-chars-modified-tick) imenu-menubar-modified-tick)) | ||
| 285 | (null which-function-imenu-failed)) | 290 | (null which-function-imenu-failed)) |
| 286 | (ignore-errors (imenu--make-index-alist t)) | 291 | (ignore-errors (imenu--make-index-alist t)) |
| 287 | (unless imenu--index-alist | 292 | (unless imenu--index-alist |
| @@ -323,10 +328,6 @@ If no function name is found, return nil." | |||
| 323 | (funcall | 328 | (funcall |
| 324 | which-func-imenu-joiner-function | 329 | which-func-imenu-joiner-function |
| 325 | (reverse (cons (car pair) namestack)))))))))))) | 330 | (reverse (cons (car pair) namestack)))))))))))) |
| 326 | |||
| 327 | ;; Try using add-log support. | ||
| 328 | (when (null name) | ||
| 329 | (setq name (add-log-current-defun))) | ||
| 330 | ;; Filter the name if requested. | 331 | ;; Filter the name if requested. |
| 331 | (when name | 332 | (when name |
| 332 | (if which-func-cleanup-function | 333 | (if which-func-cleanup-function |