Commit aea566be authored by Glenn Morris's avatar Glenn Morris
Browse files

(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.
parent 6b789b4b
...@@ -48,32 +48,35 @@ ...@@ -48,32 +48,35 @@
;; Islamic calendar, to the Baha'i calendar, to the French ;; Islamic calendar, to the Baha'i calendar, to the French
;; Revolutionary calendar, to the Mayan calendar, to the Chinese ;; Revolutionary calendar, to the Mayan calendar, to the Chinese
;; calendar, to the Coptic calendar, to the Ethiopic calendar, and to ;; calendar, to the Coptic calendar, to the Ethiopic calendar, and to
;; the astronomical (Julian) day number. When floating point is ;; the astronomical (Julian) day number. Times of sunrise/sunset can
;; available, times of sunrise/sunset can be displayed, as can the ;; be displayed, as can the phases of the moon. Appointment
;; phases of the moon. Appointment notification for diary entries is ;; notification for diary entries is available. Calendar printing via
;; available. Calendar printing via LaTeX is available. ;; LaTeX is available.
;; The following files are part of the calendar/diary code: ;; The following files are part of the calendar/diary code:
;; appt.el Appointment notification ;; appt.el Appointment notification
;; cal-china.el Chinese calendar ;; cal-bahai.el Baha'i calendar
;; cal-coptic.el Coptic/Ethiopic calendars ;; cal-china.el Chinese calendar
;; cal-dst.el Daylight saving time rules ;; cal-coptic.el Coptic/Ethiopic calendars
;; cal-hebrew.el Hebrew calendar ;; cal-dst.el Daylight saving time rules
;; cal-islam.el Islamic calendar ;; cal-french.el French revolutionary calendar
;; cal-bahai.el Baha'i calendar ;; cal-hebrew.el Hebrew calendar
;; cal-iso.el ISO calendar ;; cal-html.el Calendars in HTML
;; cal-julian.el Julian/astronomical calendars ;; cal-islam.el Islamic calendar
;; cal-mayan.el Mayan calendars ;; cal-iso.el ISO calendar
;; cal-menu.el Menu support ;; cal-julian.el Julian/astronomical calendars
;; cal-move.el Movement in the calendar ;; cal-mayan.el Mayan calendars
;; cal-persia.el Persian calendar ;; cal-menu.el Menu support
;; cal-tex.el Calendars in LaTeX ;; cal-move.el Movement in the calendar
;; cal-x.el X-windows dedicated frame functions ;; cal-persia.el Persian calendar
;; diary-lib.el Diary functions ;; cal-tex.el Calendars in LaTeX
;; holidays.el Holiday functions ;; cal-x.el Dedicated frame functions
;; lunar.el Phases of the moon ;; calendar.el This file
;; solar.el Sunrise/sunset, equinoxes/solstices ;; diary-lib.el Diary functions
;; holidays.el Holiday functions
;; lunar.el Phases of the moon
;; solar.el Sunrise/sunset, equinoxes/solstices
;; Technical details of all the calendrical calculations can be found in ;; Technical details of all the calendrical calculations can be found in
;; ``Calendrical Calculations: The Millennium Edition'' by Edward M. Reingold ;; ``Calendrical Calculations: The Millennium Edition'' by Edward M. Reingold
...@@ -1666,7 +1669,7 @@ after the inserted text. Returns t." ...@@ -1666,7 +1669,7 @@ after the inserted text. Returns t."
(define-key map "q" 'exit-calendar) (define-key map "q" 'exit-calendar)
(define-key map "a" 'calendar-list-holidays) (define-key map "a" 'calendar-list-holidays)
(define-key map "h" 'calendar-cursor-holidays) (define-key map "h" 'calendar-cursor-holidays)
(define-key map "x" 'mark-calendar-holidays) (define-key map "x" 'calendar-mark-holidays)
(define-key map "u" 'calendar-unmark) (define-key map "u" 'calendar-unmark)
(define-key map "m" 'mark-diary-entries) (define-key map "m" 'mark-diary-entries)
(define-key map "d" 'diary-view-entries) (define-key map "d" 'diary-view-entries)
...@@ -1837,9 +1840,6 @@ EVENT is the last mouse event." ...@@ -1837,9 +1840,6 @@ EVENT is the last mouse event."
(defvar calendar-mark-ring nil (defvar calendar-mark-ring nil
"Used by `calendar-set-mark'.") "Used by `calendar-set-mark'.")
(defvar calendar-starred-day nil
"Stores the value of the last date that `calendar-star-date' replaced.")
(defun calendar-mode () (defun calendar-mode ()
"A major mode for the calendar window. "A major mode for the calendar window.
...@@ -1851,11 +1851,11 @@ For a complete description, type \ ...@@ -1851,11 +1851,11 @@ For a complete description, type \
(setq major-mode 'calendar-mode (setq major-mode 'calendar-mode
mode-name "Calendar" mode-name "Calendar"
buffer-read-only t buffer-read-only t
buffer-undo-list t
indent-tabs-mode nil) indent-tabs-mode nil)
(use-local-map calendar-mode-map) (use-local-map calendar-mode-map)
(update-calendar-mode-line) (update-calendar-mode-line)
(make-local-variable 'calendar-mark-ring) (make-local-variable 'calendar-mark-ring)
(make-local-variable 'calendar-starred-day)
(make-local-variable 'displayed-month) ; month in middle of window (make-local-variable 'displayed-month) ; month in middle of window
(make-local-variable 'displayed-year) ; year in middle of window (make-local-variable 'displayed-year) ; year in middle of window
;; Most functions only work if displayed-month and displayed-year are set, ;; 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,12 +1984,7 @@ ERROR is non-nil, otherwise just returns nil."
(list month (list month
(string-to-number (buffer-substring (1+ (point)) (+ 4 (point)))) (string-to-number (buffer-substring (1+ (point)) (+ 4 (point))))
year)) year))
(if (and (looking-at "\\*") (if error (error "Not on a date!")))))
(save-excursion
(re-search-backward "[^*]")
(looking-at ".\\*\\*")))
(list month calendar-starred-day year)
(if error (error "Not on a date!"))))))
(add-to-list 'debug-ignored-errors "Not on a date!") (add-to-list 'debug-ignored-errors "Not on a date!")
...@@ -2316,7 +2311,8 @@ interpreted as BC; -1 being 1 BC, and so on." ...@@ -2316,7 +2311,8 @@ interpreted as BC; -1 being 1 BC, and so on."
(interactive) (interactive)
(setq mark-holidays-in-calendar nil (setq mark-holidays-in-calendar nil
mark-diary-entries-in-calendar nil) mark-diary-entries-in-calendar nil)
(redraw-calendar)) (with-current-buffer calendar-buffer
(mapc 'delete-overlay (overlays-in (point-min) (point-max)))))
(defun calendar-date-is-visible-p (date) (defun calendar-date-is-visible-p (date)
"Return non-nil if DATE is valid and is visible in the calendar window." "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,14 +2366,10 @@ MARK defaults to `diary-entry-marker'."
((facep mark) ((facep mark)
(overlay-put (overlay-put
(make-overlay (1- (point)) (1+ (point))) 'face mark)) (make-overlay (1- (point)) (1+ (point))) 'face mark))
;; Single-character. ;; Single-character mark, goes after the date.
((and (stringp mark) (= (length mark) 1)) ((and (stringp mark) (= (length mark) 1))
(let ((inhibit-read-only t)) (overlay-put
(forward-char 1) (make-overlay (1+ (point)) (+ 2 (point))) 'display mark))
;; Insert before delete so as to better preserve markers.
(insert mark)
(delete-char 1)
(forward-char -2)))
(t ; attr list (t ; attr list
(let ((temp-face (let ((temp-face
(make-symbol (make-symbol
...@@ -2392,6 +2384,7 @@ MARK defaults to `diary-entry-marker'." ...@@ -2392,6 +2384,7 @@ MARK defaults to `diary-entry-marker'."
(make-face temp-face) (make-face temp-face)
;; Remove :face info from mark, copy the face info into temp-face. ;; Remove :face info from mark, copy the face info into temp-face.
(while (setq faceinfo (memq :face faceinfo)) (while (setq faceinfo (memq :face faceinfo))
;; FIXME not read.
(copy-face (read (nth 1 faceinfo)) temp-face) (copy-face (read (nth 1 faceinfo)) temp-face)
(setcar faceinfo nil) (setcar faceinfo nil)
(setcar (cdr faceinfo) nil)) (setcar (cdr faceinfo) nil))
...@@ -2404,17 +2397,19 @@ MARK defaults to `diary-entry-marker'." ...@@ -2404,17 +2397,19 @@ MARK defaults to `diary-entry-marker'."
(defun calendar-star-date () (defun calendar-star-date ()
"Replace the date under the cursor in the calendar window with asterisks. "Replace the date under the cursor in the calendar window with asterisks.
You might want to add this function to `today-visible-calendar-hook'." You might want to add this function to `today-visible-calendar-hook'."
(let ((inhibit-read-only t) (unless (catch 'found
(modified (buffer-modified-p))) (dolist (ol (overlays-at (point)))
(forward-char 1) (and (overlay-get ol 'calendar-star)
(setq calendar-starred-day (throw 'found t))))
(string-to-number (buffer-substring (point) (- (point) 2)))) (let ((ol (make-overlay (1- (point)) (point))))
;; Insert before deleting, to better preserve markers. (overlay-put ol 'display "*")
(insert "**") (overlay-put ol 'calendar-star t)
(forward-char -2) ;; Use copy-sequence to avoid merging of identical 'display props.
(delete-char -2) ;; Use two overlays so as not to mess up
(forward-char 1) ;; calendar-cursor-to-nearest-date (and calendar-forward-day).
(restore-buffer-modified-p modified))) (overlay-put (setq ol (make-overlay (point) (1+ (point))))
'display (copy-sequence "*"))
(overlay-put ol 'calendar-star t))))
(defun calendar-mark-today () (defun calendar-mark-today ()
"Mark the date under the cursor in the calendar window. "Mark the date under the cursor in the calendar window.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment