aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2008-04-01 02:46:29 +0000
committerGlenn Morris2008-04-01 02:46:29 +0000
commitaea566be0fa9c10e9edc162bf74ffc78a308fc33 (patch)
tree2aa59e983a5929d391b2d627171124c349dbbdaa
parent6b789b4b036ef3cca843054b1148dc5d9368ac55 (diff)
downloademacs-aea566be0fa9c10e9edc162bf74ffc78a308fc33.tar.gz
emacs-aea566be0fa9c10e9edc162bf74ffc78a308fc33.zip
(calendar-mode-map): Use calendar-mark-holidays rather than obsolete alias.
(mark-visible-calendar-date): Also use overlay for mark characters. (calendar-unmark): Unmark by removing all overlays, rather than redrawing. (calendar-starred-day): Remove. (calendar-mode): Disable undo. Don't make calendar-starred-day local. (calendar-cursor-to-date): No need for special star handling now using overlays. (calendar-star-date): Use overlays.
-rw-r--r--lisp/calendar/calendar.el101
1 files changed, 48 insertions, 53 deletions
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el
index 46f0bcd350a..d4fb02309e6 100644
--- a/lisp/calendar/calendar.el
+++ b/lisp/calendar/calendar.el
@@ -48,32 +48,35 @@
48;; Islamic calendar, to the Baha'i calendar, to the French 48;; Islamic calendar, to the Baha'i calendar, to the French
49;; Revolutionary calendar, to the Mayan calendar, to the Chinese 49;; Revolutionary calendar, to the Mayan calendar, to the Chinese
50;; calendar, to the Coptic calendar, to the Ethiopic calendar, and to 50;; calendar, to the Coptic calendar, to the Ethiopic calendar, and to
51;; the astronomical (Julian) day number. When floating point is 51;; the astronomical (Julian) day number. Times of sunrise/sunset can
52;; available, times of sunrise/sunset can be displayed, as can the 52;; be displayed, as can the phases of the moon. Appointment
53;; phases of the moon. Appointment notification for diary entries is 53;; notification for diary entries is available. Calendar printing via
54;; available. Calendar printing via LaTeX is available. 54;; LaTeX is available.
55 55
56;; The following files are part of the calendar/diary code: 56;; The following files are part of the calendar/diary code:
57 57
58;; appt.el Appointment notification 58;; appt.el Appointment notification
59;; cal-china.el Chinese calendar 59;; cal-bahai.el Baha'i calendar
60;; cal-coptic.el Coptic/Ethiopic calendars 60;; cal-china.el Chinese calendar
61;; cal-dst.el Daylight saving time rules 61;; cal-coptic.el Coptic/Ethiopic calendars
62;; cal-hebrew.el Hebrew calendar 62;; cal-dst.el Daylight saving time rules
63;; cal-islam.el Islamic calendar 63;; cal-french.el French revolutionary calendar
64;; cal-bahai.el Baha'i calendar 64;; cal-hebrew.el Hebrew calendar
65;; cal-iso.el ISO calendar 65;; cal-html.el Calendars in HTML
66;; cal-julian.el Julian/astronomical calendars 66;; cal-islam.el Islamic calendar
67;; cal-mayan.el Mayan calendars 67;; cal-iso.el ISO calendar
68;; cal-menu.el Menu support 68;; cal-julian.el Julian/astronomical calendars
69;; cal-move.el Movement in the calendar 69;; cal-mayan.el Mayan calendars
70;; cal-persia.el Persian calendar 70;; cal-menu.el Menu support
71;; cal-tex.el Calendars in LaTeX 71;; cal-move.el Movement in the calendar
72;; cal-x.el X-windows dedicated frame functions 72;; cal-persia.el Persian calendar
73;; diary-lib.el Diary functions 73;; cal-tex.el Calendars in LaTeX
74;; holidays.el Holiday functions 74;; cal-x.el Dedicated frame functions
75;; lunar.el Phases of the moon 75;; calendar.el This file
76;; solar.el Sunrise/sunset, equinoxes/solstices 76;; diary-lib.el Diary functions
77;; holidays.el Holiday functions
78;; lunar.el Phases of the moon
79;; solar.el Sunrise/sunset, equinoxes/solstices
77 80
78;; Technical details of all the calendrical calculations can be found in 81;; Technical details of all the calendrical calculations can be found in
79;; ``Calendrical Calculations: The Millennium Edition'' by Edward M. Reingold 82;; ``Calendrical Calculations: The Millennium Edition'' by Edward M. Reingold
@@ -1666,7 +1669,7 @@ after the inserted text. Returns t."
1666 (define-key map "q" 'exit-calendar) 1669 (define-key map "q" 'exit-calendar)
1667 (define-key map "a" 'calendar-list-holidays) 1670 (define-key map "a" 'calendar-list-holidays)
1668 (define-key map "h" 'calendar-cursor-holidays) 1671 (define-key map "h" 'calendar-cursor-holidays)
1669 (define-key map "x" 'mark-calendar-holidays) 1672 (define-key map "x" 'calendar-mark-holidays)
1670 (define-key map "u" 'calendar-unmark) 1673 (define-key map "u" 'calendar-unmark)
1671 (define-key map "m" 'mark-diary-entries) 1674 (define-key map "m" 'mark-diary-entries)
1672 (define-key map "d" 'diary-view-entries) 1675 (define-key map "d" 'diary-view-entries)
@@ -1837,9 +1840,6 @@ EVENT is the last mouse event."
1837(defvar calendar-mark-ring nil 1840(defvar calendar-mark-ring nil
1838 "Used by `calendar-set-mark'.") 1841 "Used by `calendar-set-mark'.")
1839 1842
1840(defvar calendar-starred-day nil
1841 "Stores the value of the last date that `calendar-star-date' replaced.")
1842
1843(defun calendar-mode () 1843(defun calendar-mode ()
1844 "A major mode for the calendar window. 1844 "A major mode for the calendar window.
1845 1845
@@ -1851,11 +1851,11 @@ For a complete description, type \
1851 (setq major-mode 'calendar-mode 1851 (setq major-mode 'calendar-mode
1852 mode-name "Calendar" 1852 mode-name "Calendar"
1853 buffer-read-only t 1853 buffer-read-only t
1854 buffer-undo-list t
1854 indent-tabs-mode nil) 1855 indent-tabs-mode nil)
1855 (use-local-map calendar-mode-map) 1856 (use-local-map calendar-mode-map)
1856 (update-calendar-mode-line) 1857 (update-calendar-mode-line)
1857 (make-local-variable 'calendar-mark-ring) 1858 (make-local-variable 'calendar-mark-ring)
1858 (make-local-variable 'calendar-starred-day)
1859 (make-local-variable 'displayed-month) ; month in middle of window 1859 (make-local-variable 'displayed-month) ; month in middle of window
1860 (make-local-variable 'displayed-year) ; year in middle of window 1860 (make-local-variable 'displayed-year) ; year in middle of window
1861 ;; Most functions only work if displayed-month and displayed-year are set, 1861 ;; Most functions only work if displayed-month and displayed-year are set,
@@ -1984,12 +1984,7 @@ ERROR is non-nil, otherwise just returns nil."
1984 (list month 1984 (list month
1985 (string-to-number (buffer-substring (1+ (point)) (+ 4 (point)))) 1985 (string-to-number (buffer-substring (1+ (point)) (+ 4 (point))))
1986 year)) 1986 year))
1987 (if (and (looking-at "\\*") 1987 (if error (error "Not on a date!")))))
1988 (save-excursion
1989 (re-search-backward "[^*]")
1990 (looking-at ".\\*\\*")))
1991 (list month calendar-starred-day year)
1992 (if error (error "Not on a date!"))))))
1993 1988
1994(add-to-list 'debug-ignored-errors "Not on a date!") 1989(add-to-list 'debug-ignored-errors "Not on a date!")
1995 1990
@@ -2316,7 +2311,8 @@ interpreted as BC; -1 being 1 BC, and so on."
2316 (interactive) 2311 (interactive)
2317 (setq mark-holidays-in-calendar nil 2312 (setq mark-holidays-in-calendar nil
2318 mark-diary-entries-in-calendar nil) 2313 mark-diary-entries-in-calendar nil)
2319 (redraw-calendar)) 2314 (with-current-buffer calendar-buffer
2315 (mapc 'delete-overlay (overlays-in (point-min) (point-max)))))
2320 2316
2321(defun calendar-date-is-visible-p (date) 2317(defun calendar-date-is-visible-p (date)
2322 "Return non-nil if DATE is valid and is visible in the calendar window." 2318 "Return non-nil if DATE is valid and is visible in the calendar window."
@@ -2370,14 +2366,10 @@ MARK defaults to `diary-entry-marker'."
2370 ((facep mark) 2366 ((facep mark)
2371 (overlay-put 2367 (overlay-put
2372 (make-overlay (1- (point)) (1+ (point))) 'face mark)) 2368 (make-overlay (1- (point)) (1+ (point))) 'face mark))
2373 ;; Single-character. 2369 ;; Single-character mark, goes after the date.
2374 ((and (stringp mark) (= (length mark) 1)) 2370 ((and (stringp mark) (= (length mark) 1))
2375 (let ((inhibit-read-only t)) 2371 (overlay-put
2376 (forward-char 1) 2372 (make-overlay (1+ (point)) (+ 2 (point))) 'display mark))
2377 ;; Insert before delete so as to better preserve markers.
2378 (insert mark)
2379 (delete-char 1)
2380 (forward-char -2)))
2381 (t ; attr list 2373 (t ; attr list
2382 (let ((temp-face 2374 (let ((temp-face
2383 (make-symbol 2375 (make-symbol
@@ -2392,6 +2384,7 @@ MARK defaults to `diary-entry-marker'."
2392 (make-face temp-face) 2384 (make-face temp-face)
2393 ;; Remove :face info from mark, copy the face info into temp-face. 2385 ;; Remove :face info from mark, copy the face info into temp-face.
2394 (while (setq faceinfo (memq :face faceinfo)) 2386 (while (setq faceinfo (memq :face faceinfo))
2387 ;; FIXME not read.
2395 (copy-face (read (nth 1 faceinfo)) temp-face) 2388 (copy-face (read (nth 1 faceinfo)) temp-face)
2396 (setcar faceinfo nil) 2389 (setcar faceinfo nil)
2397 (setcar (cdr faceinfo) nil)) 2390 (setcar (cdr faceinfo) nil))
@@ -2404,17 +2397,19 @@ MARK defaults to `diary-entry-marker'."
2404(defun calendar-star-date () 2397(defun calendar-star-date ()
2405 "Replace the date under the cursor in the calendar window with asterisks. 2398 "Replace the date under the cursor in the calendar window with asterisks.
2406You might want to add this function to `today-visible-calendar-hook'." 2399You might want to add this function to `today-visible-calendar-hook'."
2407 (let ((inhibit-read-only t) 2400 (unless (catch 'found
2408 (modified (buffer-modified-p))) 2401 (dolist (ol (overlays-at (point)))
2409 (forward-char 1) 2402 (and (overlay-get ol 'calendar-star)
2410 (setq calendar-starred-day 2403 (throw 'found t))))
2411 (string-to-number (buffer-substring (point) (- (point) 2)))) 2404 (let ((ol (make-overlay (1- (point)) (point))))
2412 ;; Insert before deleting, to better preserve markers. 2405 (overlay-put ol 'display "*")
2413 (insert "**") 2406 (overlay-put ol 'calendar-star t)
2414 (forward-char -2) 2407 ;; Use copy-sequence to avoid merging of identical 'display props.
2415 (delete-char -2) 2408 ;; Use two overlays so as not to mess up
2416 (forward-char 1) 2409 ;; calendar-cursor-to-nearest-date (and calendar-forward-day).
2417 (restore-buffer-modified-p modified))) 2410 (overlay-put (setq ol (make-overlay (point) (1+ (point))))
2411 'display (copy-sequence "*"))
2412 (overlay-put ol 'calendar-star t))))
2418 2413
2419(defun calendar-mark-today () 2414(defun calendar-mark-today ()
2420 "Mark the date under the cursor in the calendar window. 2415 "Mark the date under the cursor in the calendar window.