mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 12:21:25 -08:00
Use variables to store marking state
Bug#78967. (calendar-mode): Init new variables with user options. * lisp/calendar/calendar.el (calendar-generate-window) (calendar-unmark): * lisp/calendar/diary-lib.el (diary-mark-entries) (diary-redraw-calendar): * lisp/calendar/holidays.el (calendar-mark-holidays): Use new variables. * etc/NEWS: Document the change.
This commit is contained in:
parent
55541c8b66
commit
cbeb558f16
4 changed files with 26 additions and 9 deletions
8
etc/NEWS
8
etc/NEWS
|
|
@ -2451,6 +2451,14 @@ modifier, it scrolls by year.
|
|||
The month and year navigation key bindings 'M-}', 'M-{', 'C-x ]' and
|
||||
'C-x [' now have the alternative keys '}', '{', ']' and '['.
|
||||
|
||||
---
|
||||
*** Avoid modifying user options.
|
||||
The user options `calendar-mark-holidays-flag' and
|
||||
`calendar-mark-diary-entries-flag' are not modified anymore when
|
||||
changing the marking state in the calendar buffer. We now use variables
|
||||
that are reset to the user option values whenever we generate a new
|
||||
calendar.
|
||||
|
||||
** Calc
|
||||
|
||||
*** New user option 'calc-string-maximum-character'.
|
||||
|
|
|
|||
|
|
@ -456,6 +456,12 @@ LEFT is the leftmost column associated with month segment N,
|
|||
FIRST and LAST are the first and last columns with day digits in,
|
||||
and LAST is the rightmost column.")
|
||||
|
||||
(defvar calendar-mark-holidays nil
|
||||
"Variable version of the user option `calendar-mark-holidays-flag'.")
|
||||
|
||||
(defvar calendar-mark-diary-entries nil
|
||||
"Variable version of the user option `calendar-mark-diary-entries-flag'.")
|
||||
|
||||
(defun calendar-month-edges (segment)
|
||||
"Compute the month edge columns for month SEGMENT.
|
||||
Returns a list (LEFT FIRST LAST RIGHT), where LEFT is the
|
||||
|
|
@ -1436,11 +1442,11 @@ Optional integers MON and YR are used instead of today's date."
|
|||
;; For a full height window or a window that is horizontally
|
||||
;; combined don't fit height to that of its buffer.
|
||||
(set-window-vscroll nil 0)))
|
||||
(and calendar-mark-holidays-flag
|
||||
(and calendar-mark-holidays
|
||||
;; (calendar-date-is-valid-p today) ; useful for BC dates
|
||||
(calendar-mark-holidays))
|
||||
(unwind-protect
|
||||
(if calendar-mark-diary-entries-flag (diary-mark-entries))
|
||||
(if calendar-mark-diary-entries (diary-mark-entries))
|
||||
(run-hooks (if today-visible
|
||||
'calendar-today-visible-hook
|
||||
'calendar-today-invisible-hook)))))
|
||||
|
|
@ -1833,6 +1839,9 @@ For a complete description, see the info node `Calendar/Diary'.
|
|||
(make-local-variable 'calendar-mark-ring)
|
||||
(make-local-variable 'displayed-month) ; month in middle of window
|
||||
(make-local-variable 'displayed-year) ; year in middle of window
|
||||
;; Init with user options.
|
||||
(setq calendar-mark-holidays calendar-mark-holidays-flag
|
||||
calendar-mark-diary-entries calendar-mark-diary-entries-flag)
|
||||
;; Most functions only work if displayed-month and displayed-year are set,
|
||||
;; so let's make sure they're always set. Most likely, this will be reset
|
||||
;; soon in calendar-generate, but better safe than sorry.
|
||||
|
|
@ -2431,8 +2440,8 @@ interpreted as BC; -1 being 1 BC, and so on."
|
|||
(defun calendar-unmark ()
|
||||
"Delete all diary/holiday marks/highlighting from the calendar."
|
||||
(interactive)
|
||||
(setq calendar-mark-holidays-flag nil
|
||||
calendar-mark-diary-entries-flag nil)
|
||||
(setq calendar-mark-holidays nil
|
||||
calendar-mark-diary-entries nil)
|
||||
(with-current-buffer calendar-buffer
|
||||
(mapc #'delete-overlay (overlays-in (point-min) (point-max)))))
|
||||
|
||||
|
|
|
|||
|
|
@ -1395,8 +1395,8 @@ marks. This is intended to deal with deleted diary entries."
|
|||
;; ii) called via calendar-redraw (since calendar has already been
|
||||
;; erased).
|
||||
;; Use of REDRAW handles both of these cases.
|
||||
(when (and redraw calendar-mark-diary-entries-flag)
|
||||
(setq calendar-mark-diary-entries-flag nil)
|
||||
(when (and redraw calendar-mark-diary-entries)
|
||||
(setq calendar-mark-diary-entries nil)
|
||||
(calendar-redraw))
|
||||
(let ((diary-marking-entries-flag t)
|
||||
(diary-buffer (find-buffer-visiting diary-file))
|
||||
|
|
@ -1417,7 +1417,7 @@ marks. This is intended to deal with deleted diary entries."
|
|||
;; If including, caller has already verified it is readable.
|
||||
(insert-file-contents diary-file)
|
||||
(if (eq major-mode (default-value 'major-mode)) (diary-mode)))
|
||||
(setq calendar-mark-diary-entries-flag t)
|
||||
(setq calendar-mark-diary-entries t)
|
||||
(setq file-glob-attrs (nth 1 (diary-pull-attrs nil '())))
|
||||
(with-syntax-table diary-syntax-table
|
||||
(save-excursion
|
||||
|
|
@ -2243,7 +2243,7 @@ Prefix argument ARG makes the entry nonmarking."
|
|||
|
||||
(defun diary-redraw-calendar ()
|
||||
"If `calendar-buffer' is live and diary entries are marked, redraw it."
|
||||
(and calendar-mark-diary-entries-flag
|
||||
(and calendar-mark-diary-entries
|
||||
(save-excursion
|
||||
(calendar-redraw)))
|
||||
;; Return value suitable for `write-contents-functions'.
|
||||
|
|
|
|||
|
|
@ -585,7 +585,7 @@ use instead of point."
|
|||
(with-current-buffer
|
||||
(if event (calendar-event-buffer event)
|
||||
(current-buffer))
|
||||
(setq calendar-mark-holidays-flag t)
|
||||
(setq calendar-mark-holidays t)
|
||||
(message "Marking holidays...")
|
||||
(dolist (holiday (calendar-holiday-list))
|
||||
(calendar-mark-visible-date (car holiday) calendar-holiday-marker))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue