6

How do I add a new ibuffer saved filter group which matches all files in org-agenda-files?

Something like:

(setq-default ibuffer-saved-filter-groups
              `(("Default"
                 ("Agenda" (or (mode . org-agenda-mode)
                               (mode . diary-mode)
                               (predicate . '(lambda ()
                                              (member (buffer-file-name)
                                                      (mapcar 'expand-file-name org-agenda-files))))))))

I'm guessing at the predicate bit as I can't find any examples or documentation. What should it really look like?

  • 2
    Don't quote your lambdas! – Stefan Oct 12 '14 at 2:36
4

The predicate is not a function, but a form to be eval'd in the context of each buffer

Something like this should work:

(defun my-org-agenda-filter ()
  (let ((fname (buffer-file-name)))
    (and fname
         (member (file-truename fname)
                 (mapcar 'file-truename (org-agenda-files))))))

(setq-default ibuffer-saved-filter-groups
              `(("default"
                 ("Agenda" (or (mode . org-agenda-mode)
                               (mode . diary-mode)
                               (predicate . (my-org-agenda-filter)))))))

Note that you should not use org-agenda-files since it can be for example a directory, or even a file containing the list of actual files you're interested in.

  • Your my-org-agenda-filter isn't working for me: no buffers end up in the Agenda group. Using my original strategy but with your new layout (separate function, check for fname) works though. Does this work on your machine? My org-agenda-files is a list of files, but for future readers it would be good if org-agenda-file-p worked. – Buffer Mangler Oct 12 '14 at 13:42
  • @BufferMangler indeed, actually I think my previous implementation worked (I just reverted to it) and I modified it when I saw org-agenda-file-p existed... which is buggy (it doesn't normalize filenames). I guess I should submit a patch. Can you verify if it works for you? – Sigma Oct 12 '14 at 15:08

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.