* Bug: org-agenda-buffer-name wrongly persists [9.4.4 (release_9.4.4 @ /usr/local/share/emacs/28.0.50/lisp/org/)]
@ 2021-05-15 11:40 Ingo Lohmar
2021-06-19 15:22 ` [PATCH] " Ingo Lohmar
0 siblings, 1 reply; 2+ messages in thread
From: Ingo Lohmar @ 2021-05-15 11:40 UTC (permalink / raw)
To: emacs-orgmode
Remember to cover the basics, that is, what you expected to happen and
what in fact did happen. You don't know how to make a good report? See
https://orgmode.org/manual/Feedback.html#Feedback
Your bug report will be posted to the Org mailing list.
------------------------------------------------------------------------
The global variable org-agenda-buffer-name, once set, wrongly (IMO)
affects all future agenda buffer names for composite commands.
Minimal complete example (in emacs -q):
================================================================================
Evaluate
(setq org-agenda-custom-commands
'(("z" "Std Agenda"
((tags "select"
((org-agenda-overriding-header "*select*ed")))
(agenda "" ((org-agenda-span 2)))))))
(("z" "Std Agenda" ((tags "select" ...) (agenda "" ...))))
(org-agenda nil "z")
and get a custom agenda with the default buffer name "*Org Agenda*"
(OK).
Create a buffer "test.org" and switch it to `org-mode', insert a
timestamp (C-c .). Now follow the timestamp link (C-c C-o), and get an
agenda with buffer name "*Org Agenda(a:2021-05-15)" (OK).
Now re-do
(org-agenda nil "z")
which has the same buffer name including the date (BUG).
================================================================================
I do not pretend to understand how the global variable
org-agenda-buffer-name is supposed to work (not even mentioning the
-sticky- functionality here). What I understand is the following:
The org-agenda dispatcher let-binds o-a-buffer-name to the global value.
"Simple" agenda commands (like a todo list) called from the dispatcher
set this let-bound o-a-buffer-name, so they use the correct default
value.
"Composite" custom commands called via the dispatcher do not set the
let-bound value, so they use the original let-bound value (the global
value at the start of org-agenda).
`org-follow-timestamp-link' calls the `org-agenda-list' command directly
(not via the dispatcher), hence sets the global (not a local let-bound)
value of o-a-buffer-name.
I have little constructive advice to offer regarding a solution. It
seems to me that the global variable o-a-buffer-name is only harmful and
I would try to get rid of it, but I guess it is necessary for sticky
agendas (not using them).
Emacs : GNU Emacs 28.0.50 (build 6, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0)
of 2021-05-01
Package: Org mode version 9.4.4 (release_9.4.4 @ /usr/local/share/emacs/28.0.50/lisp/org/)
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] Re: Bug: org-agenda-buffer-name wrongly persists [9.4.4 (release_9.4.4 @ /usr/local/share/emacs/28.0.50/lisp/org/)]
2021-05-15 11:40 Bug: org-agenda-buffer-name wrongly persists [9.4.4 (release_9.4.4 @ /usr/local/share/emacs/28.0.50/lisp/org/)] Ingo Lohmar
@ 2021-06-19 15:22 ` Ingo Lohmar
0 siblings, 0 replies; 2+ messages in thread
From: Ingo Lohmar @ 2021-06-19 15:22 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 277 bytes --]
Here's a local-tested fix to the bug described previously. The attached
patch does not change anything about the overall handling of the agenda
buffer names, it only fixes org-follow-timestamp-link to introduce a
let-binding similar to what the standard org-dispatcher does.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org.el-org-follow-timestamp-link-Do-not-set-global-a.patch --]
[-- Type: text/x-diff, Size: 2554 bytes --]
From 2c0166449de2f4252435ecfea8a2d1287eafc04b 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] 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 1bd9e02eb..4fd8b6fa6 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9165,24 +9165,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
end of thread, other threads:[~2021-06-19 15:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-15 11:40 Bug: org-agenda-buffer-name wrongly persists [9.4.4 (release_9.4.4 @ /usr/local/share/emacs/28.0.50/lisp/org/)] Ingo Lohmar
2021-06-19 15:22 ` [PATCH] " Ingo Lohmar
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).