2
votes

Org-mode allow to define custom commands by customizing org-agenda-custom-commands. Doing something like this:

(setq org-agenda-custom-commands
  '(("pb" "Bugs "
      (
       (todo "KNOWNCAUSE")
       (todo "BUG")
       (todo "REPORT")
      )
    ((org-agenda-files (list projects-dir))))

will allow me to press C-c a to call the agenda dispatcher and then if i press pb it will filter my todos by folder (project-dirs) and by states.

Is there an elisp function that calls that (a specific) custom command defined in org-agenda-custom-commands directly?

Rephrasing: I would like an elisp function that if called shows my filtered todos, just like pressing C-c a p b now does.

1
Your question is unclear. Are you asking for a method of calling a particular agenda view at start-up? In which case this: stackoverflow.com/questions/2010539/… answer may help. Perhaps you could rephrase your question with the outcome you are looking for. - andygavin
Thank you for you answer! I'm sorry if I was unclear, I've now expanded my question. I do not seek to open the agenda view at startup like is described in the answer you linked (my end goal is to open a specific filtered todos list at startup, but this is beyond the point of the question). - CarloDePieri

1 Answers

3
votes

I think you are asking for a way to call through the dispatcher from a function so you can reuse your configured dispatcher. Try:

(org-agenda nil "pb")

If you are looking for function to add to a hook or initialize you can wrap this up using a lambda expression. So for example you might have your inital-buffer as this view:

(setq initial-buffer-choice (lambda ()
  (org-agenda nil "pb")
  (get-buffer "*Org Agenda*")))