diff options
| author | Juanma Barranquero | 2003-05-25 02:02:45 +0000 |
|---|---|---|
| committer | Juanma Barranquero | 2003-05-25 02:02:45 +0000 |
| commit | 0ec0b89fe2c87d900f2c60ec0ca9065c57509686 (patch) | |
| tree | 01d5daec298e8f0f7a314c943bf6e9b0cc10d230 | |
| parent | ea82f0df29e71d1e135ba4e1cce9c837427c8015 (diff) | |
| download | emacs-0ec0b89fe2c87d900f2c60ec0ca9065c57509686.tar.gz emacs-0ec0b89fe2c87d900f2c60ec0ca9065c57509686.zip | |
(which-func-update-timer): New variable.
(which-function-mode): Use it.
| -rw-r--r-- | lisp/which-func.el | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lisp/which-func.el b/lisp/which-func.el index d6bc88c37ca..4b1dfca6f5b 100644 --- a/lisp/which-func.el +++ b/lisp/which-func.el | |||
| @@ -175,6 +175,8 @@ It creates the Imenu index for the buffer, if necessary." | |||
| 175 | ;;;###autoload | 175 | ;;;###autoload |
| 176 | (defalias 'which-func-mode 'which-function-mode) | 176 | (defalias 'which-func-mode 'which-function-mode) |
| 177 | 177 | ||
| 178 | (defvar which-func-update-timer nil) | ||
| 179 | |||
| 178 | ;; This is the name people would normally expect. | 180 | ;; This is the name people would normally expect. |
| 179 | ;;;###autoload | 181 | ;;;###autoload |
| 180 | (define-minor-mode which-function-mode | 182 | (define-minor-mode which-function-mode |
| @@ -188,14 +190,16 @@ and off otherwise." | |||
| 188 | (if which-function-mode | 190 | (if which-function-mode |
| 189 | ;;Turn it on | 191 | ;;Turn it on |
| 190 | (progn | 192 | (progn |
| 191 | (add-hook 'post-command-idle-hook 'which-func-update) | 193 | (setq which-func-update-timer |
| 194 | (run-with-idle-timer idle-update-delay t 'which-func-update)) | ||
| 192 | (dolist (buf (buffer-list)) | 195 | (dolist (buf (buffer-list)) |
| 193 | (with-current-buffer buf | 196 | (with-current-buffer buf |
| 194 | (setq which-func-mode | 197 | (setq which-func-mode |
| 195 | (or (eq which-func-modes t) | 198 | (or (eq which-func-modes t) |
| 196 | (member major-mode which-func-modes)))))) | 199 | (member major-mode which-func-modes)))))) |
| 197 | ;; Turn it off | 200 | ;; Turn it off |
| 198 | (remove-hook 'post-command-idle-hook 'which-func-update) | 201 | (cancel-timer which-func-update-timer) |
| 202 | (setq which-func-update-timer nil) | ||
| 199 | (dolist (buf (buffer-list)) | 203 | (dolist (buf (buffer-list)) |
| 200 | (with-current-buffer buf (setq which-func-mode nil))))) | 204 | (with-current-buffer buf (setq which-func-mode nil))))) |
| 201 | 205 | ||
| @@ -222,7 +226,7 @@ If no function name is found, return nil." | |||
| 222 | (while alist | 226 | (while alist |
| 223 | (setq elem (car-safe alist) | 227 | (setq elem (car-safe alist) |
| 224 | alist (cdr-safe alist)) | 228 | alist (cdr-safe alist)) |
| 225 | ;; Elements of alist are either ("name" . marker), or | 229 | ;; Elements of alist are either ("name" . marker), or |
| 226 | ;; ("submenu" ("name" . marker) ... ). | 230 | ;; ("submenu" ("name" . marker) ... ). |
| 227 | (unless (listp (cdr elem)) | 231 | (unless (listp (cdr elem)) |
| 228 | (setq elem (list elem))) | 232 | (setq elem (list elem))) |