2

What is the preferred method of building (viewing) a custom agenda without modifying org-agenda-custom-commands? I am hoping that there is a function like org-agenda-list or org-todo-list that accepts a custom agenda command definition like those that would be added to `org-agenda-custom-commands.

Edit: Essentially just bypassing the org-agenda dispatcher / stored custom commands

An example taken from the org-mode manual:

(setq org-agenda-custom-commands
  '(("O" "Office block agenda"
     ((agenda "" ((org-agenda-ndays 1)))
      (tags-todo "+PRIORITY=\"A\"")
      (tags-todo "computer|office|phone")
      (tags "project+CATEGORY=\"elephants\"")
      (tags "review" ((org-agenda-files '("~/org/circuspeanuts.org"))))
      (todo "WAITING"))
     ((org-agenda-compact-blocks t)))

I think that org-agenda concatenates the results of individual sub-commands (like org-tags-view) internally. What I'm looking to do is skip the traditional org-agenda dispatcher and construct the agenda directly from an arbitrary definition like (from the above):

'((agenda "" ((org-agenda-ndays 1)))
  (tags-todo "+PRIORITY=\"A\"")
  (tags-todo "computer|office|phone")
  (tags "project+CATEGORY=\"elephants\"")
  (tags "review" ((org-agenda-files '("~/org/circuspeanuts.org"))))
  (todo "WAITING"))
 ((org-agenda-compact-blocks t)))

The key being that the definition is subject only to the constraints for org-agenda-custom-commands. It could simply be a tags agenda or a multipart one like that shown.

I originally thought that the user-defined function type that can be added to org-agenda-custom-commands might be the trick, but it looks like it's treated as a match predicate (it's not really mentioned in the documentation).

I'm asking because I'd like to view an agenda that has a dynamically-generated definition.

1

Depending on exactly what kind of agenda you're trying to build, org-tags-view may do what you want:

(org-tags-view &optional TODO-ONLY MATCH)

Show all headlines for all ‘org-agenda-files’ matching a TAGS criterion. The prefix arg TODO-ONLY limits the search to TODO entries.

This basically what a tags or tags-todo type entry in org-agenda-custom-commands does. The rest of the custom command definition is just variable/value pairs that are let bound when you call org-tags-view. For example,

(let ((org-agenda-overriding-header "Test"))
  (org-tags-view nil "+test"))

will find anything labeled test and set the title of the agenda to "Test". Any other org-agneda-* variable can be set similarly.

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.