Subject: bug#61546: closed (Re: bug#61546: [PATCH] Fix some org functionality breaking upon changing `calendar-buffer')

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 02 May 2023 18:04:02 +0000

Your bug report

#61546: [PATCH] Fix some org functionality breaking upon changing `calendar-buffer'

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
61546: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61546
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#61546: [PATCH] Fix some org functionality breaking upon changing `calendar-buffer'
From: Eli Zaretskii <[email-masked]>
To: Ihor Radchenko <[email-masked]>
Cc: [email-masked], [email-masked], [email-masked]
Date: Tue, 02 May 2023 21:04:13 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> Cc: [email-masked], Stefan Kangas <[email-masked]>
> From: Ihor Radchenko <[email-masked]>
> Date: Tue, 02 May 2023 11:38:40 +0000
> 
> Thuna <[email-masked]> writes:
> 
> > Some code in org seems to break when calendar-buffer is modified, as
> > they rely on it being its default value, "*Calendar*".  The attached
> > patch fixes that.  I haven't tested it, however, it should work fine.
> > The `require's all seem correct as well.
> 
> I now applied an equivalent patch onto main in Org.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=9ea50ca21
> 
> Stefan, please note that part of the patch is for Emacs:

I'm not Stefan, but I've installed this part on the emacs-29 branch,
and I'm therefore closing the bug.

Subject: [PATCH] Fix some org functionality breaking upon changing `calendar-buffer'
From: Thuna <[email-masked]>
To: [email-masked]
Date: Thu, 16 Feb 2023 07:01:23 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Some code in org seems to break when calendar-buffer is modified, as
they rely on it being its default value, "*Calendar*".  The attached
patch fixes that.  I haven't tested it, however, it should work fine.
The `require's all seem correct as well.

>From 1facad66a10211470cc7d785dfd4418217553b57 Mon Sep 17 00:00:00 2001
From: Thuna <[email-masked]>
Date: Tue, 14 Feb 2023 19:52:37 +0100
Subject: [PATCH 1/3] Use the calendar-buffer variable

* lisp/org/org.el (org-read-date org-eval-in-calendar
org-timestamp-change org-modify-ts-extra org-goto-calendar):
lisp/org/org-agenda.el (org-agenda-clock-goto):
test/lisp/calendar/cal-julian-tests.el (with-cal-julian-test): Use the
variable `calendar-buffer' instead of its default value, the literal
string `"*Calendar*"'.
---
 lisp/org/org-agenda.el                 |  2 +-
 lisp/org/org.el                        | 12 ++++++------
 test/lisp/calendar/cal-julian-tests.el |  2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el
index 3db33c4d63e..63757cf5e1c 100644
--- a/lisp/org/org-agenda.el
+++ b/lisp/org/org-agenda.el
@@ -10555,7 +10555,7 @@ org-agenda-clock-goto
 (defun org-agenda-diary-entry-in-org-file ()
   "Make a diary entry in the file `org-agenda-diary-file'."
   (let (d1 d2 char (text "") dp1 dp2)
-    (if (equal (buffer-name) "*Calendar*")
+    (if (equal (buffer-name) calendar-buffer)
 	(setq d1 (calendar-cursor-to-date t)
 	      d2 (car calendar-mark-ring))
       (setq dp1 (get-text-property (line-beginning-position) 'day))
diff --git a/lisp/org/org.el b/lisp/org/org.el
index 9a4f7803cf4..f602bfb8c8a 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 '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)
 	      (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 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 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 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
     (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..4207d1ee285 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))))
 
 (ert-deftest cal-julian-test-goto-date ()
   (with-cal-julian-test
-- 
2.38.2