diff options
author | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2016-05-28 06:47:26 +0200 |
---|---|---|
committer | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2016-05-28 08:45:10 +0200 |
commit | 84b745c1bd640552698389a5378de21faa737a53 (patch) | |
tree | 96407e974720201bb37a584a7fd8138fc7497f41 /helm-sys.el | |
parent | 896ff1bdbf46ce40d9062135acf22793e95b306e (diff) |
Run the hooks in the top local after-init-hook.
* helm-sys.el (helm-top-poll): Don't add hooks here.
(helm-top-initialize-poll-hooks): New, just add the hooks.
(helm-top-poll-mode): Add helm-top-initialize-poll-hooks
to the after-init-hook.
Diffstat (limited to 'helm-sys.el')
-rw-r--r-- | helm-sys.el | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/helm-sys.el b/helm-sys.el index 11a82884..cc93f951 100644 --- a/helm-sys.el +++ b/helm-sys.el @@ -80,8 +80,6 @@ A format string where %s will be replaced with `frame-width'." (unless no-update (when (helm-alive-p) (helm-force-update))) - (add-hook 'helm-self-insert-hook 'helm-top-poll-no-update nil t) - (add-hook 'helm-move-selection-after-hook 'helm-top-poll-no-update nil t) (setq helm-top-poll-timer (run-with-idle-timer (helm-aif (current-idle-time) (time-add it (seconds-to-time 1.5)) @@ -93,13 +91,30 @@ A format string where %s will be replaced with `frame-width'." (defun helm-top-poll-no-update () (helm-top-poll t)) +(defun helm-top-initialize-poll-hooks () + ;; When emacs is idle during say 20s + ;; the idle timer will run in 20+1.5 s. + ;; This is fine when emacs stays idle, because the next timer + ;; will run at 21.5+1.5 etc... so the display will be updated + ;; at every 1.5 seconds. + ;; But as soon as emacs looses its idleness, the next update + ;; will occur at say 21+1.5 s, so we have to reinitialize + ;; the timer at 0+1.5. + ;; FIXME In some other cases these hooks are not enough + ;; e.g when emacs loose focus and getback focus, none of + ;; the hooks below run. + (add-hook 'helm-self-insert-hook 'helm-top-poll-no-update) + (add-hook 'helm-move-selection-after-hook 'helm-top-poll-no-update)) + ;;;###autoload (define-minor-mode helm-top-poll-mode "Refresh automatically helm top buffer once enabled." :group 'helm-top (if helm-top-poll-mode - (add-hook 'helm-top-after-init-hook 'helm-top-poll) - (remove-hook 'helm-top-after-init-hook 'helm-top-poll))) + (progn + (add-hook 'helm-top-after-init-hook 'helm-top-poll-no-update) + (add-hook 'helm-top-after-init-hook 'helm-top-initialize-poll-hooks)) + (remove-hook 'helm-top-after-init-hook 'helm-top-poll-no-update))) (defvar helm-source-top (helm-build-in-buffer-source "Top" |