In org-mode, M-x org-agenda a will display a built-in agenda view labeled "Agenda for current week or day". How can I exclude a tag from this view?

Parenthetical clarification

I know how to filter a tag out of this view after it is displayed, but I would like to add something to my configuration to exclude the tag by default.

I know how to exclude a tag from a custom agenda view, but I would like to exclude a tag from the built-in agenda view labeled "Agenda for current week or day".


As Yasushi Shoji mentioned, the correct approach is to let-bind org-agenda-tag-filter-preset. To advise just the one pre-built agenda view, you'll want to use advice around the function org-agenda-list, which builds just that particular view. Try this:

(defun my/org-agenda-list-exclude-tags-advice (orig-fn &rest args)
  "Exclude selected tags from `org-agenda-list'.
Intended as :around advice for `org-agenda-list'."
  (let ((org-agenda-tag-filter-preset '("-foo")))
    (apply orig-fn args)))

(advice-add #'org-agenda-list :around #'my/org-agenda-list-exclude-tags-advice)
| improve this answer | |
  • Shouldn't it be (apply org-fn args) instead of funcall? – grepcake May 2 at 7:23
  • @grepcake: Yes, I believe you're right. Fixing it now. – Aaron Harris May 2 at 14:53

I you don't want to see :foo:, this should exclude it:

(setq org-agenda-tag-filter-preset '("-foo"))

However, the doc string says:

This variable should not be set directly, but agenda custom commands can bind it in the options section.

So, let bind the variable before calling org-agenda by defining your own wrapper function:

(defun yashi/org-agenda (&optional arg)
  (interactive "P")
  (let ((org-agenda-tag-filter-preset '("-foo")))
   (org-agenda arg "a")))

And bind it to, say, F1

(bind-key "<f1>" 'yashi/org-agenda)
| improve this answer | |
  • What does "bind it in the options section" actually mean? – RichieHH Feb 3 at 20:32

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.