From: Juanma Barranquero Date: Mon, 19 Jul 2010 11:06:42 +0000 (+0200) Subject: time.el: Use `define-derived-mode'. Simplify. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~438^2~51^2~22 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=16f3ade52e3d68261fdbf244ab97924ea252f828;p=emacs.git 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. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c8acb06aba1..2729668cea5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2010-07-19 Juanma Barranquero + + * time.el (display-time-world-mode): Define with `define-derived-mode'. + Set `show-trailing-whitespace' to nil. + (display-time-world-display): Simplify. + 2010-07-18 Alan Mackenzie 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." 'display-time-event-handler))) -(defun display-time-world-mode () +(define-derived-mode display-time-world-mode nil "World clock" "Major mode for buffer that displays times in various time zones. See `display-time-world'." - (interactive) - (kill-all-local-variables) - (setq - major-mode 'display-time-world-mode - mode-name "World clock") - (use-local-map display-time-world-mode-map)) + (setq show-trailing-whitespace nil)) (defun display-time-world-display (alist) "Replace current buffer text with times in various zones, based on ALIST." @@ -506,24 +501,22 @@ See `display-time-world'." (buffer-undo-list t)) (erase-buffer) (let ((max-width 0) - (result ())) + (result ()) + fmt) (unwind-protect (dolist (zone alist) (let* ((label (cadr zone)) (width (string-width label))) (set-time-zone-rule (car zone)) - (setq result - (append result - (list - label width - (format-time-string display-time-world-time-format)))) + (push (cons label + (format-time-string display-time-world-time-format)) + result) (when (> width max-width) (setq max-width width)))) (set-time-zone-rule nil)) - (while result - (insert (pop result) - (make-string (1+ (- max-width (pop result))) ?\s) - (pop result) "\n"))) + (setq fmt (concat "%-" (int-to-string max-width) "s %s\n")) + (dolist (timedata (nreverse result)) + (insert (format fmt (car timedata) (cdr timedata))))) (delete-char -1))) ;;;###autoload