all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#40863: [PATCH] Improve the display-time-world UI
@ 2020-04-26  8:56 Stefan Kangas
  2020-04-26 14:08 ` Eli Zaretskii
  2020-04-27 22:58 ` Basil L. Contovounesios
  0 siblings, 2 replies; 27+ messages in thread
From: Stefan Kangas @ 2020-04-26  8:56 UTC (permalink / raw)
  To: 40863

[-- Attachment #1: Type: text/plain, Size: 652 bytes --]

I have made some improvements to the display-time-world UI.  I divided
them up into four patches to ease review and merging of the individual
features.  Please let me know what you think.

(Of course I can squash the patches before pushing if that is preferable.)

Patch 4 adds an alias 'world-clock'.  Ideally, I would like to rename
the somewhat obscurely named 'display-world-time' to 'world-clock' and
make the old names into obsolete aliases.  It would be good to hear
any opinions on that too.

I'm also not sure if any of this should go into NEWS, so I didn't do
that work for now.  Let me know if that's desirable.

Best regards,
Stefan Kangas

[-- Attachment #2: 0001-Kill-display-time-world-buffer-on-exit.patch --]
[-- Type: text/x-patch, Size: 1730 bytes --]

From 3d8c091a03c25826755b3735eca9da4b342826ba Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Sun, 26 Apr 2020 09:38:03 +0200
Subject: [PATCH 1/4] Kill display-time-world buffer on exit

* lisp/time.el (display-time-world-mode-map): New defvar.
(display-time-world-exit): New defun to kill buffer on exit.
(display-time-world): Doc fix.
---
 lisp/time.el | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/lisp/time.el b/lisp/time.el
index 44fd1a7e33..a5e5b9b4a7 100644
--- a/lisp/time.el
+++ b/lisp/time.el
@@ -509,6 +509,13 @@ display-time-mode
 		 'display-time-event-handler)))
 
 
+(defvar display-time-world-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "g" nil)
+    (define-key map "q" 'display-time-world-exit)
+    map)
+  "Keymap for `display-time-world-mode'.")
+
 (define-derived-mode display-time-world-mode special-mode "World clock"
   "Major mode for buffer that displays times in various time zones.
 See `display-time-world'."
@@ -537,11 +544,17 @@ display-time-world-display
     (delete-char -1))
   (goto-char (point-min)))
 
+(defun display-time-world-exit ()
+  "Quit the world time buffer."
+  (interactive)
+  (quit-window t))
+
 ;;;###autoload
 (defun display-time-world ()
   "Enable updating display of times in various time zones.
+\\<display-time-world-mode-map>
 `display-time-world-list' specifies the zones.
-To turn off the world time display, go to that window and type `q'."
+To turn off the world time display, go to that window and type `\\[display-time-world-exit]'."
   (interactive)
   (when (and display-time-world-timer-enable
              (not (get-buffer display-time-world-buffer-name)))
-- 
2.26.2


[-- Attachment #3: 0002-New-face-for-display-time-world-label.patch --]
[-- Type: text/x-patch, Size: 1399 bytes --]

From 6680705f464dd6e582e70beaf64b027ac57d0d43 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Sun, 26 Apr 2020 10:16:06 +0200
Subject: [PATCH 2/4] New face for display-time-world label

* lisp/time.el (display-time-world-label): New face.
(display-time-world-display): Use the new face.
---
 lisp/time.el | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lisp/time.el b/lisp/time.el
index a5e5b9b4a7..44885f74d1 100644
--- a/lisp/time.el
+++ b/lisp/time.el
@@ -516,6 +516,10 @@ display-time-world-mode-map
     map)
   "Keymap for `display-time-world-mode'.")
 
+(defface display-time-world-label
+  '((t :inherit font-lock-variable-name-face))
+  "Face for time zone label.")
+
 (define-derived-mode display-time-world-mode special-mode "World clock"
   "Major mode for buffer that displays times in various time zones.
 See `display-time-world'."
@@ -540,7 +544,10 @@ display-time-world-display
 	  (setq max-width width))))
     (setq fmt (concat "%-" (int-to-string max-width) "s %s\n"))
     (dolist (timedata (nreverse result))
-      (insert (format fmt (car timedata) (cdr timedata))))
+      (insert (format fmt
+                      (propertize (car timedata)
+                                  'face 'display-time-world-label)
+                      (cdr timedata))))
     (delete-char -1))
   (goto-char (point-min)))
 
-- 
2.26.2


[-- Attachment #4: 0003-Move-point-to-new-buffer-for-display-time-world.patch --]
[-- Type: text/x-patch, Size: 1389 bytes --]

From 0f2ca954e03b857554071ae48a98d44ba7030d69 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Sun, 26 Apr 2020 10:44:00 +0200
Subject: [PATCH 3/4] Move point to new buffer for display-time-world

* lisp/time.el (display-time-world): Move point to created buffer.
---
 lisp/time.el | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lisp/time.el b/lisp/time.el
index 44885f74d1..84c0071b7d 100644
--- a/lisp/time.el
+++ b/lisp/time.el
@@ -566,11 +566,11 @@ display-time-world
   (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))
-  (with-current-buffer (get-buffer-create display-time-world-buffer-name)
-    (display-time-world-display (time--display-world-list))
-    (display-buffer display-time-world-buffer-name
-		    (cons nil '((window-height . fit-window-to-buffer))))
-    (display-time-world-mode)))
+  (switch-to-buffer-other-window (get-buffer-create display-time-world-buffer-name))
+  (display-time-world-display (time--display-world-list))
+  (display-buffer display-time-world-buffer-name
+		  (cons nil '((window-height . fit-window-to-buffer))))
+  (display-time-world-mode))
 
 (defun display-time-world-timer ()
   (if (get-buffer display-time-world-buffer-name)
-- 
2.26.2


[-- Attachment #5: 0004-Improve-the-display-time-world-UI.patch --]
[-- Type: text/x-patch, Size: 1554 bytes --]

From 47401a1e10213d89cbdb6eaa2b66b44c2be37dfe Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Sun, 26 Apr 2020 10:47:17 +0200
Subject: [PATCH 4/4] Improve the display-time-world UI

* lisp/time.el (display-time-world-buffer-name): Change default
buffer name.
(display-time-world): Add usage instructions to modeline.
(world-clock): New defalias for 'display-time-world'.
---
 lisp/time.el | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lisp/time.el b/lisp/time.el
index 84c0071b7d..18de3990c3 100644
--- a/lisp/time.el
+++ b/lisp/time.el
@@ -195,11 +195,11 @@ display-time-world-time-format
   :type 'string
   :version "23.1")
 
-(defcustom display-time-world-buffer-name "*wclock*"
+(defcustom display-time-world-buffer-name "*World Clock*"
   "Name of the world clock buffer."
   :group 'display-time
   :type 'string
-  :version "23.1")
+  :version "28.1")
 
 (defcustom display-time-world-timer-enable t
   "If non-nil, a timer will update the world clock."
@@ -570,7 +570,11 @@ display-time-world
   (display-time-world-display (time--display-world-list))
   (display-buffer display-time-world-buffer-name
 		  (cons nil '((window-height . fit-window-to-buffer))))
-  (display-time-world-mode))
+  (display-time-world-mode)
+  (setq mode-line-format (format "%15s %13s" "World Clock" "q to quit")))
+
+;; This would be a more intuitive name.
+(defalias 'world-clock 'display-time-world)
 
 (defun display-time-world-timer ()
   (if (get-buffer display-time-world-buffer-name)
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2020-08-18 18:23 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-26  8:56 bug#40863: [PATCH] Improve the display-time-world UI Stefan Kangas
2020-04-26 14:08 ` Eli Zaretskii
2020-04-26 14:19   ` Stefan Kangas
2020-04-27 17:20   ` Noam Postavsky
2020-04-27 18:31     ` Eli Zaretskii
2020-04-27 19:00       ` Noam Postavsky
2020-04-27 19:35         ` Eli Zaretskii
2020-04-27 22:00           ` Dmitry Gutov
2020-04-27 23:04             ` Noam Postavsky
2020-05-01 15:03         ` Stefan Kangas
2020-05-01 15:13           ` Eli Zaretskii
2020-05-01 16:26             ` Stefan Kangas
2020-05-01 17:57               ` Eli Zaretskii
2020-05-01 18:07                 ` Dmitry Gutov
2020-05-01 18:18                   ` Eli Zaretskii
2020-04-27 22:58 ` Basil L. Contovounesios
2020-05-02 11:50   ` Stefan Kangas
2020-05-23 13:44     ` Basil L. Contovounesios
2020-05-02 16:10   ` Stefan Kangas
2020-05-02 18:00     ` Stefan Kangas
2020-05-23 13:43     ` Basil L. Contovounesios
2020-08-07 17:23       ` Stefan Kangas
2020-08-07 17:51         ` Basil L. Contovounesios
2020-08-09 22:11           ` Stefan Kangas
2020-08-18 13:49             ` Lars Ingebrigtsen
2020-08-18 14:37               ` Stefan Kangas
2020-08-18 18:23                 ` Stefan Kangas

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.