0

I would like to start an org-mode agenda with a custom tag search (rather than starting the agenda and then doing the search).

The overall goal is to make a work and a personal agenda. I can make the custom search commands easily enough:

(setq org-agenda-custom-commands
      '(("p" tags "-work")
        ("w" tags "+work")))

Normally I get to an agenda with a function like:

(defun just-agenda()
  (org-agenda-list)
  (delete-other-windows))

Is there a way to pass a custom search to the agenda when I call org-agenda-list? I've seen a bunch of things that seem close in the docs but it feels like I'm missing something for how to do it.

  • 1
    Yes, type C-h f (aka M-x describe-function) and look at the arguments to org-agenda-list .... Then, try setting up a test using the arguments ... In addition, you can let-bind certain values potentially used by org-agenda-list ... To see what makes it tick, type M-x find-function .... Keep in mind that that there are also functions used for searches such as org-tags-view and org-search-view. – lawlist Jul 18 '19 at 19:52
  • 1
    You can also use your custom searches with (org-agenda nil "p"). – Hubisan Jul 19 '19 at 20:17
  • Thanks! (org-agenda nil "p") did exactly what I wanted. – jcv Jul 24 '19 at 15:33
  • The describe-function tip was also useful (although I should have thought to do that one myself). – jcv Jul 24 '19 at 15:33
1

You can use your custom searches programmatically with:

(org-agenda nil "p")

In this example p is the key of your custom command you want to invoke.

The documentation for the function is unfortunately missing any hint about its ORG-KEYS parameter:

(org-agenda &optional ARG ORG-KEYS RESTRICTION)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.