From 8b837af563c6e875befe6ef1cd33b54efd5e7b5e Mon Sep 17 00:00:00 2001 From: Thuna Date: Thu, 16 Feb 2023 06:08:25 +0100 Subject: [PATCH 2/2] Make calendar.el `*-buffer' variables obsolete for `*-buffer-name' * lisp/calendar/calendar.el (calendar-buffer holiday-buffer diary-fancy-buffer calendar-other-calendars-buffer lunar-phases-buffer solar-sunrises-buffer calendar-hebrew-yahrzeit-buffer calendar-buffer-name holiday-buffer-name diary-fancy-buffer-name calendar-other-calendars-buffer-name lunar-phases-buffer-name solar-sunrises-buffer-name calendar-hebrew-yahrzeit-buffer-name): Mark `*-buffer' variables as obsolete in favor of their `*-buffer-name' equivalents. * lisp/calendar/cal-hebrew.el (calendar-hebrew-mark-date-pattern calendar-hebrew-list-yahrzeits calendar-hebrew-list-yahrzeits): lisp/calendar/cal-x.el (calendar-dedicate-diary calendar-frame-setup): lisp/calendar/calendar.el (calendar-basic-setup calendar-basic-setup calendar-generate-window calendar-generate-month calendar-string-spread calendar-update-mode-line calendar-unmark calendar-mark-visible-date calendar-print-other-dates): lisp/calendar/diary-lib.el (diary-header-line-format diary-display-no-entries diary-fancy-display diary-print-entries diary-mail-entries diary-mark-sexp-entries calendar-mark-days-named calendar-mark-date-pattern calendar-mark-1 diary-insert-cyclic-entry): lisp/calendar/holidays.el (calendar-list-holidays list-holidays calendar-cursor-holidays): lisp/calendar/lunar.el (calendar-lunar-phases): lisp/calendar/solar.el (calendar-sunrise-sunset-month): lisp/calendar/todo-mode.el (todo-set-date-from-calendar): lisp/org/org-agenda.el (org-get-entries-from-diary org-get-entries-from-diary org-get-entries-from-diary): lisp/org/org.el (org-read-date org-eval-in-calendar org-timestamp-change org-modify-ts-extra org-goto-calendar): test/lisp/calendar/cal-julian-tests.el (with-cal-julian-test): Replace the `*-buffer' variables for their `*-buffer-name' equivalent. --- lisp/calendar/cal-hebrew.el | 6 +-- lisp/calendar/cal-x.el | 8 ++-- lisp/calendar/calendar.el | 63 +++++++++++++++++--------- lisp/calendar/diary-lib.el | 22 ++++----- lisp/calendar/holidays.el | 6 +-- lisp/calendar/lunar.el | 2 +- lisp/calendar/solar.el | 2 +- lisp/calendar/todo-mode.el | 2 +- lisp/org/org-agenda.el | 8 ++-- lisp/org/org.el | 12 ++--- test/lisp/calendar/cal-julian-tests.el | 2 +- 11 files changed, 77 insertions(+), 56 deletions(-) diff --git a/lisp/calendar/cal-hebrew.el b/lisp/calendar/cal-hebrew.el index b6c60185029..35c122e5ab3 100644 --- a/lisp/calendar/cal-hebrew.el +++ b/lisp/calendar/cal-hebrew.el @@ -614,7 +614,7 @@ calendar-hebrew-mark-date-pattern passed to `calendar-mark-visible-date' as MARK." ;; FIXME not the same as the Bahá’í and Islamic cases, so can't use ;; calendar-mark-1. - (with-current-buffer calendar-buffer + (with-current-buffer calendar-buffer-name (if (and (not (zerop month)) (not (zerop day))) (if (not (zerop year)) ;; Fully specified Hebrew date. @@ -679,7 +679,7 @@ calendar-hebrew-list-yahrzeits from the cursor position." (interactive (let* ((death-date - (if (equal (current-buffer) (get-buffer calendar-buffer)) + (if (equal (current-buffer) (get-buffer calendar-buffer-name)) (calendar-cursor-to-date t) (let* ((today (calendar-current-date)) (year (calendar-read-sexp @@ -718,7 +718,7 @@ calendar-hebrew-list-yahrzeits (calendar-absolute-from-gregorian death-date))) (h-year (calendar-extract-year h-date)) (i (1- start-year))) - (calendar-in-read-only-buffer calendar-hebrew-yahrzeit-buffer + (calendar-in-read-only-buffer calendar-hebrew-yahrzeit-buffer-name (calendar-set-mode-line (format "Yahrzeit dates for %s = %s" (calendar-date-string death-date) diff --git a/lisp/calendar/cal-x.el b/lisp/calendar/cal-x.el index 58eea324e82..d61ac1a76d7 100644 --- a/lisp/calendar/cal-x.el +++ b/lisp/calendar/cal-x.el @@ -97,10 +97,10 @@ calendar-dedicate-diary (progn ;; If there are no diary entries, there won't be a buffer ;; to dedicate, so make a basic one. - (or (get-buffer diary-fancy-buffer) - (calendar-in-read-only-buffer diary-fancy-buffer + (or (get-buffer diary-fancy-buffer-name) + (calendar-in-read-only-buffer diary-fancy-buffer-name (calendar-set-mode-line "Diary Entries"))) - diary-fancy-buffer) + diary-fancy-buffer-name) (get-file-buffer diary-file))) t)) @@ -138,7 +138,7 @@ calendar-frame-setup calendar-and-diary-frame-parameters calendar-frame-parameters)))) (calendar-basic-setup prompt (not (eq config 'one-frame))) - (set-window-buffer (selected-window) calendar-buffer) + (set-window-buffer (selected-window) calendar-buffer-name) (set-window-dedicated-p (selected-window) t) (if (eq config 'one-frame) (calendar-dedicate-diary)))))) diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el index 2521a9c73c1..093873e84a5 100644 --- a/lisp/calendar/calendar.el +++ b/lisp/calendar/calendar.el @@ -1079,43 +1079,64 @@ calendar-time-zone-style (defconst calendar-first-date-row 3 "First row in the calendar with actual dates.") -(defcustom calendar-buffer "*Calendar*" +(make-obsolete-variable 'calendar-buffer + 'calendar-buffer-name + "30.0.50") +(defcustom calendar-buffer-name "*Calendar*" "Name of the buffer used for the calendar." :type 'string :version "30.0.50" :group 'calendar) -(defcustom holiday-buffer "*Holidays*" +(make-obsolete-variable 'holiday-buffer + 'holiday-buffer-name + "30.0.50") +(defcustom holiday-buffer-name "*Holidays*" "Name of the buffer used for the displaying the holidays." :type 'string :version "30.0.50" :group 'calendar) -(defcustom diary-fancy-buffer "*Fancy Diary Entries*" +(make-obsolete-variable 'diary-fancy-buffer + 'diary-fancy-buffer-name + "30.0.50") +(defcustom diary-fancy-buffer-name "*Fancy Diary Entries*" "Name of the buffer used for the optional fancy display of the diary." :type 'string :version "30.0.50" :group 'calendar) -(defcustom calendar-other-calendars-buffer "*Other Calendars*" +(make-obsolete-variable 'calendar-other-calendars-buffer + 'calendar-other-calendars-buffer-name + "30.0.50") +(defcustom calendar-other-calendars-buffer-name "*Other Calendars*" "Name of the buffer used for the display of date on other calendars." :type 'string :version "30.0.50" :group 'calendar) -(defcustom lunar-phases-buffer "*Phases of Moon*" +(make-obsolete-variable 'lunar-phases-buffer + 'lunar-phases-buffer-name + "30.0.50") +(defcustom lunar-phases-buffer-name "*Phases of Moon*" "Name of the buffer used for the lunar phases." :type 'string :version "30.0.50" :group 'calendar) -(defcustom solar-sunrises-buffer "*Sunrise/Sunset Times*" +(make-obsolete-variable 'solar-sunrises-buffer + 'solar-sunrises-buffer-name + "30.0.50") +(defcustom solar-sunrises-buffer-name "*Sunrise/Sunset Times*" "Name of buffer used for sunrise/sunset times." :type 'string :version "30.0.50" :group 'calendar) -(defcustom calendar-hebrew-yahrzeit-buffer "*Yahrzeits*" +(make-obsolete-variable 'calendar-hebrew-yahrzeit-buffer + 'calendar-hebrew-yahrzeit-buffer-name + "30.0.50") +(defcustom calendar-hebrew-yahrzeit-buffer-name "*Yahrzeits*" "Name of the buffer used by `calendar-hebrew-list-yahrzeits'." :type 'string :version "30.0.50" @@ -1341,7 +1362,7 @@ calendar-basic-setup display the generated calendar." (interactive "P") (let ((buff (current-buffer))) - (set-buffer (get-buffer-create calendar-buffer)) + (set-buffer (get-buffer-create calendar-buffer-name)) (calendar-mode) (let* ((pop-up-windows t) ;; Not really needed now, but means we use exactly the same @@ -1386,7 +1407,7 @@ calendar-basic-setup ;; horizontally and we end up with three side-by-side windows. (when (window-splittable-p (selected-window) t) (split-window-right)) - (pop-to-buffer calendar-buffer) + (pop-to-buffer calendar-buffer-name) ;; Has the window already been split vertically? (when (and (not (window-dedicated-p)) (window-splittable-p (selected-window)) @@ -1425,7 +1446,7 @@ calendar-generate-window (today-visible (or (not mon) (<= (abs (calendar-interval mon yr month year)) 1))) (in-calendar-window (eq (window-buffer) - (get-buffer calendar-buffer)))) + (get-buffer calendar-buffer-name)))) (calendar-generate (or mon month) (or yr year)) (calendar-update-mode-line) (calendar-cursor-to-visible-date @@ -1565,10 +1586,10 @@ calendar-generate-month (calendar-insert-at-column indent calendar-intermonth-text trunc)))))) (defun calendar-redraw () - "Redraw the calendar display, if `calendar-buffer' is live." + "Redraw the calendar display, if `calendar-buffer-name' is live." (interactive) - (when (get-buffer calendar-buffer) - (with-current-buffer calendar-buffer + (when (get-buffer calendar-buffer-name) + (with-current-buffer calendar-buffer-name (let ((cursor-date (calendar-cursor-to-nearest-date))) (calendar-generate-window displayed-month displayed-year) (calendar-cursor-to-visible-date cursor-date)) @@ -1854,8 +1875,8 @@ calendar-string-spread (defun calendar-update-mode-line () "Update the calendar mode line with the current date and date style." (if (and calendar-mode-line-format - (bufferp (get-buffer calendar-buffer))) - (with-current-buffer calendar-buffer + (bufferp (get-buffer calendar-buffer-name))) + (with-current-buffer calendar-buffer-name (let ((start (- calendar-left-margin 2))) (calendar-dlet ((date (condition-case nil (calendar-cursor-to-nearest-date) @@ -1873,10 +1894,10 @@ calendar-update-mode-line (defun calendar-buffer-list () "List of all calendar-related buffers (as buffers, not strings)." (let (buffs) - (dolist (b (list calendar-hebrew-yahrzeit-buffer lunar-phases-buffer - holiday-buffer diary-fancy-buffer solar-sunrises-buffer + (dolist (b (list calendar-hebrew-yahrzeit-buffer-name lunar-phases-buffer-name + holiday-buffer-name diary-fancy-buffer-name solar-sunrises-buffer-name (get-file-buffer diary-file) - calendar-buffer calendar-other-calendars-buffer)) + calendar-buffer-name calendar-other-calendars-buffer-name)) (and b (setq b (get-buffer b)) (push b buffs))) buffs)) @@ -2415,7 +2436,7 @@ calendar-unmark (interactive) (setq calendar-mark-holidays-flag nil calendar-mark-diary-entries-flag nil) - (with-current-buffer calendar-buffer + (with-current-buffer calendar-buffer-name (mapc #'delete-overlay (overlays-in (point-min) (point-max))))) (defun calendar-date-is-visible-p (date) @@ -2527,7 +2548,7 @@ calendar-mark-visible-date MARK is a single-character string, a list of face attributes/values, or a face. MARK defaults to `diary-entry-marker'." (if (calendar-date-is-valid-p date) - (with-current-buffer calendar-buffer + (with-current-buffer calendar-buffer-name (save-excursion (calendar-cursor-to-visible-date date) (setq mark @@ -2704,7 +2725,7 @@ calendar-print-other-dates (and (setq selection (cal-menu-x-popup-menu event title (mapcar #'list others))) (call-interactively selection)) - (calendar-in-read-only-buffer calendar-other-calendars-buffer + (calendar-in-read-only-buffer calendar-other-calendars-buffer-name (calendar-set-mode-line title) (insert (mapconcat #'identity others "\n")))))) diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el index 946cf0e7236..221c8436779 100644 --- a/lisp/calendar/diary-lib.el +++ b/lisp/calendar/diary-lib.el @@ -438,7 +438,7 @@ diary-header-line-format (defun diary-live-p () "Return non-nil if the diary is being displayed. The actual return value is a diary buffer." - (or (get-buffer diary-fancy-buffer) + (or (get-buffer diary-fancy-buffer-name) (and diary-file (find-buffer-visiting diary-file)))) ;;;###cal-autoload @@ -974,7 +974,7 @@ diary-display-no-entries (not holiday-list)) (message "%s" msg) ;; holiday-list which is too wide for a message gets a buffer. - (calendar-in-read-only-buffer holiday-buffer + (calendar-in-read-only-buffer holiday-buffer-name (calendar-set-mode-line (format "Holidays for %s" diary--date-string)) (insert (mapconcat #'identity holiday-list "\n"))) @@ -1055,7 +1055,7 @@ diary-fancy-display (diary-unhide-everything)) (unless (car (diary-display-no-entries)) ; no entries ;; Prepare the fancy diary buffer. - (calendar-in-read-only-buffer diary-fancy-buffer + (calendar-in-read-only-buffer diary-fancy-buffer-name (calendar-set-mode-line "Diary Entries") (let ((holiday-list-last-month 1) (holiday-list-last-year 1) @@ -1152,7 +1152,7 @@ diary-print-entries The hooks given by the variable `diary-print-entries-hook' are called to do the actual printing." (interactive) - (let ((diary-buffer (get-buffer diary-fancy-buffer)) + (let ((diary-buffer (get-buffer diary-fancy-buffer-name)) temp-buffer heading start end) (if diary-buffer (with-current-buffer diary-buffer @@ -1235,8 +1235,8 @@ diary-mail-entries (concat "Diary entries generated " (calendar-date-string (calendar-current-date)))) (insert - (if (get-buffer diary-fancy-buffer) - (with-current-buffer diary-fancy-buffer (buffer-string)) + (if (get-buffer diary-fancy-buffer-name) + (with-current-buffer diary-fancy-buffer-name (buffer-string)) "No entries found")) (call-interactively (get mail-user-agent 'sendfunc)))) @@ -1470,7 +1470,7 @@ diary-mark-sexp-entries (file-glob-attrs (nth 1 (diary-pull-attrs nil '()))) m y first-date last-date date mark file-glob-attrs sexp-start sexp entry entry-start) - (with-current-buffer calendar-buffer + (with-current-buffer calendar-buffer-name (setq m displayed-month y displayed-year)) (calendar-increment-month m y -1) @@ -1522,7 +1522,7 @@ calendar-mark-days-named "Mark all dates in the calendar window that are day DAYNAME of the week. 0 means all Sundays, 1 means all Mondays, and so on. Optional argument COLOR is passed to `calendar-mark-visible-date' as MARK." - (with-current-buffer calendar-buffer + (with-current-buffer calendar-buffer-name (let ((prev-month displayed-month) (prev-year displayed-year) (succ-month displayed-month) @@ -1557,7 +1557,7 @@ calendar-mark-date-pattern "Mark all dates in the calendar window that conform to MONTH/DAY/YEAR. A value of 0 in any position is a wildcard. Optional argument COLOR is passed to `calendar-mark-visible-date' as MARK." - (with-current-buffer calendar-buffer + (with-current-buffer calendar-buffer-name (let ((m displayed-month) (y displayed-year)) (calendar-increment-month m y -1) @@ -1601,7 +1601,7 @@ calendar-mark-1 The function FROMABS converts absolute dates to the appropriate date system. The function TOABS carries out the inverse operation. Optional argument COLOR is passed to `calendar-mark-visible-date' as MARK." - (with-current-buffer calendar-buffer + (with-current-buffer calendar-buffer-name (if (and (not (zerop month)) (not (zerop day))) (if (not (zerop year)) ;; Fully specified date. @@ -2241,7 +2241,7 @@ diary-insert-cyclic-entry ;;; Diary mode. (defun diary-redraw-calendar () - "If `calendar-buffer' is live and diary entries are marked, redraw it." + "If `calendar-buffer-name' is live and diary entries are marked, redraw it." (and calendar-mark-diary-entries-flag (save-excursion (calendar-redraw))) diff --git a/lisp/calendar/holidays.el b/lisp/calendar/holidays.el index f30c5653c11..8fe203aa5ff 100644 --- a/lisp/calendar/holidays.el +++ b/lisp/calendar/holidays.el @@ -369,7 +369,7 @@ calendar-list-holidays (y2 displayed-year)) (if (not holiday-list) (message "Looking up holidays...none found") - (calendar-in-read-only-buffer holiday-buffer + (calendar-in-read-only-buffer holiday-buffer-name (calendar-increment-month m1 y1 -1) (calendar-increment-month m2 y2 1) (calendar-set-mode-line @@ -495,7 +495,7 @@ list-holidays (setq s (calendar-absolute-from-gregorian (list displayed-month 1 displayed-year)))) (save-current-buffer - (calendar-in-read-only-buffer holiday-buffer + (calendar-in-read-only-buffer holiday-buffer-name (calendar-set-mode-line (if (= y1 y2) (format "%s for %s" title y1) @@ -576,7 +576,7 @@ calendar-cursor-holidays (mapconcat 'identity holiday-list "; ")))) (frame-width)) (message "%s" msg) - (calendar-in-read-only-buffer holiday-buffer + (calendar-in-read-only-buffer holiday-buffer-name (calendar-set-mode-line date-string) (insert (mapconcat 'identity holiday-list "\n"))) (message "Checking holidays...done")))))) diff --git a/lisp/calendar/lunar.el b/lisp/calendar/lunar.el index 0db811417af..032daaf5d39 100644 --- a/lisp/calendar/lunar.el +++ b/lisp/calendar/lunar.el @@ -232,7 +232,7 @@ calendar-lunar-phases (y2 displayed-year)) (calendar-increment-month m1 y1 -1) (calendar-increment-month m2 y2 1) - (calendar-in-read-only-buffer lunar-phases-buffer + (calendar-in-read-only-buffer lunar-phases-buffer-name (calendar-set-mode-line (if (= y1 y2) (format "Phases of the Moon from %s to %s, %d%%-" diff --git a/lisp/calendar/solar.el b/lisp/calendar/solar.el index d82215a6d35..b76895cd2af 100644 --- a/lisp/calendar/solar.el +++ b/lisp/calendar/solar.el @@ -882,7 +882,7 @@ calendar-sunrise-sunset-month (title (format "Sunrise/sunset times for %s %d at %s" (calendar-month-name month) year (eval calendar-location-name)))) - (calendar-in-read-only-buffer solar-sunrises-buffer + (calendar-in-read-only-buffer solar-sunrises-buffer-name (calendar-set-mode-line title) (insert title ":\n\n") (dotimes (i last) diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index 671210f3ee8..10d183945df 100644 --- a/lisp/calendar/todo-mode.el +++ b/lisp/calendar/todo-mode.el @@ -2031,7 +2031,7 @@ todo-set-date-from-calendar (message "Put cursor on a date and type to set it.") (recursive-edit) (unwind-protect - (when (equal (buffer-name) calendar-buffer) + (when (equal (buffer-name) calendar-buffer-name) (setq todo-date-from-calendar (calendar-date-string (calendar-cursor-to-date t) t t)) (calendar-exit) diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el index 3db33c4d63e..e2e3c3fed3d 100644 --- a/lisp/org/org-agenda.el +++ b/lisp/org/org-agenda.el @@ -5339,7 +5339,7 @@ org-get-entries-from-diary "Get the (Emacs Calendar) diary entries for DATE." (require 'diary-lib) (declare-function diary-fancy-display "diary-lib" ()) - (let* ((diary-fancy-buffer "*temporary-fancy-diary-buffer*") + (let* ((diary-fancy-buffer-name "*temporary-fancy-diary-buffer*") (diary-display-function #'diary-fancy-display) (pop-up-frames nil) (diary-list-entries-hook @@ -5353,9 +5353,9 @@ org-get-entries-from-diary (save-excursion (save-window-excursion (diary-list-entries date 1))) - (if (not (get-buffer diary-fancy-buffer)) + (if (not (get-buffer diary-fancy-buffer-name)) (setq entries nil) - (with-current-buffer diary-fancy-buffer + (with-current-buffer diary-fancy-buffer-name (setq buffer-read-only nil) (if (zerop (buffer-size)) ;; No entries @@ -5374,7 +5374,7 @@ org-get-entries-from-diary (replace-match (concat "; " (match-string 1))))) (buffer-string))))) (set-buffer-modified-p nil) - (kill-buffer diary-fancy-buffer))) + (kill-buffer diary-fancy-buffer-name))) (when entries (setq entries (org-split-string entries "\n")) (setq entries diff --git a/lisp/org/org.el b/lisp/org/org.el index 9a4f7803cf4..d9551677db0 100644 --- a/lisp/org/org.el +++ b/lisp/org/org.el @@ -13710,7 +13710,7 @@ org-read-date (calendar) (when (eq calendar-setup 'calendar-only) (setq cal-frame - (window-frame (get-buffer-window "*Calendar*" 'visible))) + (window-frame (get-buffer-window calendar-buffer-name 'visible))) (select-frame cal-frame)) (org-eval-in-calendar '(setq cursor-type nil) t) (unwind-protect @@ -13746,7 +13746,7 @@ org-read-date (when org-read-date-overlay (delete-overlay org-read-date-overlay) (setq org-read-date-overlay nil))))) - (bury-buffer "*Calendar*") + (bury-buffer calendar-buffer-name) (when cal-frame (delete-frame cal-frame) (select-frame-set-input-focus cur-frame)))))) @@ -14103,7 +14103,7 @@ org-eval-in-calendar Unless KEEPDATE is non-nil, update `org-ans2' to the cursor date." (let ((sf (selected-frame)) (sw (selected-window))) - (select-window (get-buffer-window "*Calendar*" t)) + (select-window (get-buffer-window calendar-buffer-name t)) (eval form t) (when (and (not keepdate) (calendar-cursor-to-date)) (let* ((date (calendar-cursor-to-date)) @@ -14952,7 +14952,7 @@ org-timestamp-change (org-get-heading t t))))))))) ;; Try to recenter the calendar window, if any. (when (and org-calendar-follow-timestamp-change - (get-buffer-window "*Calendar*" t) + (get-buffer-window calendar-buffer-name t) (memq timestamp? '(day month year))) (org-recenter-calendar (time-to-days time)))))) @@ -14995,7 +14995,7 @@ org-modify-ts-extra (defun org-recenter-calendar (d) "If the calendar is visible, recenter it to date D." - (let ((cwin (get-buffer-window "*Calendar*" t))) + (let ((cwin (get-buffer-window calendar-buffer-name t))) (when cwin (let ((calendar-move-hook nil)) (with-selected-window cwin @@ -15022,7 +15022,7 @@ org-goto-calendar (defun org-get-date-from-calendar () "Return a list (month day year) of date at point in calendar." - (with-current-buffer "*Calendar*" + (with-current-buffer calendar-buffer-name (save-match-data (calendar-cursor-to-date)))) diff --git a/test/lisp/calendar/cal-julian-tests.el b/test/lisp/calendar/cal-julian-tests.el index e0d74e8a6cd..8db21f7b1a8 100644 --- a/test/lisp/calendar/cal-julian-tests.el +++ b/test/lisp/calendar/cal-julian-tests.el @@ -47,7 +47,7 @@ with-cal-julian-test (progn (calendar) ,@body) - (kill-buffer "*Calendar*")))) + (kill-buffer calendar-buffer-name)))) (ert-deftest cal-julian-test-goto-date () (with-cal-julian-test -- 2.38.2