diff options
| author | Raúl Benencia <id@rbenencia.name> | 2025-12-12 08:48:35 -0800 |
|---|---|---|
| committer | Raúl Benencia <id@rbenencia.name> | 2025-12-12 08:48:35 -0800 |
| commit | 15dc21287ad882e4d42f96a7aaa27e078f696c0f (patch) | |
| tree | 9ea58a9c0ec03230b5c0b2bb12a08275bc2683c2 | |
| parent | edb714c0462a215615827e57f446ff1dcec6455d (diff) | |
add periodic update timer
| -rw-r--r-- | org-tempus.el | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/org-tempus.el b/org-tempus.el index 1d936be..992460a 100644 --- a/org-tempus.el +++ b/org-tempus.el @@ -41,9 +41,17 @@ :package-version '(org-tempus . "0.0.1") :group 'org-tempus) +(defcustom org-tempus-update-interval 60 + "Seconds between automatic mode line refreshes." + :type 'integer + :group 'org-tempus) + (defvar org-tempus-mode-line-string "" "Org Tempus mode line indicator.") +(defvar org-tempus--timer nil + "Timer used to refresh the Org Tempus mode line.") + (defun org-tempus--current-task-name () "Return unpropertized name of current task." (substring-no-properties org-clock-current-task)) @@ -74,6 +82,12 @@ :global t (if org-tempus-mode (progn + (when (timerp org-tempus--timer) + (cancel-timer org-tempus--timer)) + (setq org-tempus--timer + (run-at-time org-tempus-update-interval + org-tempus-update-interval + #'org-tempus--update-mode-line)) (add-hook 'org-clock-in-hook #'org-tempus--update-mode-line) (add-hook 'org-clock-out-hook #'org-tempus--update-mode-line) (when org-tempus-add-to-global-mode-string @@ -88,6 +102,9 @@ (setq global-mode-string (remove 'org-tempus-mode-line-string global-mode-string)) (force-mode-line-update)) + (when (timerp org-tempus--timer) + (cancel-timer org-tempus--timer)) + (setq org-tempus--timer nil) (remove-hook 'org-clock-in-hook #'org-tempus--update-mode-line) (remove-hook 'org-clock-out-hook #'org-tempus--update-mode-line))) |
