summaryrefslogtreecommitdiff
path: root/lisp/time.el
diff options
context:
space:
mode:
authorStefan Kangas <stefan@marxist.se>2020-10-24 15:47:26 +0200
committerStefan Kangas <stefan@marxist.se>2020-10-24 15:49:20 +0200
commit97267d2bf1fbb9279d32f75eda9dbcf0c4316edd (patch)
treef28af1c515fae0e5b1ea60f3bf7e1f875a87991c /lisp/time.el
parent6f92674ce81b39a44a0d841a5176884e0321b508 (diff)
downloademacs-97267d2bf1fbb9279d32f75eda9dbcf0c4316edd.tar.gz
Re-introduce variable for world clock timer
* lisp/time.el (world-clock--timer): New variable. (world-clock): Save timer to above variable when it is started. (world-clock-cancel-timer): Delete timer saved in variable instead of searching for the function name.
Diffstat (limited to 'lisp/time.el')
-rw-r--r--lisp/time.el15
1 files changed, 8 insertions, 7 deletions
diff --git a/lisp/time.el b/lisp/time.el
index 63773d42048..519c96242dd 100644
--- a/lisp/time.el
+++ b/lisp/time.el
@@ -531,6 +531,9 @@ See `world-clock'."
(setq-local revert-buffer-function #'world-clock-update)
(setq show-trailing-whitespace nil))
+(defvar world-clock--timer nil
+ "The current world clock timer.")
+
(defun world-clock-display (alist)
"Replace current buffer text with times in various zones, based on ALIST."
(let ((inhibit-read-only t)
@@ -571,7 +574,8 @@ To turn off the world time display, go to the window and type `\\[quit-window]'.
(pop-to-buffer buffer)
(pop-to-buffer world-clock-buffer-name)
(when world-clock-timer-enable
- (run-at-time t world-clock-timer-second #'world-clock-update)
+ (setq world-clock--timer
+ (run-at-time t world-clock-timer-second #'world-clock-update))
(add-hook 'kill-buffer-hook #'world-clock-cancel-timer nil t)))
(world-clock-display (time--display-world-list))
(world-clock-mode)
@@ -579,12 +583,9 @@ To turn off the world time display, go to the window and type `\\[quit-window]'.
(defun world-clock-cancel-timer ()
"Cancel the world clock timer."
- (let ((list timer-list))
- (while list
- (let ((elt (pop list)))
- (when (equal (symbol-name (timer--function elt))
- "world-clock-update")
- (cancel-timer elt))))))
+ (when world-clock--timer
+ (cancel-timer world-clock--timer)
+ (setq world-clock--timer nil))))
(defun world-clock-update (&optional _arg _noconfirm)
"Update the `world-clock' buffer."