From 043650acccd2528c5459c3c854cbd886acae9642 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sat, 2 May 2020 17:26:14 +0200 Subject: [PATCH 3/4] Rename 'display-time-world' to 'world-clock' (Bug#40863) * lisp/time.el (world-clock): New defgroup. (zoneinfo-style-world-list, legacy-style-world-list): Use :group 'world-clock'. (world-clock-list, world-clock-time-format) (world-clock-buffer-name, world-clock-timer-enable) (world-clock-timer-second): Rename from 'display-time-world-*'. Use :group 'world-clock'. (world-clock-label, world-clock-mode-map, world-clock-mode) (world-clock-display, world-clock): Rename from 'display-time-world-*'. Use the new names. (time--display-world-list): Use the above new names. (display-time-world-list, display-time-world-time-format) (display-time-world-buffer-name) (display-time-world-timer-enable) (display-time-world-timer-second): Redefine as obsolete variable aliases for the new 'world-clock-*' names. (display-time-world-mode, display-time-world-display) (display-time-world, display-time-world-timer): Redefine as obsolete function aliases for the new 'world-clock-*' names. * etc/NEWS: Announce the above changes. --- etc/NEWS | 21 +++++++++- lisp/time.el | 114 +++++++++++++++++++++++++++++++-------------------- 2 files changed, 89 insertions(+), 46 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index d2b745c579..d97b148cc8 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -291,9 +291,26 @@ These new navigation commands are bound to 'n' and 'p' in ** Time --- -*** 'display-time-world' is now an alias for 'world-clock'. +*** 'display-time-world' has been renamed to 'world-clock'. 'world-clock' creates a buffer with an updating time display using -several time zones. The new name is hoped to be more discoverable. +several time zones. + +The following functions have been renamed: + + 'display-time-world' to 'world-clock' + 'display-time-world-mode' to 'world-clock-mode' + 'display-time-world-display' to 'world-clock-display' + 'display-time-world-timer' to 'world-clock-update' + +The following options have been renamed: + + 'display-time-world-list' to 'world-clock-list' + 'display-time-world-time-format' to 'world-clock-time-format' + 'display-time-world-buffer-name' to 'world-clock-buffer-namt' + 'display-time-world-timer-enable' to 'world-clock-timer-enablt' + 'display-time-world-timer-second' to 'world-clock-timer-secont' + +The old names are now obsolete. * New Modes and Packages in Emacs 28.1 diff --git a/lisp/time.el b/lisp/time.el index fe290ff71f..3f1880b708 100644 --- a/lisp/time.el +++ b/lisp/time.el @@ -122,6 +122,10 @@ display-time-server-down-time "Time when mail file's file system was recorded to be down. If that file system seems to be up, the value is nil.") +(defgroup world-clock nil + "Show a world clock." + :group 'applications) + (defcustom zoneinfo-style-world-list '(("America/Los_Angeles" "Seattle") ("America/New_York" "New York") @@ -135,7 +139,7 @@ zoneinfo-style-world-list the name of a region -- a continent or ocean, and LOCATION is the name of a specific location, e.g., a city, within that region. LABEL is a string to display as the label of that TIMEZONE's time." - :group 'display-time + :group 'world-clock :type '(repeat (list string string)) :version "23.1") @@ -155,11 +159,11 @@ legacy-style-world-list See the documentation of the TZ environment variable on your system, for more details about the format of TIMEZONE. LABEL is a string to display as the label of that TIMEZONE's time." - :group 'display-time + :group 'world-clock :type '(repeat (list string string)) :version "23.1") -(defcustom display-time-world-list t +(defcustom world-clock-list t "Alist of time zones and places for `world-clock' to display. Each element has the form (TIMEZONE LABEL). TIMEZONE should be in a format supported by your system. See the @@ -170,16 +174,15 @@ display-time-world-list If the value is t instead of an alist, use the value of `zoneinfo-style-world-list' if it works on this platform, and of `legacy-style-world-list' otherwise." - - :group 'display-time + :group 'world-clock :type '(choice (const :tag "Default" t) (repeat :tag "List of zones and labels" (list (string :tag "Zone") (string :tag "Label")))) - :version "23.1") + :version "28.1") (defun time--display-world-list () - (if (listp display-time-world-list) - display-time-world-list + (if (listp world-clock-list) + world-clock-list ;; Determine if zoneinfo style timezones are supported by testing that ;; America/New York and Europe/London return different timezones. (let ((nyt (format-time-string "%z" nil "America/New_York")) @@ -188,29 +191,29 @@ time--display-world-list legacy-style-world-list zoneinfo-style-world-list)))) -(defcustom display-time-world-time-format "%A %d %B %R %Z" +(defcustom world-clock-time-format "%A %d %B %R %Z" "Time format for `world-clock', see `format-time-string'." - :group 'display-time + :group 'world-clock :type 'string - :version "23.1") + :version "28.1") -(defcustom display-time-world-buffer-name "*wclock*" +(defcustom world-clock-buffer-name "*wclock*" "Name of the `world-clock' buffer." - :group 'display-time + :group 'world-clock :type 'string - :version "23.1") + :version "28.1") -(defcustom display-time-world-timer-enable t +(defcustom world-clock-timer-enable t "If non-nil, a timer will update the `world-clock' buffer." - :group 'display-time + :group 'world-clock :type 'boolean - :version "23.1") + :version "28.1") -(defcustom display-time-world-timer-second 60 +(defcustom world-clock-timer-second 60 "Interval in seconds for updating the `world-clock' buffer." - :group 'display-time + :group 'world-clock :type 'integer - :version "23.1") + :version "28.1") ;;;###autoload (defun display-time () @@ -507,23 +510,48 @@ display-time-mode (remove-hook 'rmail-after-get-new-mail-hook 'display-time-event-handler))) - -(defface display-time-world-label + +;;; Obsolete names + +(define-obsolete-variable-alias 'display-time-world-list + 'world-clock-list "28.1") +(define-obsolete-variable-alias 'display-time-world-time-format + 'world-clock-time-format "28.1") +(define-obsolete-variable-alias 'display-time-world-buffer-name + 'world-clock-buffer-name "28.1") +(define-obsolete-variable-alias 'display-time-world-timer-enable + 'world-clock-timer-enable "28.1") +(define-obsolete-variable-alias 'display-time-world-timer-second + 'world-clock-timer-second "28.1") + +(define-obsolete-function-alias 'display-time-world-mode + #'world-clock-mode "28.1") +(define-obsolete-function-alias 'display-time-world-display + #'world-clock-display "28.1") +(define-obsolete-function-alias 'display-time-world + #'world-clock "28.1") +(define-obsolete-function-alias 'display-time-world-timer + #'world-clock-update "28.1") + + +;;; World clock + +(defface world-clock-label '((t :inherit font-lock-variable-name-face)) "Face for time zone label in `world-clock' buffer.") -(defvar display-time-world-mode-map +(defvar world-clock-mode-map (let ((map (make-sparse-keymap))) - (define-key map "g" #'display-time-world-timer) + (define-key map "g" #'world-clock-update) map) - "Keymap for `display-time-world-mode'.") + "Keymap for `world-clock-mode'.") -(define-derived-mode display-time-world-mode special-mode "World clock" +(define-derived-mode world-clock-mode special-mode "World clock" "Major mode for buffer that displays times in various time zones. See `display-time-world'." (setq show-trailing-whitespace nil)) -(defun display-time-world-display (alist) +(defun world-clock-display (alist) "Replace current buffer text with times in various zones, based on ALIST." (let ((inhibit-read-only t) (buffer-undo-list t) @@ -535,7 +563,7 @@ display-time-world-display (let* ((label (cadr zone)) (width (string-width label))) (push (cons label - (format-time-string display-time-world-time-format + (format-time-string world-clock-time-format now (car zone))) result) (when (> width max-width) @@ -544,7 +572,7 @@ display-time-world-display (dolist (timedata (nreverse result)) (insert (format fmt (propertize (car timedata) - 'face 'display-time-world-label) + 'face 'world-clock-label) (cdr timedata)))) (delete-char -1)) (goto-char (point-min))) @@ -552,32 +580,30 @@ display-time-world-display ;;;###autoload (defun world-clock () "Show world clock buffer with times in various time zones. -`display-time-world-list' specifies the zones. +`world-clock-list' specifies the zones. To turn off the world time display, go to that window and type `\\[quit-window]'." (interactive) - (when (and display-time-world-timer-enable - (not (get-buffer display-time-world-buffer-name))) - (run-at-time t display-time-world-timer-second 'display-time-world-timer)) - (pop-to-buffer display-time-world-buffer-name) - (display-time-world-display (time--display-world-list)) - (display-time-world-mode)) - -(defun display-time-world-timer () + (when (and world-clock-timer-enable + (not (get-buffer world-clock-buffer-name))) + (run-at-time t world-clock-timer-second 'world-clock-update)) + (pop-to-buffer world-clock-buffer-name) + (world-clock-display (time--display-world-list)) + (world-clock-mode)) + +(defun world-clock-update () "Update the `world-clock' buffer." (interactive) - (if (get-buffer display-time-world-buffer-name) - (with-current-buffer (get-buffer display-time-world-buffer-name) - (display-time-world-display (time--display-world-list))) + (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)) - "display-time-world-timer") + "world-clock-update") (cancel-timer elt))))))) -(defalias 'display-time-world #'world-clock) - ;;;###autoload (defun emacs-uptime (&optional format) "Return a string giving the uptime of this instance of Emacs. -- 2.26.2