alphapapa / org-super-agenda

Supercharge your Org daily/weekly agenda by grouping items
GNU General Public License v3.0
1.35k stars 107 forks source link

Missing item when using :auto-parent #130

Closed failable closed 4 years ago

failable commented 4 years ago

Say there's a test.org containing

* TODO Parent 1
DEADLINE: <2020-01-18 Sat>
** TODO Child 1
** TODO Child 2
* TODO Parent 2
DEADLINE: <2020-01-18 Sat>

Parent 2 is missing in the result of the following script

(-let* (((sec minute hour day month year dow dst utcoff) (decode-time))
        (last-day-of-month (calendar-last-day-of-month month year))
        (target-date
         (format "%d-%02d-%02d" year month (1+ last-day-of-month)))
        (org-agenda-files '("~/org/test.org"))
        (org-agenda-custom-commands
         `(("z" "Super agenda"
            ((alltodo "" ((org-agenda-overriding-header "")
                          (org-super-agenda-groups
                           '((:auto-parent t :deadline (before ,target-date))
                             (:todo "TODO"))))))))))
  (org-agenda nil "z"))

i.e.

Parent 1
test:       TODO Child 1
test:       TODO Child 2

The strange part to me is, if the :deadline part is removed, Parent 2 appears.

Will items that have no parent get filtered in the selectors that near :auto-parent? Is :auto-parent designed to be work with any other selector? I guess some like :name is meaningless to it. Thanks.

alphapapa commented 4 years ago

The :auto- selectors can't be combined with other selectors, because they expand internally to multiple groups at runtime, e.g. one for each parent item.

You may find org-ql helpful in writing more advanced queries.

failable commented 4 years ago

Thanks for the quick reply.

they expand internally to multiple groups at runtime, e.g. one for each parent item.

I guessed so. But why the behavior different when :deadline is removed?

The strange part to me is, if the :deadline part is removed, Parent 2 appears.

—————————— Under some selecting criteria, I want make groups for items that have parents and leave items that have no parents as a single group. Can I achieve this without using org-ql? Should I only use :auto-parent as the last selector? Thanks.

alphapapa commented 4 years ago

Thanks for the quick reply.

they expand internally to multiple groups at runtime, e.g. one for each parent item.

I guessed so. But why the behavior different when :deadline is removed?

I don't know. It's not intended to be used that way.

The strange part to me is, if the :deadline part is removed, Parent 2 appears.

—————————— Under some selecting criteria, I want make groups for items that have parents and leave items that have no parents as a single group.

That's what will happen if you use '((:auto-parent t)).

Should I only use :auto-parent as the last selector?

That depends on what you want to achieve. As the documentation says, groups consume items, and ones that are not matched fall through to later selectors.

failable commented 4 years ago

It seems no selection should be performed when using auto selectors, e.g. select anything that has deadline this month and group them.

alphapapa commented 4 years ago

I don't understand what you mean.