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

QUESTION: Is it possible to do `:deadline nil` AND `:scheduled nil` #128

Closed jonathanchu closed 4 years ago

jonathanchu commented 4 years ago

Hi @alphapapa! First off, thank YOU for this wonderful package! 🤗 This was exactly what I was looking for all these years!

I'm currently migrating over some custom org agenda commands and was looking for a way to replicate a custom org command that filters tasks that do NOT have a deadline AND scheduled date.

Here is an example of what I was trying:

(setq org-super-agenda-groups '((:name "To Refile"
                                       :and (:scheduled nil :deadline nil)
                                       )))

I've tried several variations of :not and :and with :scheduled and :deadline but could not get it working as I thought. In my attempts, it would not display anything. :scheduled nil and :deadline nil by itself works as expected so I'm thinking maybe my elisp-fu sucks? (...it does ;P)

Thanks again for your time!

alphapapa commented 4 years ago

Hi Jonathan,

Thanks for the kind words. I'm glad it's useful to you.

I did a simple test and it seems to work for me. Using this file content:

* TODO A
* TODO B
* TODO Scheduled
SCHEDULED: <2020-01-01 12:00>
* TODO Deadline
DEADLINE: <2020-01-01 12:00>

And this code:

(org-ql-search "/tmp/delta-895b2.org"
  '(todo)
  :super-groups '((:and (:deadline nil :scheduled nil))))

I get this result:

 Items without deadlines AND Unscheduled items 
  TODO A 
  TODO B 

 Other items
  TODO Scheduled  1d ago 
  TODO Deadline  1d ago 

So I'm guessing the problem is not with org-super-agenda but with your agenda command or query. Remember that org-super-agenda only groups items that are collected by org-agenda or org-ql. The :discard selector can be used as a kind of filter in some cases, but that only removes items that have already been collected.

If my guess is correct, then I recommend that you consider using org-ql where appropriate, because it generally makes writing queries much easier (and often faster with its caching).

jonathanchu commented 4 years ago

Hi @alphapapa, thanks so much for this great response. Your example above with org-ql (TIL BTW, very cool package!) helped me uncover the core issue here...which is a bit embarrassing on my part to admit but here it goes...!

When I use org-agenda, I typically use one of these two commands:

a     Agenda for current week or day
t     List of all TODO entries

I used your concise org example above with org-super-agenda and :and (:deadline nil :scheduled nil) and the result I got was:


Other items
  test:           Sched. 1x:     TODO Scheduled
  test:            1 d. ago:     TODO Deadline

(Note the leading whitespace for the empty group "To Refile")

So this wasn't adding up to me especially from your example above, so I decided to inspect the results from org-agenda-finalize-entries and noticed that the results returned were only scheduled and deadlines. I then dove into the org-mode source code and realized that the functions org-agenda-list and org-todo-list produce different results because of the nature of their corresponding views.

org-agenda-list -> only scheduled and deadline tasks for the week or day view org-todo-list -> all TODOs for the global list view

My blunder here was testing org-super-agenda with the results generated from org-agenda-list and not org-todo-list. 🤦‍♂ Looking back on all this now, it totally makes sense...and I'm glad it turned out to be a good TIL day for me with org-ql and org-mode 😃

Thanks again!

alphapapa commented 4 years ago

Don't feel bad. Every Org user who starts using the Agenda in a more advanced way faces this same problem and learns by trial and error. The Agenda is a powerful but complicated beast. :) That's one of the reasons I wrote org-ql, to hopefully make similar functionality easier to use.

Do you write a blog about Emacs and Org? If you don't, I encourage you to start one, because you write well, and others could learn from your journeys. :)

jonathanchu commented 4 years ago

You're absolutely right, there's only been a handful of times that I ventured into the org-mode source and it never ceases to amaze me how complex it is. It's why packages like org-super-agenda are so great because it helps abstract a lot of that complexity away.

And thanks for those kind and encouraging words @alphapapa! I ought to blog more about Emacs and org-mode and this is the perfect motivation :) :beers:

alphapapa commented 4 years ago

I look forward to seeing your links on Reddit! :)

AtomicNess123 commented 3 years ago

How to group both unscheduled items that have a specific tag? Thanks!