Dear all,

I regularly lose all my filters when I bury a sticky agenda and revive
it later.  In that case, the variable `org-agenda-tag-filter' is set to
nil, although it was non-nil before burying.

I played around a bit, and found out that `org-agenda-tag-filter' is
buffer-local (which is not a surprise).  When the agenda buffer is
revived, the function `org-agenda-prepare' is called, which, among
others, should reset the filters (provided that
`org-agenda-persistent-filter' is set).  The beginning of the function
is

--->8---
(defun org-agenda-prepare (&optional name)
  (let ((filter-alist (if org-agenda-persistent-filter
                          (list `(tag . ,org-agenda-tag-filter)
                                `(re . ,org-agenda-regexp-filter)
                                `(car . ,org-agenda-category-filter)))))
  ...))
---8<---

It seems to me that `org-agenda-tag-filter' is read *before* the old
agenda buffer is poped up (i.e., made current), and thus results in a
`nil' value.  Indeed, if I replace the definition of `filter-alist' by

--->8---
(let ((filter-alist (if org-agenda-persistent-filter
                        (with-current-buffer
                            (get-buffer org-agenda-buffer-name)
                          (list `(tag . ,org-agenda-tag-filter)
                                `(re . ,org-agenda-regexp-filter)
                                `(car . ,org-agenda-category-filter))))))
  ...)
---8<---

then the bug (seems to) disappear.

My question is now: is this correct, or did I understand something
wrong?  If my understanding is correct, how this bug be fixed more
elegantly?

Best,

  Daniel

-- 
Daniel Borchmann                                   http://daniel.kxpq.de
GPG (Mail)            0849 473E 6BF0 B504 DF0B  D640 455E 3610 01FF 778F

Attachment: signature.asc
Description: PGP signature

Reply via email to