0

I am a elisp noob and need some help for a custom agenda in org-mode. I need an agenda view that filters the todo entries based on a scheduled or deadline timestamp. I want to see all the todos due in the next 60s. I have working code with hardcoded timestamp, but I need the timestamp to be dynamic (based on the current date/time).

This code is working (fixed date/times):

(setq org-agenda-custom-commands
      '(("P" "Notify List"
      ((org-ql-block
        '(and (not (done))
          (planning
           :from
           "2021-02-02 11:00"
           :to
           "2021-02-02 14:00"
           )
          )
        ))
      )
    ))

But this code seems to just ignore the from and to keywords and displays all tasks with a scheduled or deadline date:

(setq org-agenda-custom-commands
      '(("P" "Notify List"
      ((org-ql-block
        '(and (not (done))
          (planning
           :from
           (format-time-string "%Y-%m-%d %H:%M")
           :to
           (format-time-string "%Y-%m-%d %H:%M" (time-add (current-time) (seconds-to-time 60)))
           )
          )
        ))
      )
    ))

Can someone help me out why the functions are not working. I tried with many different functions, that create a timestamp, used the timestamp, converted it to string. Nothing worked. Thanks in advance. Cheers

Drew
  • 29,895
  • 7
  • 74
  • 104
StefanW
  • 1
  • 1
  • Thanks for your answer, unfortunately the problem under the link does not help me :( – StefanW Feb 02 '21 at 19:03
  • Change the quote `'` to a backquote \` and precede every `(format ...)` with a comma. Does that help? – NickD Feb 02 '21 at 19:19
  • ... and read the *answer* in the link. – NickD Feb 02 '21 at 19:50
  • Nick, thanks a lot. Your suggestions did the job. In hindsight, your link explained that as well obviously. Sorry, my knowledge of elisp is to limited to understand how that is working. I will learn more elisp now. Thanks a lot again :) – StefanW Feb 02 '21 at 20:39

1 Answers1

0

NickD presented the solution. Here is the final code, that is working for me. Thanks a lot NickD :)

(setq org-agenda-custom-commands
      '(("P" "Notify List"
      ((org-ql-block
        `(and (not (done))
          (planning
           :from
           ,(format-time-string "%Y-%m-%d %H:%M")
           :to
           ,(format-time-string "%Y-%m-%d %H:%M" (org-time-add (org-current-time) (seconds-to-time 600)))
           )
          )
        ))
      )
    ))
StefanW
  • 1
  • 1