aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas2020-04-26 10:16:06 +0200
committerStefan Kangas2020-08-18 20:16:51 +0200
commit64da2e80966049222486c3f9f1757504c3a42331 (patch)
treea5bc7b2061e753b9d27e76e7f8dc226b0c53f5d7
parent070c60665e71ac9dddf073c9c49c1f8e91a9811f (diff)
downloademacs-64da2e80966049222486c3f9f1757504c3a42331.tar.gz
emacs-64da2e80966049222486c3f9f1757504c3a42331.zip
Improve display-time-world UI (Bug#40863)
* lisp/time.el (display-time-world-mode): Set 'revert-buffer-function' to 'display-time-world-timer'. (display-time-world-label): New face. (display-time-world-display): Use the new face. Move point to new buffer on creation and resize.
-rw-r--r--lisp/time.el23
1 files changed, 15 insertions, 8 deletions
diff --git a/lisp/time.el b/lisp/time.el
index 44fd1a7e337..36259403344 100644
--- a/lisp/time.el
+++ b/lisp/time.el
@@ -509,9 +509,14 @@ runs the normal hook `display-time-hook' after each update."
509 'display-time-event-handler))) 509 'display-time-event-handler)))
510 510
511 511
512(defface display-time-world-label
513 '((t :inherit font-lock-variable-name-face))
514 "Face for time zone label.")
515
512(define-derived-mode display-time-world-mode special-mode "World clock" 516(define-derived-mode display-time-world-mode special-mode "World clock"
513 "Major mode for buffer that displays times in various time zones. 517 "Major mode for buffer that displays times in various time zones.
514See `display-time-world'." 518See `display-time-world'."
519 (setq revert-buffer-function #'display-time-world-timer)
515 (setq show-trailing-whitespace nil)) 520 (setq show-trailing-whitespace nil))
516 521
517(defun display-time-world-display (alist) 522(defun display-time-world-display (alist)
@@ -533,7 +538,10 @@ See `display-time-world'."
533 (setq max-width width)))) 538 (setq max-width width))))
534 (setq fmt (concat "%-" (int-to-string max-width) "s %s\n")) 539 (setq fmt (concat "%-" (int-to-string max-width) "s %s\n"))
535 (dolist (timedata (nreverse result)) 540 (dolist (timedata (nreverse result))
536 (insert (format fmt (car timedata) (cdr timedata)))) 541 (insert (format fmt
542 (propertize (car timedata)
543 'face 'display-time-world-label)
544 (cdr timedata))))
537 (delete-char -1)) 545 (delete-char -1))
538 (goto-char (point-min))) 546 (goto-char (point-min)))
539 547
@@ -541,18 +549,17 @@ See `display-time-world'."
541(defun display-time-world () 549(defun display-time-world ()
542 "Enable updating display of times in various time zones. 550 "Enable updating display of times in various time zones.
543`display-time-world-list' specifies the zones. 551`display-time-world-list' specifies the zones.
544To turn off the world time display, go to that window and type `q'." 552To turn off the world time display, go to that window and type `\\[quit-window]'."
545 (interactive) 553 (interactive)
546 (when (and display-time-world-timer-enable 554 (when (and display-time-world-timer-enable
547 (not (get-buffer display-time-world-buffer-name))) 555 (not (get-buffer display-time-world-buffer-name)))
548 (run-at-time t display-time-world-timer-second 'display-time-world-timer)) 556 (run-at-time t display-time-world-timer-second 'display-time-world-timer))
549 (with-current-buffer (get-buffer-create display-time-world-buffer-name) 557 (pop-to-buffer display-time-world-buffer-name)
550 (display-time-world-display (time--display-world-list)) 558 (display-time-world-display (time--display-world-list))
551 (display-buffer display-time-world-buffer-name 559 (display-time-world-mode)
552 (cons nil '((window-height . fit-window-to-buffer)))) 560 (fit-window-to-buffer))
553 (display-time-world-mode)))
554 561
555(defun display-time-world-timer () 562(defun display-time-world-timer (&optional _arg _noconfirm)
556 (if (get-buffer display-time-world-buffer-name) 563 (if (get-buffer display-time-world-buffer-name)
557 (with-current-buffer (get-buffer display-time-world-buffer-name) 564 (with-current-buffer (get-buffer display-time-world-buffer-name)
558 (display-time-world-display (time--display-world-list))) 565 (display-time-world-display (time--display-world-list)))