alphapapa / alphapapa/org-super-agenda
Allow groups to match items non-greedy?
- Vorherrschende Sprache
- Emacs Lisp
- Sterne
- 1.5k
- Forks
- 107
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Before I go further with this and create a PR, I want to get your input on whether you want it and your thoughts on the design.
This is related to my previous issue, https://github.com/alphapapa/org-super-agenda/issues/152.
On further investigation, I found the problem was that each item could only exist in a single group. This means I cannot both have a "schedule" group and a list of upcoming deadlines as an item can be both, and would get caught by the first. The same issue applies in many cases. I started creating several different functions for different `org-super-agenda-groups` permutations, but it became difficult to create groups which didn't overlap, and just creating all of these felt wrong.
Looking at the code made it seem like a small change to allow an item to both match, and still flow to groups further down. A non-greedy match.
I created a simple implementation for this so I could make sure items matches several groups, and for my use-case, this works fine.
``` patch
diff --git a/org-super-agenda.el b/org-super-agenda.el
index 7878c40..541b0dd 100644
--- a/org-super-agenda.el
+++ b/org-super-agenda.el
@@ -121,7 +121,7 @@
;;;; Variables
(defconst org-super-agenda-special-selectors
- '(:name :order :face :transformer)
+ '(:name :order :face :transformer :forward)
;; This needs to be manually updated if any are added.
"Special, non-grouping selectors.")
@@ -1024,7 +1024,7 @@ see."
;; This is the implicit OR
append matching into all-matches
and collect auto-section-name into names
- and do (setq items non-matching)
+ and do (setq items (append non-matching (and (memq :forward group) matching)))
for name = (if (stringp (car names))
(s-join " and " (-non-nil names))
;; Probably an :auto-group
```
What do you think about a feature like this? I would like to avoid maintaining a fork, so I'll happily do some work on this. Note that I don't know much lisp or emacs, so it might take a while.
EDIT: With a patch like the above, it's also useful to have the option to avoid the "unmatched" grouping as the above doesn't count number of groups an item is matched in, and we can easily wind up getting a full log of everything in the "unmatched" group
``` patch
diff --git a/org-super-agenda.el b/org-super-agenda.el
index 541b0dd..b8a6394 100644
--- a/org-super-agenda.el
+++ b/org-super-agenda.el
@@ -174,7 +174,9 @@ disabled. This sets the INHERIT argument to `org-entry-get'."
:type 'boolean)
(defcustom org-super-agenda-unmatched-name "Other items"
- "Default name for agenda section containing items unmatched by any filter."
+ "Default name for agenda section containing items unmatched by any filter.
+If this is NIL, no section is added for items which gets to this point,
+and any items not matched by other groups will be silently discarded."
:type 'string)
(defcustom org-super-agenda-unmatched-order 99
@@ -791,9 +793,10 @@ The string should be the priority cookie letter, e.g. \"A\".")
and do (setq all-items non-matching)
;; Sort sections by :order then :name
- finally do (setq non-matching (list :name org-super-agenda-unmatched-name
- :items non-matching
- :order org-super-agenda-unmatched-order))
+ finally do (setq non-matching (and org-super-agenda-unmatched-name
+ (list :name org-super-agenda-unmatched-name
+ :items non-matching
+ :order org-super-agenda-unmatched-order)))
finally do (setq sections (--sort (let ((o-it (plist-get it :order))
(o-other (plist-get other :order)))
(cond ((and
```
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.