emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] lisp/org-agenda.el: Fix filter preset problem for sticky agenda


From: Liu Hui
Subject: [PATCH] lisp/org-agenda.el: Fix filter preset problem for sticky agenda
Date: Tue, 04 Oct 2022 13:02:20 +0800

Hi,

This patch fixes the bug originally reported in
https://list.orgmode.org/59e02fb6.1462370a.fffe8.51c4@mx.google.com/
with the following reproducing recipe. The bug still exists in latest
org-mode.

> To reproduce, take the following org file:
>
> ---8<---
> * Foo
>   :PROPERTIES:
>   :CATEGORY: foo
>   :END:
> ** TODO Foo todo one
>    DEADLINE: <2017-10-13 Fri>
>    - foo 1
>
> * Bar
>   :PROPERTIES:
>   :CATEGORY: bar
>   :END:
> ** TODO Bar todo one
>    DEADLINE: <2017-10-13 Fri>
>    - bar 1
> --->8---
>
> And the following elisp file to setup a minimal environment:
>
> ---8<---
> (require 'org)
> (setq org-agenda-files (list (expand-file-name "repro.org")))
> (setq org-agenda-sticky t)
> (setq org-agenda-custom-commands
>       '(("f" "foo"
>          ((agenda "" ())
>           (tags-todo "+CATEGORY=\"foo\"" ()))
>          ((org-agenda-category-filter-preset '("+foo"))))
>
>         ("b" "bar"
>          ((agenda "" ())
>           (tags-todo "+CATEGORY=\"bar\"" ()))
>          ((org-agenda-category-filter-preset '("+bar"))))))
>
> (global-set-key (kbd "C-c a") #'org-agenda)
> --->8---
>
> Then run (something like):
>
> emacs -nw -Q -L ~/git/org-mode/lisp -l repro.el repro.org
>
> Followed by:
>
> C-c a f
> C-c a b
> C-x o
> r
>
> I would expect pressing `r' in the `*Org Agenda(f)*' buffer would
> keep the original `org-agenda-category-filter-preset' and that the
> preset in `*Org Agenda(b)*' should have no bearing on it.  But, as you
> can (probably) see from the mode line, the filter is set to "+bar", and
> refreshing the buffer causes all the TODOs to be lost because it now has
> the wrong filter.

Because the filter presets are stored as symbol properties, they
cannot be used with multiple sticky agenda buffers. The patch fixes
the problem by adding a new variable `org-agenda-filters-preset' for
getting and setting per-buffer filter presets. I have signed the FSF
copyright assignment paper.

Best,
Hui

Attachment: 0001-lisp-org-agenda.el-Fix-filter-preset-problem-for-sti.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]