emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master c449a00 2/2: Merge branch 'master' of git.savannah.gnu.org:/srv/g


From: Eli Zaretskii
Subject: master c449a00 2/2: Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs
Date: Thu, 3 Sep 2020 13:21:18 -0400 (EDT)

branch: master
commit c449a00aa51185486d76ebf602d84e189af702c0
Merge: a4e45a1 54070a5
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs
---
 lisp/time.el | 33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/lisp/time.el b/lisp/time.el
index 5ced920..534f128 100644
--- a/lisp/time.el
+++ b/lisp/time.el
@@ -29,6 +29,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'subr-x))
+
 (defgroup display-time nil
   "Display time and load in mode line of Emacs."
   :group 'mode-line
@@ -523,8 +525,6 @@ See `world-clock'."
   (setq-local revert-buffer-function #'world-clock-update)
   (setq show-trailing-whitespace nil))
 
-(defvar world-clock-timer nil)
-
 (defun world-clock-display (alist)
   "Replace current buffer text with times in various zones, based on ALIST."
   (let ((inhibit-read-only t)
@@ -561,34 +561,31 @@ See `world-clock'."
 The variable `world-clock-list' specifies which time zones to use.
 To turn off the world time display, go to the window and type 
`\\[quit-window]'."
   (interactive)
-  (when (and world-clock-timer-enable
-             (not (get-buffer world-clock-buffer-name)))
-    (setq world-clock-timer
-          (run-at-time t world-clock-timer-second #'world-clock-update))
-    (add-hook 'kill-buffer-hook #'world-clock-cancel-timer))
-  (pop-to-buffer world-clock-buffer-name)
+  (if-let ((buffer (get-buffer world-clock-buffer-name)))
+      (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)
+      (add-hook 'kill-buffer-hook #'world-clock-cancel-timer nil t)))
   (world-clock-display (time--display-world-list))
   (world-clock-mode)
   (fit-window-to-buffer))
 
 (defun world-clock-cancel-timer ()
   "Cancel the world clock timer."
-  (when world-clock-timer
-    (cancel-timer world-clock-timer)
-    (setq world-clock-timer nil)))
+  (let ((list timer-list))
+    (while list
+      (let ((elt (pop list)))
+        (when (equal (symbol-name (timer--function elt))
+                     "world-clock-update")
+          (cancel-timer elt))))))
 
 (defun world-clock-update (&optional _arg _noconfirm)
   "Update the `world-clock' buffer."
   (if (get-buffer world-clock-buffer-name)
       (with-current-buffer (get-buffer world-clock-buffer-name)
         (world-clock-display (time--display-world-list)))
-    ;; cancel timer
-    (let ((list timer-list))
-      (while list
-        (let ((elt (pop list)))
-          (when (equal (symbol-name (timer--function elt))
-                      "world-clock-update")
-            (cancel-timer elt)))))))
+    (world-clock-cancel-timer)))
 
 ;;;###autoload
 (defun emacs-uptime (&optional format)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]