diff options
| author | Juanma Barranquero | 2010-07-19 13:06:42 +0200 |
|---|---|---|
| committer | Juanma Barranquero | 2010-07-19 13:06:42 +0200 |
| commit | 16f3ade52e3d68261fdbf244ab97924ea252f828 (patch) | |
| tree | f36bd6dbad16f77f98dcbd91ade146d8a50e8ddb | |
| parent | 311f0356add5e270d209bc9e2304670ff00b55f3 (diff) | |
| download | emacs-16f3ade52e3d68261fdbf244ab97924ea252f828.tar.gz emacs-16f3ade52e3d68261fdbf244ab97924ea252f828.zip | |
time.el: Use `define-derived-mode'. Simplify.
* time.el (display-time-world-mode): Define with `define-derived-mode'.
Set `show-trailing-whitespace' to nil.
(display-time-world-display): Simplify.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/time.el | 27 |
2 files changed, 16 insertions, 17 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c8acb06aba1..2729668cea5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2010-07-19 Juanma Barranquero <lekktu@gmail.com> | ||
| 2 | |||
| 3 | * time.el (display-time-world-mode): Define with `define-derived-mode'. | ||
| 4 | Set `show-trailing-whitespace' to nil. | ||
| 5 | (display-time-world-display): Simplify. | ||
| 6 | |||
| 1 | 2010-07-18 Alan Mackenzie <acm@muc.de> | 7 | 2010-07-18 Alan Mackenzie <acm@muc.de> |
| 2 | 8 | ||
| 3 | Enhance `c-file-style' in file/directory local variables. | 9 | Enhance `c-file-style' in file/directory local variables. |
diff --git a/lisp/time.el b/lisp/time.el index c11f399ae71..e09ceaec18a 100644 --- a/lisp/time.el +++ b/lisp/time.el | |||
| @@ -490,15 +490,10 @@ This runs the normal hook `display-time-hook' after each update." | |||
| 490 | 'display-time-event-handler))) | 490 | 'display-time-event-handler))) |
| 491 | 491 | ||
| 492 | 492 | ||
| 493 | (defun display-time-world-mode () | 493 | (define-derived-mode display-time-world-mode nil "World clock" |
| 494 | "Major mode for buffer that displays times in various time zones. | 494 | "Major mode for buffer that displays times in various time zones. |
| 495 | See `display-time-world'." | 495 | See `display-time-world'." |
| 496 | (interactive) | 496 | (setq show-trailing-whitespace nil)) |
| 497 | (kill-all-local-variables) | ||
| 498 | (setq | ||
| 499 | major-mode 'display-time-world-mode | ||
| 500 | mode-name "World clock") | ||
| 501 | (use-local-map display-time-world-mode-map)) | ||
| 502 | 497 | ||
| 503 | (defun display-time-world-display (alist) | 498 | (defun display-time-world-display (alist) |
| 504 | "Replace current buffer text with times in various zones, based on ALIST." | 499 | "Replace current buffer text with times in various zones, based on ALIST." |
| @@ -506,24 +501,22 @@ See `display-time-world'." | |||
| 506 | (buffer-undo-list t)) | 501 | (buffer-undo-list t)) |
| 507 | (erase-buffer) | 502 | (erase-buffer) |
| 508 | (let ((max-width 0) | 503 | (let ((max-width 0) |
| 509 | (result ())) | 504 | (result ()) |
| 505 | fmt) | ||
| 510 | (unwind-protect | 506 | (unwind-protect |
| 511 | (dolist (zone alist) | 507 | (dolist (zone alist) |
| 512 | (let* ((label (cadr zone)) | 508 | (let* ((label (cadr zone)) |
| 513 | (width (string-width label))) | 509 | (width (string-width label))) |
| 514 | (set-time-zone-rule (car zone)) | 510 | (set-time-zone-rule (car zone)) |
| 515 | (setq result | 511 | (push (cons label |
| 516 | (append result | 512 | (format-time-string display-time-world-time-format)) |
| 517 | (list | 513 | result) |
| 518 | label width | ||
| 519 | (format-time-string display-time-world-time-format)))) | ||
| 520 | (when (> width max-width) | 514 | (when (> width max-width) |
| 521 | (setq max-width width)))) | 515 | (setq max-width width)))) |
| 522 | (set-time-zone-rule nil)) | 516 | (set-time-zone-rule nil)) |
| 523 | (while result | 517 | (setq fmt (concat "%-" (int-to-string max-width) "s %s\n")) |
| 524 | (insert (pop result) | 518 | (dolist (timedata (nreverse result)) |
| 525 | (make-string (1+ (- max-width (pop result))) ?\s) | 519 | (insert (format fmt (car timedata) (cdr timedata))))) |
| 526 | (pop result) "\n"))) | ||
| 527 | (delete-char -1))) | 520 | (delete-char -1))) |
| 528 | 521 | ||
| 529 | ;;;###autoload | 522 | ;;;###autoload |