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

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
    Commented Jul 18, 2019 at 19:52
  • 1
    You can also use your custom searches with (org-agenda nil "p").
    – Hubisan
    Commented Jul 19, 2019 at 20:17
  • Thanks! (org-agenda nil "p") did exactly what I wanted.
    – jcv
    Commented Jul 24, 2019 at 15:33
  • The describe-function tip was also useful (although I should have thought to do that one myself).
    – jcv
    Commented Jul 24, 2019 at 15:33

1 Answer 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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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