changeset 93023:1e2a7548f004

(calendar-phases-of-moon): Use calendar-in-read-only-buffer to replace previous code and disable undo.
author Glenn Morris <rgm@gnu.org>
date Mon, 17 Mar 2008 02:19:31 +0000
parents fd9926fada4b
children efee212e0b17
files lisp/calendar/lunar.el
diffstat 1 files changed, 19 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/calendar/lunar.el	Mon Mar 17 01:24:44 2008 +0000
+++ b/lisp/calendar/lunar.el	Mon Mar 17 02:19:31 2008 +0000
@@ -194,31 +194,25 @@
         (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