emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org--batch-store-agenda-views: Fix treatment of lambda functions
@ 2023-02-07  1:05 Aaron L. Zeng
  2023-02-07 11:16 ` Ihor Radchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Aaron L. Zeng @ 2023-02-07  1:05 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Aaron L. Zeng

`org-agenda-custom-commands' entries may specify a custom function
instead of a symbol like `tags-todo'.  `org--batch-store-agenda-views'
behaved differently from `org-agenda' when that custom function was
defined as a lambda rather than a symbol, incorrectly treating the
lambda form as a list of agenda commands.

This patch makes `org--batch-store-agenda-views' use the same test as
`org-agenda' does to determine whether the command is a series.
---
 lisp/org-agenda.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 1d1f2271b..1aab64820 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -3525,7 +3525,8 @@ This ensures the export commands can easily use it."
   (let ((cmds (org-agenda-normalize-custom-commands org-agenda-custom-commands))
         (pop-up-frames nil)
         (dir default-directory)
-        cmd thiscmdkey thiscmdcmd match files opts cmd-or-set bufname)
+        cmd thiscmdkey thiscmdcmd match files opts cmd-or-set
+        seriesp bufname)
     (save-window-excursion
       (while cmds
 	(setq cmd (pop cmds)
@@ -3538,8 +3539,9 @@ This ensures the export commands can easily use it."
 			      (format "*Org Agenda(%s)*" thiscmdkey))
 			org-agenda-buffer-name)
 	      cmd-or-set (nth 2 cmd)
-	      opts (nth (if (listp cmd-or-set) 3 4) cmd)
-	      files (nth (if (listp cmd-or-set) 4 5) cmd))
+	      seriesp (not (or (symbolp cmd-or-set) (functionp cmd-or-set)))
+	      opts (nth (if seriesp 3 4) cmd)
+	      files (nth (if seriesp 4 5) cmd))
 	(if (stringp files) (setq files (list files)))
 	(when files
 	  (let* ((opts (append org-agenda-exporter-settings opts))
-- 
2.38.1



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

* Re: [PATCH] org--batch-store-agenda-views: Fix treatment of lambda functions
  2023-02-07  1:05 [PATCH] org--batch-store-agenda-views: Fix treatment of lambda functions Aaron L. Zeng
@ 2023-02-07 11:16 ` Ihor Radchenko
  2023-02-07 17:47   ` Aaron L. Zeng
  0 siblings, 1 reply; 7+ messages in thread
From: Ihor Radchenko @ 2023-02-07 11:16 UTC (permalink / raw)
  To: Aaron L. Zeng; +Cc: emacs-orgmode

"Aaron L. Zeng" <me@bcc32.com> writes:

> `org-agenda-custom-commands' entries may specify a custom function
> instead of a symbol like `tags-todo'.  `org--batch-store-agenda-views'
> behaved differently from `org-agenda' when that custom function was
> defined as a lambda rather than a symbol, incorrectly treating the
> lambda form as a list of agenda commands.

Thanks for the patch!

> -	      opts (nth (if (listp cmd-or-set) 3 4) cmd)
> -	      files (nth (if (listp cmd-or-set) 4 5) cmd))
> +	      seriesp (not (or (symbolp cmd-or-set) (functionp cmd-or-set)))
> +	      opts (nth (if seriesp 3 4) cmd)
> +	      files (nth (if seriesp 4 5) cmd))

Could you add a brief comment explaining why "3", "4", and "5"?
Something like

;; series:     (0:key 1:desc 2:(cmd1 cmd2 ...) 3:general-settings 4:files)
;; non-series: (0:key 1:desc 2:type 3:match    4:settings         5:files)

Also, please add a changelog entry, as described in
https://orgmode.org/worg/org-contribute.html#commit-messages

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

* [PATCH] org--batch-store-agenda-views: Fix treatment of lambda functions
  2023-02-07 11:16 ` Ihor Radchenko
@ 2023-02-07 17:47   ` Aaron L. Zeng
  2023-02-07 17:47     ` Aaron Zeng
  2023-02-08 10:10     ` Ihor Radchenko
  0 siblings, 2 replies; 7+ messages in thread
From: Aaron L. Zeng @ 2023-02-07 17:47 UTC (permalink / raw)
  To: emacs-orgmode, yantar92; +Cc: Aaron L. Zeng

* org-agenda.el (org--batch-store-agenda-views): Fix treatment of
lambda functions used as custom agenda commands.
`org-agenda-custom-commands' entries may specify a custom function
instead of a symbol like `tags-todo'.  `org--batch-store-agenda-views'
behaved differently from `org-agenda' when that custom function was
defined as a lambda rather than a symbol, incorrectly treating the
lambda form as a list of agenda commands.  Instead, use the same test
as `org-agenda' does to determine whether the command is a series.
---
 lisp/org-agenda.el | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 1d1f2271b..49f93c338 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -3525,10 +3525,13 @@ This ensures the export commands can easily use it."
   (let ((cmds (org-agenda-normalize-custom-commands org-agenda-custom-commands))
         (pop-up-frames nil)
         (dir default-directory)
-        cmd thiscmdkey thiscmdcmd match files opts cmd-or-set bufname)
+        cmd thiscmdkey thiscmdcmd match files opts cmd-or-set
+        seriesp bufname)
     (save-window-excursion
       (while cmds
 	(setq cmd (pop cmds)
+              ;; series:     (0:key 1:desc 2:(cmd1 cmd2 ...) 3:general-settings 4:files)
+              ;; non-series: (0:key 1:desc 2:type 3:match    4:settings         5:files)
 	      thiscmdkey (car cmd)
 	      thiscmdcmd (cdr cmd)
 	      match (nth 2 thiscmdcmd)
@@ -3538,8 +3541,9 @@ This ensures the export commands can easily use it."
 			      (format "*Org Agenda(%s)*" thiscmdkey))
 			org-agenda-buffer-name)
 	      cmd-or-set (nth 2 cmd)
-	      opts (nth (if (listp cmd-or-set) 3 4) cmd)
-	      files (nth (if (listp cmd-or-set) 4 5) cmd))
+	      seriesp (not (or (symbolp cmd-or-set) (functionp cmd-or-set)))
+	      opts (nth (if seriesp 3 4) cmd)
+	      files (nth (if seriesp 4 5) cmd))
 	(if (stringp files) (setq files (list files)))
 	(when files
 	  (let* ((opts (append org-agenda-exporter-settings opts))
-- 
2.38.1



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

* Re: [PATCH] org--batch-store-agenda-views: Fix treatment of lambda functions
  2023-02-07 17:47   ` Aaron L. Zeng
@ 2023-02-07 17:47     ` Aaron Zeng
  2023-02-08 10:10     ` Ihor Radchenko
  1 sibling, 0 replies; 7+ messages in thread
From: Aaron Zeng @ 2023-02-07 17:47 UTC (permalink / raw)
  To: emacs-orgmode, yantar92

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

Thanks Ihor, I sent a new patch with your comment included verbatim, and
also added a ChangeLog entry.

On Tue, Feb 7, 2023 at 12:47 PM Aaron L. Zeng <me@bcc32.com> wrote:

> * org-agenda.el (org--batch-store-agenda-views): Fix treatment of
> lambda functions used as custom agenda commands.
> `org-agenda-custom-commands' entries may specify a custom function
> instead of a symbol like `tags-todo'.  `org--batch-store-agenda-views'
> behaved differently from `org-agenda' when that custom function was
> defined as a lambda rather than a symbol, incorrectly treating the
> lambda form as a list of agenda commands.  Instead, use the same test
> as `org-agenda' does to determine whether the command is a series.
> ---
>  lisp/org-agenda.el | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
> index 1d1f2271b..49f93c338 100644
> --- a/lisp/org-agenda.el
> +++ b/lisp/org-agenda.el
> @@ -3525,10 +3525,13 @@ This ensures the export commands can easily use
> it."
>    (let ((cmds (org-agenda-normalize-custom-commands
> org-agenda-custom-commands))
>          (pop-up-frames nil)
>          (dir default-directory)
> -        cmd thiscmdkey thiscmdcmd match files opts cmd-or-set bufname)
> +        cmd thiscmdkey thiscmdcmd match files opts cmd-or-set
> +        seriesp bufname)
>      (save-window-excursion
>        (while cmds
>         (setq cmd (pop cmds)
> +              ;; series:     (0:key 1:desc 2:(cmd1 cmd2 ...)
> 3:general-settings 4:files)
> +              ;; non-series: (0:key 1:desc 2:type 3:match    4:settings
>        5:files)
>               thiscmdkey (car cmd)
>               thiscmdcmd (cdr cmd)
>               match (nth 2 thiscmdcmd)
> @@ -3538,8 +3541,9 @@ This ensures the export commands can easily use it."
>                               (format "*Org Agenda(%s)*" thiscmdkey))
>                         org-agenda-buffer-name)
>               cmd-or-set (nth 2 cmd)
> -             opts (nth (if (listp cmd-or-set) 3 4) cmd)
> -             files (nth (if (listp cmd-or-set) 4 5) cmd))
> +             seriesp (not (or (symbolp cmd-or-set) (functionp
> cmd-or-set)))
> +             opts (nth (if seriesp 3 4) cmd)
> +             files (nth (if seriesp 4 5) cmd))
>         (if (stringp files) (setq files (list files)))
>         (when files
>           (let* ((opts (append org-agenda-exporter-settings opts))
> --
> 2.38.1
>
>

[-- Attachment #2: Type: text/html, Size: 3055 bytes --]

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

* Re: [PATCH] org--batch-store-agenda-views: Fix treatment of lambda functions
  2023-02-07 17:47   ` Aaron L. Zeng
  2023-02-07 17:47     ` Aaron Zeng
@ 2023-02-08 10:10     ` Ihor Radchenko
  2023-02-08 15:46       ` Aaron Zeng
  1 sibling, 1 reply; 7+ messages in thread
From: Ihor Radchenko @ 2023-02-08 10:10 UTC (permalink / raw)
  To: Aaron L. Zeng; +Cc: emacs-orgmode

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

"Aaron L. Zeng" <me@bcc32.com> writes:

> * org-agenda.el (org--batch-store-agenda-views): Fix treatment of
> lambda functions used as custom agenda commands.
> `org-agenda-custom-commands' entries may specify a custom function
> instead of a symbol like `tags-todo'.  `org--batch-store-agenda-views'
> behaved differently from `org-agenda' when that custom function was
> defined as a lambda rather than a symbol, incorrectly treating the
> lambda form as a list of agenda commands.  Instead, use the same test
> as `org-agenda' does to determine whether the command is a series.

Thanks for the updated patch!
I am attaching amended version with the comment placed closer to where
the custom command list is being used.
I also added TINYCHANGE cookie because you are not listed as a
contributor with FSF copyright assignment.

Let me know if you have any objections.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: v2-0001-org-batch-store-agenda-views-Fix-treatment-of-lam.patch --]
[-- Type: text/x-patch, Size: 2343 bytes --]

From 4f4693a5dd85e09737ecb27a68b04c7f8af014ad Mon Sep 17 00:00:00 2001
Message-Id: <4f4693a5dd85e09737ecb27a68b04c7f8af014ad.1675850882.git.yantar92@posteo.net>
From: "Aaron L. Zeng" <me@bcc32.com>
Date: Tue, 7 Feb 2023 12:47:03 -0500
Subject: [PATCH v2] org--batch-store-agenda-views: Fix treatment of lambda
 functions

* org-agenda.el (org--batch-store-agenda-views): Fix treatment of
lambda functions used as custom agenda commands.
`org-agenda-custom-commands' entries may specify a custom function
instead of a symbol like `tags-todo'.  `org--batch-store-agenda-views'
behaved differently from `org-agenda' when that custom function was
defined as a lambda rather than a symbol, incorrectly treating the
lambda form as a list of agenda commands.  Instead, use the same test
as `org-agenda' does to determine whether the command is a series.

TINYCHANGE
---
 lisp/org-agenda.el | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 1d1f2271b..127503af0 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -3525,7 +3525,8 @@ (defun org--batch-store-agenda-views (vars vals)
   (let ((cmds (org-agenda-normalize-custom-commands org-agenda-custom-commands))
         (pop-up-frames nil)
         (dir default-directory)
-        cmd thiscmdkey thiscmdcmd match files opts cmd-or-set bufname)
+        cmd thiscmdkey thiscmdcmd match files opts cmd-or-set
+        seriesp bufname)
     (save-window-excursion
       (while cmds
 	(setq cmd (pop cmds)
@@ -3537,9 +3538,12 @@ (defun org--batch-store-agenda-views (vars vals)
 				   (format "*Org Agenda(%s:%s)*" thiscmdkey match))
 			      (format "*Org Agenda(%s)*" thiscmdkey))
 			org-agenda-buffer-name)
+              ;; series:     (0:key 1:desc 2:(cmd1 cmd2 ...) 3:general-settings 4:files)
+              ;; non-series: (0:key 1:desc 2:type 3:match    4:settings         5:files)
 	      cmd-or-set (nth 2 cmd)
-	      opts (nth (if (listp cmd-or-set) 3 4) cmd)
-	      files (nth (if (listp cmd-or-set) 4 5) cmd))
+	      seriesp (not (or (symbolp cmd-or-set) (functionp cmd-or-set)))
+	      opts (nth (if seriesp 3 4) cmd)
+	      files (nth (if seriesp 4 5) cmd))
 	(if (stringp files) (setq files (list files)))
 	(when files
 	  (let* ((opts (append org-agenda-exporter-settings opts))
-- 
2.39.1


[-- Attachment #3: Type: text/plain, Size: 225 bytes --]



-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

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

* Re: [PATCH] org--batch-store-agenda-views: Fix treatment of lambda functions
  2023-02-08 10:10     ` Ihor Radchenko
@ 2023-02-08 15:46       ` Aaron Zeng
  2023-02-09 10:01         ` Ihor Radchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Aaron Zeng @ 2023-02-08 15:46 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

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

New patch looks good.  Thanks!

On Wed, Feb 8, 2023 at 05:09 Ihor Radchenko <yantar92@posteo.net> wrote:

> "Aaron L. Zeng" <me@bcc32.com> writes:
>
> > * org-agenda.el (org--batch-store-agenda-views): Fix treatment of
> > lambda functions used as custom agenda commands.
> > `org-agenda-custom-commands' entries may specify a custom function
> > instead of a symbol like `tags-todo'.  `org--batch-store-agenda-views'
> > behaved differently from `org-agenda' when that custom function was
> > defined as a lambda rather than a symbol, incorrectly treating the
> > lambda form as a list of agenda commands.  Instead, use the same test
> > as `org-agenda' does to determine whether the command is a series.
>
> Thanks for the updated patch!
> I am attaching amended version with the comment placed closer to where
> the custom command list is being used.
> I also added TINYCHANGE cookie because you are not listed as a
> contributor with FSF copyright assignment.
>
> Let me know if you have any objections.
>
>
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>
>

[-- Attachment #2: Type: text/html, Size: 1963 bytes --]

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

* Re: [PATCH] org--batch-store-agenda-views: Fix treatment of lambda functions
  2023-02-08 15:46       ` Aaron Zeng
@ 2023-02-09 10:01         ` Ihor Radchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Ihor Radchenko @ 2023-02-09 10:01 UTC (permalink / raw)
  To: Aaron Zeng; +Cc: emacs-orgmode

Aaron Zeng <me@bcc32.com> writes:

> New patch looks good.  Thanks!

Applied, onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=739ccf6cb

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

end of thread, other threads:[~2023-02-09 10:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-07  1:05 [PATCH] org--batch-store-agenda-views: Fix treatment of lambda functions Aaron L. Zeng
2023-02-07 11:16 ` Ihor Radchenko
2023-02-07 17:47   ` Aaron L. Zeng
2023-02-07 17:47     ` Aaron Zeng
2023-02-08 10:10     ` Ihor Radchenko
2023-02-08 15:46       ` Aaron Zeng
2023-02-09 10:01         ` Ihor Radchenko

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).