Commit 0ec0b89f authored by Juanma Barranquero's avatar Juanma Barranquero
Browse files

(which-func-update-timer): New variable.

(which-function-mode): Use it.
parent ea82f0df
...@@ -175,6 +175,8 @@ It creates the Imenu index for the buffer, if necessary." ...@@ -175,6 +175,8 @@ It creates the Imenu index for the buffer, if necessary."
;;;###autoload ;;;###autoload
(defalias 'which-func-mode 'which-function-mode) (defalias 'which-func-mode 'which-function-mode)
(defvar which-func-update-timer nil)
;; This is the name people would normally expect. ;; This is the name people would normally expect.
;;;###autoload ;;;###autoload
(define-minor-mode which-function-mode (define-minor-mode which-function-mode
...@@ -188,14 +190,16 @@ and off otherwise." ...@@ -188,14 +190,16 @@ and off otherwise."
(if which-function-mode (if which-function-mode
;;Turn it on ;;Turn it on
(progn (progn
(add-hook 'post-command-idle-hook 'which-func-update) (setq which-func-update-timer
(run-with-idle-timer idle-update-delay t 'which-func-update))
(dolist (buf (buffer-list)) (dolist (buf (buffer-list))
(with-current-buffer buf (with-current-buffer buf
(setq which-func-mode (setq which-func-mode
(or (eq which-func-modes t) (or (eq which-func-modes t)
(member major-mode which-func-modes)))))) (member major-mode which-func-modes))))))
;; Turn it off ;; Turn it off
(remove-hook 'post-command-idle-hook 'which-func-update) (cancel-timer which-func-update-timer)
(setq which-func-update-timer nil)
(dolist (buf (buffer-list)) (dolist (buf (buffer-list))
(with-current-buffer buf (setq which-func-mode nil))))) (with-current-buffer buf (setq which-func-mode nil)))))
...@@ -222,7 +226,7 @@ If no function name is found, return nil." ...@@ -222,7 +226,7 @@ If no function name is found, return nil."
(while alist (while alist
(setq elem (car-safe alist) (setq elem (car-safe alist)
alist (cdr-safe alist)) alist (cdr-safe alist))
;; Elements of alist are either ("name" . marker), or ;; Elements of alist are either ("name" . marker), or
;; ("submenu" ("name" . marker) ... ). ;; ("submenu" ("name" . marker) ... ).
(unless (listp (cdr elem)) (unless (listp (cdr elem))
(setq elem (list elem))) (setq elem (list elem)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment