aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2020-09-03 20:20:56 +0300
committerEli Zaretskii2020-09-03 20:20:56 +0300
commitc449a00aa51185486d76ebf602d84e189af702c0 (patch)
tree970433341a1fbe1415506e7af05a37034a029796
parenta4e45a13b65c496a0c53b58992a4be2e3d923325 (diff)
parent54070a5e207f11fbea5adef1dbd7709f42232f0b (diff)
downloademacs-c449a00aa51185486d76ebf602d84e189af702c0.tar.gz
emacs-c449a00aa51185486d76ebf602d84e189af702c0.zip
Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs
-rw-r--r--lisp/time.el33
1 files changed, 15 insertions, 18 deletions
diff --git a/lisp/time.el b/lisp/time.el
index 5ced9205523..534f1283429 100644
--- a/lisp/time.el
+++ b/lisp/time.el
@@ -29,6 +29,8 @@
29 29
30;;; Code: 30;;; Code:
31 31
32(eval-when-compile (require 'subr-x))
33
32(defgroup display-time nil 34(defgroup display-time nil
33 "Display time and load in mode line of Emacs." 35 "Display time and load in mode line of Emacs."
34 :group 'mode-line 36 :group 'mode-line
@@ -523,8 +525,6 @@ See `world-clock'."
523 (setq-local revert-buffer-function #'world-clock-update) 525 (setq-local revert-buffer-function #'world-clock-update)
524 (setq show-trailing-whitespace nil)) 526 (setq show-trailing-whitespace nil))
525 527
526(defvar world-clock-timer nil)
527
528(defun world-clock-display (alist) 528(defun world-clock-display (alist)
529 "Replace current buffer text with times in various zones, based on ALIST." 529 "Replace current buffer text with times in various zones, based on ALIST."
530 (let ((inhibit-read-only t) 530 (let ((inhibit-read-only t)
@@ -561,34 +561,31 @@ See `world-clock'."
561The variable `world-clock-list' specifies which time zones to use. 561The variable `world-clock-list' specifies which time zones to use.
562To turn off the world time display, go to the window and type `\\[quit-window]'." 562To turn off the world time display, go to the window and type `\\[quit-window]'."
563 (interactive) 563 (interactive)
564 (when (and world-clock-timer-enable 564 (if-let ((buffer (get-buffer world-clock-buffer-name)))
565 (not (get-buffer world-clock-buffer-name))) 565 (pop-to-buffer buffer)
566 (setq world-clock-timer 566 (pop-to-buffer world-clock-buffer-name)
567 (run-at-time t world-clock-timer-second #'world-clock-update)) 567 (when world-clock-timer-enable
568 (add-hook 'kill-buffer-hook #'world-clock-cancel-timer)) 568 (run-at-time t world-clock-timer-second #'world-clock-update)
569 (pop-to-buffer world-clock-buffer-name) 569 (add-hook 'kill-buffer-hook #'world-clock-cancel-timer nil t)))
570 (world-clock-display (time--display-world-list)) 570 (world-clock-display (time--display-world-list))
571 (world-clock-mode) 571 (world-clock-mode)
572 (fit-window-to-buffer)) 572 (fit-window-to-buffer))
573 573
574(defun world-clock-cancel-timer () 574(defun world-clock-cancel-timer ()
575 "Cancel the world clock timer." 575 "Cancel the world clock timer."
576 (when world-clock-timer 576 (let ((list timer-list))
577 (cancel-timer world-clock-timer) 577 (while list
578 (setq world-clock-timer nil))) 578 (let ((elt (pop list)))
579 (when (equal (symbol-name (timer--function elt))
580 "world-clock-update")
581 (cancel-timer elt))))))
579 582
580(defun world-clock-update (&optional _arg _noconfirm) 583(defun world-clock-update (&optional _arg _noconfirm)
581 "Update the `world-clock' buffer." 584 "Update the `world-clock' buffer."
582 (if (get-buffer world-clock-buffer-name) 585 (if (get-buffer world-clock-buffer-name)
583 (with-current-buffer (get-buffer world-clock-buffer-name) 586 (with-current-buffer (get-buffer world-clock-buffer-name)
584 (world-clock-display (time--display-world-list))) 587 (world-clock-display (time--display-world-list)))
585 ;; cancel timer 588 (world-clock-cancel-timer)))
586 (let ((list timer-list))
587 (while list
588 (let ((elt (pop list)))
589 (when (equal (symbol-name (timer--function elt))
590 "world-clock-update")
591 (cancel-timer elt)))))))
592 589
593;;;###autoload 590;;;###autoload
594(defun emacs-uptime (&optional format) 591(defun emacs-uptime (&optional format)