aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas2020-10-24 15:47:26 +0200
committerStefan Kangas2020-10-24 15:49:20 +0200
commit97267d2bf1fbb9279d32f75eda9dbcf0c4316edd (patch)
treef28af1c515fae0e5b1ea60f3bf7e1f875a87991c
parent6f92674ce81b39a44a0d841a5176884e0321b508 (diff)
downloademacs-97267d2bf1fbb9279d32f75eda9dbcf0c4316edd.tar.gz
emacs-97267d2bf1fbb9279d32f75eda9dbcf0c4316edd.zip
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.
-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'."
531 (setq-local revert-buffer-function #'world-clock-update) 531 (setq-local revert-buffer-function #'world-clock-update)
532 (setq show-trailing-whitespace nil)) 532 (setq show-trailing-whitespace nil))
533 533
534(defvar world-clock--timer nil
535 "The current world clock timer.")
536
534(defun world-clock-display (alist) 537(defun world-clock-display (alist)
535 "Replace current buffer text with times in various zones, based on ALIST." 538 "Replace current buffer text with times in various zones, based on ALIST."
536 (let ((inhibit-read-only t) 539 (let ((inhibit-read-only t)
@@ -571,7 +574,8 @@ To turn off the world time display, go to the window and type `\\[quit-window]'.
571 (pop-to-buffer buffer) 574 (pop-to-buffer buffer)
572 (pop-to-buffer world-clock-buffer-name) 575 (pop-to-buffer world-clock-buffer-name)
573 (when world-clock-timer-enable 576 (when world-clock-timer-enable
574 (run-at-time t world-clock-timer-second #'world-clock-update) 577 (setq world-clock--timer
578 (run-at-time t world-clock-timer-second #'world-clock-update))
575 (add-hook 'kill-buffer-hook #'world-clock-cancel-timer nil t))) 579 (add-hook 'kill-buffer-hook #'world-clock-cancel-timer nil t)))
576 (world-clock-display (time--display-world-list)) 580 (world-clock-display (time--display-world-list))
577 (world-clock-mode) 581 (world-clock-mode)
@@ -579,12 +583,9 @@ To turn off the world time display, go to the window and type `\\[quit-window]'.
579 583
580(defun world-clock-cancel-timer () 584(defun world-clock-cancel-timer ()
581 "Cancel the world clock timer." 585 "Cancel the world clock timer."
582 (let ((list timer-list)) 586 (when world-clock--timer
583 (while list 587 (cancel-timer world-clock--timer)
584 (let ((elt (pop list))) 588 (setq world-clock--timer nil))))
585 (when (equal (symbol-name (timer--function elt))
586 "world-clock-update")
587 (cancel-timer elt))))))
588 589
589(defun world-clock-update (&optional _arg _noconfirm) 590(defun world-clock-update (&optional _arg _noconfirm)
590 "Update the `world-clock' buffer." 591 "Update the `world-clock' buffer."