diff options
| author | Manuel Giraud | 2025-07-07 07:44:08 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2025-08-07 16:49:56 +0300 |
| commit | cbeb558f167a588e7792fd270d3142f6960d643d (patch) | |
| tree | aca1b957dc32abbffb6ad2bd8093926f59bcd3f9 | |
| parent | 55541c8b66c25b1e5fb45c6d8341fd111143d509 (diff) | |
| download | emacs-cbeb558f167a588e7792fd270d3142f6960d643d.tar.gz emacs-cbeb558f167a588e7792fd270d3142f6960d643d.zip | |
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.
| -rw-r--r-- | etc/NEWS | 8 | ||||
| -rw-r--r-- | lisp/calendar/calendar.el | 17 | ||||
| -rw-r--r-- | lisp/calendar/diary-lib.el | 8 | ||||
| -rw-r--r-- | lisp/calendar/holidays.el | 2 |
4 files changed, 26 insertions, 9 deletions
| @@ -2451,6 +2451,14 @@ modifier, it scrolls by year. | |||
| 2451 | The month and year navigation key bindings 'M-}', 'M-{', 'C-x ]' and | 2451 | The month and year navigation key bindings 'M-}', 'M-{', 'C-x ]' and |
| 2452 | 'C-x [' now have the alternative keys '}', '{', ']' and '['. | 2452 | 'C-x [' now have the alternative keys '}', '{', ']' and '['. |
| 2453 | 2453 | ||
| 2454 | --- | ||
| 2455 | *** Avoid modifying user options. | ||
| 2456 | The user options `calendar-mark-holidays-flag' and | ||
| 2457 | `calendar-mark-diary-entries-flag' are not modified anymore when | ||
| 2458 | changing the marking state in the calendar buffer. We now use variables | ||
| 2459 | that are reset to the user option values whenever we generate a new | ||
| 2460 | calendar. | ||
| 2461 | |||
| 2454 | ** Calc | 2462 | ** Calc |
| 2455 | 2463 | ||
| 2456 | *** New user option 'calc-string-maximum-character'. | 2464 | *** New user option 'calc-string-maximum-character'. |
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el index 04bbc2cb8a4..04a42fcd38a 100644 --- a/lisp/calendar/calendar.el +++ b/lisp/calendar/calendar.el | |||
| @@ -456,6 +456,12 @@ LEFT is the leftmost column associated with month segment N, | |||
| 456 | FIRST and LAST are the first and last columns with day digits in, | 456 | FIRST and LAST are the first and last columns with day digits in, |
| 457 | and LAST is the rightmost column.") | 457 | and LAST is the rightmost column.") |
| 458 | 458 | ||
| 459 | (defvar calendar-mark-holidays nil | ||
| 460 | "Variable version of the user option `calendar-mark-holidays-flag'.") | ||
| 461 | |||
| 462 | (defvar calendar-mark-diary-entries nil | ||
| 463 | "Variable version of the user option `calendar-mark-diary-entries-flag'.") | ||
| 464 | |||
| 459 | (defun calendar-month-edges (segment) | 465 | (defun calendar-month-edges (segment) |
| 460 | "Compute the month edge columns for month SEGMENT. | 466 | "Compute the month edge columns for month SEGMENT. |
| 461 | Returns a list (LEFT FIRST LAST RIGHT), where LEFT is the | 467 | 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." | |||
| 1436 | ;; For a full height window or a window that is horizontally | 1442 | ;; For a full height window or a window that is horizontally |
| 1437 | ;; combined don't fit height to that of its buffer. | 1443 | ;; combined don't fit height to that of its buffer. |
| 1438 | (set-window-vscroll nil 0))) | 1444 | (set-window-vscroll nil 0))) |
| 1439 | (and calendar-mark-holidays-flag | 1445 | (and calendar-mark-holidays |
| 1440 | ;; (calendar-date-is-valid-p today) ; useful for BC dates | 1446 | ;; (calendar-date-is-valid-p today) ; useful for BC dates |
| 1441 | (calendar-mark-holidays)) | 1447 | (calendar-mark-holidays)) |
| 1442 | (unwind-protect | 1448 | (unwind-protect |
| 1443 | (if calendar-mark-diary-entries-flag (diary-mark-entries)) | 1449 | (if calendar-mark-diary-entries (diary-mark-entries)) |
| 1444 | (run-hooks (if today-visible | 1450 | (run-hooks (if today-visible |
| 1445 | 'calendar-today-visible-hook | 1451 | 'calendar-today-visible-hook |
| 1446 | 'calendar-today-invisible-hook))))) | 1452 | 'calendar-today-invisible-hook))))) |
| @@ -1833,6 +1839,9 @@ For a complete description, see the info node `Calendar/Diary'. | |||
| 1833 | (make-local-variable 'calendar-mark-ring) | 1839 | (make-local-variable 'calendar-mark-ring) |
| 1834 | (make-local-variable 'displayed-month) ; month in middle of window | 1840 | (make-local-variable 'displayed-month) ; month in middle of window |
| 1835 | (make-local-variable 'displayed-year) ; year in middle of window | 1841 | (make-local-variable 'displayed-year) ; year in middle of window |
| 1842 | ;; Init with user options. | ||
| 1843 | (setq calendar-mark-holidays calendar-mark-holidays-flag | ||
| 1844 | calendar-mark-diary-entries calendar-mark-diary-entries-flag) | ||
| 1836 | ;; Most functions only work if displayed-month and displayed-year are set, | 1845 | ;; Most functions only work if displayed-month and displayed-year are set, |
| 1837 | ;; so let's make sure they're always set. Most likely, this will be reset | 1846 | ;; so let's make sure they're always set. Most likely, this will be reset |
| 1838 | ;; soon in calendar-generate, but better safe than sorry. | 1847 | ;; soon in calendar-generate, but better safe than sorry. |
| @@ -2431,8 +2440,8 @@ interpreted as BC; -1 being 1 BC, and so on." | |||
| 2431 | (defun calendar-unmark () | 2440 | (defun calendar-unmark () |
| 2432 | "Delete all diary/holiday marks/highlighting from the calendar." | 2441 | "Delete all diary/holiday marks/highlighting from the calendar." |
| 2433 | (interactive) | 2442 | (interactive) |
| 2434 | (setq calendar-mark-holidays-flag nil | 2443 | (setq calendar-mark-holidays nil |
| 2435 | calendar-mark-diary-entries-flag nil) | 2444 | calendar-mark-diary-entries nil) |
| 2436 | (with-current-buffer calendar-buffer | 2445 | (with-current-buffer calendar-buffer |
| 2437 | (mapc #'delete-overlay (overlays-in (point-min) (point-max))))) | 2446 | (mapc #'delete-overlay (overlays-in (point-min) (point-max))))) |
| 2438 | 2447 | ||
diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el index 3d8d827417e..056360bbede 100644 --- a/lisp/calendar/diary-lib.el +++ b/lisp/calendar/diary-lib.el | |||
| @@ -1395,8 +1395,8 @@ marks. This is intended to deal with deleted diary entries." | |||
| 1395 | ;; ii) called via calendar-redraw (since calendar has already been | 1395 | ;; ii) called via calendar-redraw (since calendar has already been |
| 1396 | ;; erased). | 1396 | ;; erased). |
| 1397 | ;; Use of REDRAW handles both of these cases. | 1397 | ;; Use of REDRAW handles both of these cases. |
| 1398 | (when (and redraw calendar-mark-diary-entries-flag) | 1398 | (when (and redraw calendar-mark-diary-entries) |
| 1399 | (setq calendar-mark-diary-entries-flag nil) | 1399 | (setq calendar-mark-diary-entries nil) |
| 1400 | (calendar-redraw)) | 1400 | (calendar-redraw)) |
| 1401 | (let ((diary-marking-entries-flag t) | 1401 | (let ((diary-marking-entries-flag t) |
| 1402 | (diary-buffer (find-buffer-visiting diary-file)) | 1402 | (diary-buffer (find-buffer-visiting diary-file)) |
| @@ -1417,7 +1417,7 @@ marks. This is intended to deal with deleted diary entries." | |||
| 1417 | ;; If including, caller has already verified it is readable. | 1417 | ;; If including, caller has already verified it is readable. |
| 1418 | (insert-file-contents diary-file) | 1418 | (insert-file-contents diary-file) |
| 1419 | (if (eq major-mode (default-value 'major-mode)) (diary-mode))) | 1419 | (if (eq major-mode (default-value 'major-mode)) (diary-mode))) |
| 1420 | (setq calendar-mark-diary-entries-flag t) | 1420 | (setq calendar-mark-diary-entries t) |
| 1421 | (setq file-glob-attrs (nth 1 (diary-pull-attrs nil '()))) | 1421 | (setq file-glob-attrs (nth 1 (diary-pull-attrs nil '()))) |
| 1422 | (with-syntax-table diary-syntax-table | 1422 | (with-syntax-table diary-syntax-table |
| 1423 | (save-excursion | 1423 | (save-excursion |
| @@ -2243,7 +2243,7 @@ Prefix argument ARG makes the entry nonmarking." | |||
| 2243 | 2243 | ||
| 2244 | (defun diary-redraw-calendar () | 2244 | (defun diary-redraw-calendar () |
| 2245 | "If `calendar-buffer' is live and diary entries are marked, redraw it." | 2245 | "If `calendar-buffer' is live and diary entries are marked, redraw it." |
| 2246 | (and calendar-mark-diary-entries-flag | 2246 | (and calendar-mark-diary-entries |
| 2247 | (save-excursion | 2247 | (save-excursion |
| 2248 | (calendar-redraw))) | 2248 | (calendar-redraw))) |
| 2249 | ;; Return value suitable for `write-contents-functions'. | 2249 | ;; Return value suitable for `write-contents-functions'. |
diff --git a/lisp/calendar/holidays.el b/lisp/calendar/holidays.el index b40c56abd86..28f3a0ae7f2 100644 --- a/lisp/calendar/holidays.el +++ b/lisp/calendar/holidays.el | |||
| @@ -585,7 +585,7 @@ use instead of point." | |||
| 585 | (with-current-buffer | 585 | (with-current-buffer |
| 586 | (if event (calendar-event-buffer event) | 586 | (if event (calendar-event-buffer event) |
| 587 | (current-buffer)) | 587 | (current-buffer)) |
| 588 | (setq calendar-mark-holidays-flag t) | 588 | (setq calendar-mark-holidays t) |
| 589 | (message "Marking holidays...") | 589 | (message "Marking holidays...") |
| 590 | (dolist (holiday (calendar-holiday-list)) | 590 | (dolist (holiday (calendar-holiday-list)) |
| 591 | (calendar-mark-visible-date (car holiday) calendar-holiday-marker)) | 591 | (calendar-mark-visible-date (car holiday) calendar-holiday-marker)) |