all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [BUG] org-agenda passes current-prefix-arg to commands instead of arg [9.5.3 (9.5.3-g69c588 @ /Users/stas/.emacs.d/straight/build/org/)]
@ 2022-07-03 12:56 stasvlasov
  2022-07-07 10:05 ` Ihor Radchenko
  0 siblings, 1 reply; 2+ messages in thread
From: stasvlasov @ 2022-07-03 12:56 UTC (permalink / raw)
  To: emacs-orgmode


`org-agenda' function passes `current-prefix-arg' to its commands (e.g., `org-agenda-tags') instead of `arg'

This might create unexpected behaviour if one uses `org-agenda' function inside another interactive function that accepts on universal prefix. For example if I define `my/agenda-done-todos' it wont show any DONE todos if I call it with prefix to restrict it to current buffer because `org-agenda-tags' will be limited only to active todos by `current-prefix-arg' and this will always produce empty set:

(add-to-list 'org-agenda-custom-commands
             '("d" "DONE todos"
               tags "TODO=\"DONE\""))

(defun my/agenda-done-todos (arg)
  "Show agenda for keyword 'd' (DONE todos). With ARG prefix restrict to current buffer."
  (interactive "P")
  (if arg
      (org-agenda nil "d" 'buffer)
    (org-agenda nil "d")))

Emacs  : GNU Emacs 28.1 (build 1, x86_64-apple-darwin19.6.0, NS appkit-1894.60 Version 10.15.7 (Build 19H1519))
 of 2022-05-07
Package: Org mode version 9.5.3 (9.5.3-g69c588 @ /Users/stas/.emacs.d/straight/build/org/)


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

* Re: [BUG] org-agenda passes current-prefix-arg to commands instead of arg [9.5.3 (9.5.3-g69c588 @ /Users/stas/.emacs.d/straight/build/org/)]
  2022-07-03 12:56 [BUG] org-agenda passes current-prefix-arg to commands instead of arg [9.5.3 (9.5.3-g69c588 @ /Users/stas/.emacs.d/straight/build/org/)] stasvlasov
@ 2022-07-07 10:05 ` Ihor Radchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2022-07-07 10:05 UTC (permalink / raw)
  To: stasvlasov; +Cc: emacs-orgmode

stasvlasov@disroot.org writes:

> `org-agenda' function passes `current-prefix-arg' to its commands (e.g., `org-agenda-tags') instead of `arg'
>
> This might create unexpected behaviour if one uses `org-agenda' function inside another interactive function that accepts on universal prefix. For example if I define `my/agenda-done-todos' it wont show any DONE todos if I call it with prefix to restrict it to current buffer because `org-agenda-tags' will be limited only to active todos by `current-prefix-arg' and this will always produce empty set:

Thanks for reporting!
Your examples makes sense and I do not see any reason why
`current-prefix-arg' should be used instead of ARG. The present usage
appears to be introduced in the initial agenda implementation back 14
years ago.

Fixed on main via db12a497d.

Best,
Ihor



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

end of thread, other threads:[~2022-07-07 10:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-03 12:56 [BUG] org-agenda passes current-prefix-arg to commands instead of arg [9.5.3 (9.5.3-g69c588 @ /Users/stas/.emacs.d/straight/build/org/)] stasvlasov
2022-07-07 10:05 ` Ihor Radchenko

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.