alphapapa / org-super-agenda

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

:discard will discard all lines in agenda that render exactly the same if any *one* of the corresponding headings match #227

Open telotortium opened 1 year ago

telotortium commented 1 year ago

I have an Org-mode file filled with entries from org-gcal. One of the features it has is the ability to retrieve the parent of a recurring event and put the individual instances of the recurring event as children under this parent event - note that the parent event has the "recurrence" property while the children do not:

* MEETING Deloitte BPO Feedback - AML team
:PROPERTIES:
:recurrence: [RRULE:FREQ=MONTHLY;UNTIL=20221029T035959Z;INTERVAL=1;BYDAY=4TU]
:calendar-id: foo@group.calendar.google.com
:entry-id: bar/foo@group.calendar.google.com
:Effort:   0:30
:org-gcal-managed: gcal
:END:
:org-gcal:
<2022-07-26 Tue 14:00-14:30>
:END:

** MEETING Deloitte BPO Feedback - AML team
:PROPERTIES:
:calendar-id: foo@group.calendar.google.com
:entry-id: bar_20220726T210000Z/foo@group.calendar.google.com
:Effort:   0:30
:END:
:org-gcal:
<2022-07-26 Tue 14:00-14:30>
:END:

I wanted to ensure that I only see the child events, not the parent events, so I used the following org-super-agenda-groups:

  (setq! org-super-agenda-groups
         ;; Each group has an implicit boolean OR operator between its selectors.
         '(
           ;; Discard top-level recurring events fetched by org-gcal unless I’ve
           ;; done something to indicate I’m using them.
           (:discard
            (:tag "ARCHIVE"
             :and
             (:todo "CANCELLED")
             :and
             (
               ;; Not using ~:property "recurrence"~ because the properties
               ;; there are inherited, which means it will match all the
               ;; children too.
               :regexp "^[ \t]*:recurrence:"
               :not (:log t)
               :not (:habit t))
             :and
             (:tag "inbox")))
           (:name "Today"  ; Optionally specify section name
            :time-grid t  ; Items that appear on the time grid
            :todo "TODAY")  ; Items that have this TODO keyword
           (:name "Important (max in-flight should be 3)" :priority "A")
           ;; Set order of multiple groups at once
           (:todo "WAITING")
           (:name "Drill" :tag "drill")
           (:name "Today" :scheduled today :deadline today)
           (:name "Overdue"
            :and
            (:scheduled past :deadline past))
           (:name "Habits" :habit t)
           (:priority<= "B"
            ;; Show this section after "Today" and "Important", because
            ;; their order is unspecified, defaulting to 0. Sections
            ;; are displayed lowest-number-first.
            :order 1)))

However, this ends up deleting both lines for "Deloitte BPO Feedback - AML team" - the parent and the child.

I can work around this by adding the tag :gcal: to the parent heading (this is a tag I already have in FILETAGS, so I don't mind adding it here). This seems to work by slightly reformatting the agenda lines so that they're not the exact same - notice the tags at the end of the line:

  Lark:       14:00-14:30 MEETING Deloitte BPO Feedback - AML team                     :TikTok::gcal:
  Lark:       14:00-14:30 MEETING Deloitte BPO Feedback - AML team                     :TikTok:gcal::

Expected behavior: remove only the parent heading, not the child heading, from the agenda, even if the heading lines are exactly the same.

alphapapa commented 1 year ago

Hm, this seems strange. Would you simplify the groups definition to the minimum necessary to reproduce the problem?

Also, please see org-super-agenda-properties-inherit; I wonder if disabling that would let you use the property selector.