From: Glenn Morris Date: Mon, 17 Mar 2008 02:19:31 +0000 (+0000) Subject: (calendar-phases-of-moon): Use calendar-in-read-only-buffer to replace X-Git-Tag: emacs-pretest-23.0.90~7083 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=48844538aedc947e8e8b3a1302b0d1e228d1665b;p=emacs.git (calendar-phases-of-moon): Use calendar-in-read-only-buffer to replace previous code and disable undo. --- diff --git a/lisp/calendar/lunar.el b/lisp/calendar/lunar.el index c0e9f8d6f36..789b47eb191 100644 --- a/lisp/calendar/lunar.el +++ b/lisp/calendar/lunar.el @@ -194,31 +194,25 @@ remainder mod 4 gives the phase: 0 new moon, 1 first quarter, 2 full moon, (y2 displayed-year)) (increment-calendar-month m1 y1 -1) (increment-calendar-month m2 y2 1) - (set-buffer (get-buffer-create lunar-phases-buffer)) - (setq buffer-read-only nil) - (calendar-set-mode-line - (if (= y1 y2) - (format "Phases of the Moon from %s to %s, %d%%-" - (calendar-month-name m1) (calendar-month-name m2) y2) - (format "Phases of the Moon from %s, %d to %s, %d%%-" - (calendar-month-name m1) y1 (calendar-month-name m2) y2))) - (erase-buffer) - (insert - (mapconcat - (lambda (x) - (let ((date (car x)) - (time (cadr x)) - (phase (nth 2 x))) - (concat (calendar-date-string date) - ": " - (lunar-phase-name phase) - " " - time))) - (lunar-phase-list m1 y1) "\n")) - (goto-char (point-min)) - (set-buffer-modified-p nil) - (setq buffer-read-only t) - (display-buffer lunar-phases-buffer) + (calendar-in-read-only-buffer lunar-phases-buffer + (calendar-set-mode-line + (if (= y1 y2) + (format "Phases of the Moon from %s to %s, %d%%-" + (calendar-month-name m1) (calendar-month-name m2) y2) + (format "Phases of the Moon from %s, %d to %s, %d%%-" + (calendar-month-name m1) y1 (calendar-month-name m2) y2))) + (insert + (mapconcat + (lambda (x) + (let ((date (car x)) + (time (cadr x)) + (phase (nth 2 x))) + (concat (calendar-date-string date) + ": " + (lunar-phase-name phase) + " " + time))) + (lunar-phase-list m1 y1) "\n"))) (message "Computing phases of the moon...done"))) ;;;###autoload