Mercurial > emacs
comparison lisp/calendar/holidays.el @ 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 | 5a10f6dafd69 |
children | 3f12945a840c |
comparison
equal
deleted
inserted
replaced
93023:1e2a7548f004 | 93024:efee212e0b17 |
---|---|
88 (y2 displayed-year)) | 88 (y2 displayed-year)) |
89 (if (not holiday-list) | 89 (if (not holiday-list) |
90 (progn | 90 (progn |
91 (message "Looking up holidays...none found") | 91 (message "Looking up holidays...none found") |
92 nil) | 92 nil) |
93 (set-buffer (get-buffer-create holiday-buffer)) | 93 (calendar-in-read-only-buffer holiday-buffer |
94 (setq buffer-read-only nil) | 94 (increment-calendar-month m1 y1 -1) |
95 (increment-calendar-month m1 y1 -1) | 95 (increment-calendar-month m2 y2 1) |
96 (increment-calendar-month m2 y2 1) | 96 (calendar-set-mode-line |
97 (calendar-set-mode-line | 97 (if (= y1 y2) |
98 (if (= y1 y2) | 98 (format "Notable Dates from %s to %s, %d%%-" |
99 (format "Notable Dates from %s to %s, %d%%-" | 99 (calendar-month-name m1) (calendar-month-name m2) y2) |
100 (calendar-month-name m1) (calendar-month-name m2) y2) | 100 (format "Notable Dates from %s, %d to %s, %d%%-" |
101 (format "Notable Dates from %s, %d to %s, %d%%-" | 101 (calendar-month-name m1) y1 (calendar-month-name m2) y2))) |
102 (calendar-month-name m1) y1 (calendar-month-name m2) y2))) | 102 (insert |
103 (erase-buffer) | 103 (mapconcat |
104 (insert | 104 (lambda (x) (concat (calendar-date-string (car x)) |
105 (mapconcat | 105 ": " (cadr x))) |
106 (lambda (x) (concat (calendar-date-string (car x)) | 106 holiday-list "\n"))) |
107 ": " (cadr x))) | |
108 holiday-list "\n")) | |
109 (goto-char (point-min)) | |
110 (set-buffer-modified-p nil) | |
111 (setq buffer-read-only t) | |
112 (display-buffer holiday-buffer) | |
113 (message "Looking up holidays...done") | 107 (message "Looking up holidays...done") |
114 t))) | 108 t))) |
115 | 109 |
116 (define-obsolete-function-alias | 110 (define-obsolete-function-alias |
117 'list-calendar-holidays 'calendar-list-holidays "23.1") | 111 'list-calendar-holidays 'calendar-list-holidays "23.1") |
202 (d s) | 196 (d s) |
203 (never t) | 197 (never t) |
204 (displayed-month 2) | 198 (displayed-month 2) |
205 (displayed-year y1)) | 199 (displayed-year y1)) |
206 (while (or never (<= d e)) | 200 (while (or never (<= d e)) |
207 (setq holiday-list (append holiday-list (calendar-holiday-list))) | 201 (setq holiday-list (append holiday-list (calendar-holiday-list)) |
208 (setq never nil) | 202 never nil) |
209 (increment-calendar-month displayed-month displayed-year 3) | 203 (increment-calendar-month displayed-month displayed-year 3) |
210 (setq d (calendar-absolute-from-gregorian | 204 (setq d (calendar-absolute-from-gregorian |
211 (list displayed-month 1 displayed-year)))) | 205 (list displayed-month 1 displayed-year)))) |
212 (save-excursion | 206 (save-excursion |
213 (set-buffer (get-buffer-create holiday-buffer)) | 207 (calendar-in-read-only-buffer holiday-buffer |
214 (setq buffer-read-only nil) | 208 (calendar-set-mode-line |
215 (calendar-set-mode-line | 209 (if (= y1 y2) |
216 (if (= y1 y2) | 210 (format "%s for %s" title y1) |
217 (format "%s for %s" title y1) | 211 (format "%s for %s-%s" title y1 y2))) |
218 (format "%s for %s-%s" title y1 y2))) | 212 (insert |
219 (erase-buffer) | 213 (mapconcat |
220 (goto-char (point-min)) | 214 (lambda (x) (concat (calendar-date-string (car x)) |
221 (insert | 215 ": " (cadr x))) |
222 (mapconcat | 216 holiday-list "\n"))) |
223 (lambda (x) (concat (calendar-date-string (car x)) | |
224 ": " (cadr x))) | |
225 holiday-list "\n")) | |
226 (goto-char (point-min)) | |
227 (set-buffer-modified-p nil) | |
228 (setq buffer-read-only t) | |
229 (display-buffer holiday-buffer) | |
230 (message "Computing holidays...done")))) | 217 (message "Computing holidays...done")))) |
231 | 218 |
232 ;;;###autoload | 219 ;;;###autoload |
233 (defalias 'holiday-list 'list-holidays) | 220 (defalias 'holiday-list 'list-holidays) |
234 | 221 |
260 (msg (format "%s: %s" date-string holiday-string))) | 247 (msg (format "%s: %s" date-string holiday-string))) |
261 (if (not holiday-list) | 248 (if (not holiday-list) |
262 (message "No holidays known for %s" date-string) | 249 (message "No holidays known for %s" date-string) |
263 (if (<= (length msg) (frame-width)) | 250 (if (<= (length msg) (frame-width)) |
264 (message "%s" msg) | 251 (message "%s" msg) |
265 (set-buffer (get-buffer-create holiday-buffer)) | 252 (calendar-in-read-only-buffer holiday-buffer |
266 (setq buffer-read-only nil) | 253 (calendar-set-mode-line date-string) |
267 (calendar-set-mode-line date-string) | 254 (insert (mapconcat 'identity holiday-list "\n"))) |
268 (erase-buffer) | |
269 (insert (mapconcat 'identity holiday-list "\n")) | |
270 (goto-char (point-min)) | |
271 (set-buffer-modified-p nil) | |
272 (setq buffer-read-only t) | |
273 (display-buffer holiday-buffer) | |
274 (message "Checking holidays...done"))))) | 255 (message "Checking holidays...done"))))) |
275 | 256 |
276 ;;;###cal-autoload | 257 ;;;###cal-autoload |
277 (defun calendar-mark-holidays () | 258 (defun calendar-mark-holidays () |
278 "Mark notable days in the calendar window." | 259 "Mark notable days in the calendar window." |