emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Fix timestamp agenda setting global agenda name [9.4.6]
@ 2021-06-30 19:53 Ingo Lohmar
  2021-06-30 20:04 ` Nicolas Goaziou
  0 siblings, 1 reply; 2+ messages in thread
From: Ingo Lohmar @ 2021-06-30 19:53 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 758 bytes --]


Dear All,

a few weeks ago, I reported the original bug with a minimal complete
example in

    https://lists.gnu.org/archive/html/emacs-orgmode/2021-05/msg00757.html

My first patch attempt was wrongly based on the master branch, see

    https://lists.gnu.org/archive/html/emacs-orgmode/2021-06/msg00378.html

Also, I probably messed up the subject, and replying to my first mail
did not work as intended, please accept my apologies for any confusion
caused by this.

Below, I attach a clean patch against the 'maint' branch.  Two tests
fail, but the same tests fail on maint w/o my commit.  'make compile'
does not complain.

I have a copyright assignment for Emacs on file with the FSF.

Please let me know of anything else I can do to get the fix in.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-timestamp-agenda-setting-global-agenda-name.patch --]
[-- Type: text/x-diff, Size: 2609 bytes --]

From 167bda641e70989a5b679b89f3024f47ec68244c Mon Sep 17 00:00:00 2001
From: Ingo Lohmar <ingo.lohmar@posteo.net>
Date: Sat, 19 Jun 2021 17:04:56 +0200
Subject: [PATCH] Fix timestamp agenda setting global agenda name

* lisp/org.el (org-follow-timestamp-link): Do not set global agenda name

The tmp value for the agenda buffer name is used in `org-agenda-list'
to set `org-agenda-buffer-name'.  Wrap the call in a let-binding for
this symbol (like the agenda dispatcher does), since otherwise it
inadvertently sets the global value.
---
 lisp/org.el | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index a8b584ee4..467485b2c 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9098,24 +9098,26 @@ or to another Org file, automatically push the old position onto the ring."
 (defvar org-agenda-start-on-weekday)
 (defun org-follow-timestamp-link ()
   "Open an agenda view for the time-stamp date/range at point."
-  (cond
-   ((org-at-date-range-p t)
-    (let ((org-agenda-start-on-weekday)
-	  (t1 (match-string 1))
-	  (t2 (match-string 2)) tt1 tt2)
-      (setq tt1 (time-to-days (org-time-string-to-time t1))
-	    tt2 (time-to-days (org-time-string-to-time t2)))
+  ;; Avoid changing the global value.
+  (let ((org-agenda-buffer-name org-agenda-buffer-name))
+    (cond
+     ((org-at-date-range-p t)
+      (let ((org-agenda-start-on-weekday)
+	    (t1 (match-string 1))
+	    (t2 (match-string 2)) tt1 tt2)
+	(setq tt1 (time-to-days (org-time-string-to-time t1))
+	      tt2 (time-to-days (org-time-string-to-time t2)))
+	(let ((org-agenda-buffer-tmp-name
+	       (format "*Org Agenda(a:%s)"
+		       (concat (substring t1 0 10) "--" (substring t2 0 10)))))
+	  (org-agenda-list nil tt1 (1+ (- tt2 tt1))))))
+     ((org-at-timestamp-p 'lax)
       (let ((org-agenda-buffer-tmp-name
-	     (format "*Org Agenda(a:%s)"
-		     (concat (substring t1 0 10) "--" (substring t2 0 10)))))
-	(org-agenda-list nil tt1 (1+ (- tt2 tt1))))))
-   ((org-at-timestamp-p 'lax)
-    (let ((org-agenda-buffer-tmp-name
-	   (format "*Org Agenda(a:%s)" (substring (match-string 1) 0 10))))
-      (org-agenda-list nil (time-to-days (org-time-string-to-time
-					  (substring (match-string 1) 0 10)))
-		       1)))
-   (t (error "This should not happen"))))
+	     (format "*Org Agenda(a:%s)" (substring (match-string 1) 0 10))))
+	(org-agenda-list nil (time-to-days (org-time-string-to-time
+					    (substring (match-string 1) 0 10)))
+			 1)))
+     (t (error "This should not happen")))))
 
 
 ;;; Following file links
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix timestamp agenda setting global agenda name [9.4.6]
  2021-06-30 19:53 [PATCH] Fix timestamp agenda setting global agenda name [9.4.6] Ingo Lohmar
@ 2021-06-30 20:04 ` Nicolas Goaziou
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2021-06-30 20:04 UTC (permalink / raw)
  To: Ingo Lohmar; +Cc: emacs-orgmode

Hello,

Ingo Lohmar <ingo.lohmar@posteo.net> writes:

> Subject: [PATCH] Fix timestamp agenda setting global agenda name
>
> * lisp/org.el (org-follow-timestamp-link): Do not set global agenda name
>
> The tmp value for the agenda buffer name is used in `org-agenda-list'
> to set `org-agenda-buffer-name'.  Wrap the call in a let-binding for
> this symbol (like the agenda dispatcher does), since otherwise it
> inadvertently sets the global value.

Applied.

Thank you!

Regards,
-- 
Nicolas Goaziou


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-30 20:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-30 19:53 [PATCH] Fix timestamp agenda setting global agenda name [9.4.6] Ingo Lohmar
2021-06-30 20:04 ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).