changeset 93024:efee212e0b17

(calendar-list-holidays, list-holidays, calendar-cursor-holidays): 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:20:49 +0000
parents 1e2a7548f004
children 1e3b2cf969d4
files lisp/calendar/holidays.el
diffstat 1 files changed, 29 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/calendar/holidays.el	Mon Mar 17 02:19:31 2008 +0000
+++ b/lisp/calendar/holidays.el	Mon Mar 17 02:20:49 2008 +0000
@@ -90,26 +90,20 @@
         (progn
           (message "Looking up holidays...none found")
           nil)
-      (set-buffer (get-buffer-create holiday-buffer))
-      (setq buffer-read-only nil)
-      (increment-calendar-month m1 y1 -1)
-      (increment-calendar-month m2 y2 1)
-      (calendar-set-mode-line
-       (if (= y1 y2)
-           (format "Notable Dates from %s to %s, %d%%-"
-                   (calendar-month-name m1) (calendar-month-name m2) y2)
-         (format "Notable Dates from %s, %d to %s, %d%%-"
-                 (calendar-month-name m1) y1 (calendar-month-name m2) y2)))
-      (erase-buffer)
-      (insert
-       (mapconcat
-        (lambda (x) (concat (calendar-date-string (car x))
-                            ": " (cadr x)))
-        holiday-list "\n"))
-      (goto-char (point-min))
-      (set-buffer-modified-p nil)
-      (setq buffer-read-only t)
-      (display-buffer holiday-buffer)
+      (calendar-in-read-only-buffer holiday-buffer
+        (increment-calendar-month m1 y1 -1)
+        (increment-calendar-month m2 y2 1)
+        (calendar-set-mode-line
+         (if (= y1 y2)
+             (format "Notable Dates from %s to %s, %d%%-"
+                     (calendar-month-name m1) (calendar-month-name m2) y2)
+           (format "Notable Dates from %s, %d to %s, %d%%-"
+                   (calendar-month-name m1) y1 (calendar-month-name m2) y2)))
+        (insert
+         (mapconcat
+          (lambda (x) (concat (calendar-date-string (car x))
+                              ": " (cadr x)))
+          holiday-list "\n")))
       (message "Looking up holidays...done")
       t)))
 
@@ -204,29 +198,22 @@
          (displayed-month 2)
          (displayed-year y1))
     (while (or never (<= d e))
-      (setq holiday-list (append holiday-list (calendar-holiday-list)))
-      (setq never nil)
+      (setq holiday-list (append holiday-list (calendar-holiday-list))
+            never nil)
       (increment-calendar-month displayed-month displayed-year 3)
       (setq d (calendar-absolute-from-gregorian
                (list displayed-month 1 displayed-year))))
     (save-excursion
-      (set-buffer (get-buffer-create holiday-buffer))
-      (setq buffer-read-only nil)
-      (calendar-set-mode-line
-       (if (= y1 y2)
-           (format "%s for %s" title y1)
-         (format "%s for %s-%s" title y1 y2)))
-      (erase-buffer)
-      (goto-char (point-min))
-      (insert
-       (mapconcat
-        (lambda (x) (concat (calendar-date-string (car x))
-                            ": " (cadr x)))
-        holiday-list "\n"))
-      (goto-char (point-min))
-      (set-buffer-modified-p nil)
-      (setq buffer-read-only t)
-      (display-buffer holiday-buffer)
+      (calendar-in-read-only-buffer holiday-buffer
+        (calendar-set-mode-line
+         (if (= y1 y2)
+             (format "%s for %s" title y1)
+           (format "%s for %s-%s" title y1 y2)))
+        (insert
+         (mapconcat
+          (lambda (x) (concat (calendar-date-string (car x))
+                              ": " (cadr x)))
+          holiday-list "\n")))
       (message "Computing holidays...done"))))
 
 ;;;###autoload
@@ -262,15 +249,9 @@
         (message "No holidays known for %s" date-string)
       (if (<= (length msg) (frame-width))
           (message "%s" msg)
-        (set-buffer (get-buffer-create holiday-buffer))
-        (setq buffer-read-only nil)
-        (calendar-set-mode-line date-string)
-        (erase-buffer)
-        (insert (mapconcat 'identity holiday-list "\n"))
-        (goto-char (point-min))
-        (set-buffer-modified-p nil)
-        (setq buffer-read-only t)
-        (display-buffer holiday-buffer)
+        (calendar-in-read-only-buffer holiday-buffer
+          (calendar-set-mode-line date-string)
+          (insert (mapconcat 'identity holiday-list "\n")))
         (message "Checking holidays...done")))))
 
 ;;;###cal-autoload