alphapapa / org-super-agenda

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

`:discard` breaks org-agenda-redo when processing the time grid #215

Open stites opened 2 years ago

stites commented 2 years ago

I have the following configuration at the top level of my configs (I removed irrelevant agenda commands, so beware of unbalanced parens).

(setq org-agenda-custom-commands
      '(
      ;; ...
      ("x" "Overview/span1"
         ((agenda ""
                  ((org-agenda-start-day "0d")
                   (org-agenda-span 1)
                   (org-super-agenda-groups
                    `((:discard (:deadline (after ,(org-read-date nil nil "+14d"))))
                      ))))))
      ;; ...
       ))

This configuration works on the first load; however, when I refresh the page, I get the following stack trace (from emacs --debug-init) which crashes my agenda view.

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  org-super-agenda--group-deadline((... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) (after "2022-02-17"))
  org-super-agenda--group-dispatch-discard((... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) (:deadline ...))
  org-super-agenda--group-dispatch((... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) (:discard ...))
  org-super-agenda--group-items((... ... ... ... ... ... ... ... ... ... ... ... ... ... ...))
  org-super-agenda--filter-finalize-entries(#("  northeastern..." 0 28 ... 28 29 ... 29 47 ... 48 50 ... ...))
  org-agenda-finalize-entries((... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) agenda)
  org-agenda-list(nil)
  funcall-interactively(org-agenda-list nil)
  call-interactively(org-agenda-list)
  #f(compiled-function () #<bytecode 0x295546313818daa>)()
  funcall(#f(compiled-function () #<bytecode 0x295546313818daa>))
  (let ((org-agenda-start-day '"0d") (org-agenda-span '1) (org-super-agenda-groups '((:discard (:deadline (after "2022-02-17")))))) (funcall '#f(compiled-function () #<bytecode 0x295546313818daa>)))
  org-agenda-run-series("Overview/span1" (((agenda "" ((org-agenda-start-day "0d") (org-agenda-span 1) (org-super-agenda-groups `(...)))))))
  org-agenda-redo(nil)
  funcall-interactively(org-agenda-redo nil)
  command-execute(org-agenda-redo)

I am currently using org-super-agenda at the current head of master: fb5e2ef.

I understand that relative date support is in the hands of the user (re: #59) -- as an elisp novice, I could easily be doing something wrong. Any help with this bug or my configuration would be appreciated!

stites commented 2 years ago

Rubber-ducking this a little. I /think/ it trying to discard the non-header lines from the agenda view and discard them, but it's reading them as strings and not org elements. the " northeastern..." is coming from the expected view of my agenda:

Thursday    3 February 2022

 Today
  northeastern: 8:00am...... calendar event 
               8:00am...... ----------------
               9:48am...... now - - - - - - - - - - - - - - - - - - - - - - - - -
              10:00am...... ----------------
              12:00pm...... ----------------
  northeastern: 2:00pm...... calendar event
               2:00pm...... ----------------
               4:00pm...... ----------------
  seminars:    5:00pm...... a seminar title 
               6:00pm...... ----------------
               8:00pm...... ----------------
  todo:       Deadline:   TODO [#A] ...removed...
  todo:       Deadline:   TODO ...removed...

If this intuition is correct, then I would expect this to be a bug with a simple fix of swallowing the error when discarding in a time-grid (with more or less work done verifying that the discard is happening in a time grid). Looking at the codebase, however, I have no idea how to start tackling this problem.

I think this also means there must be a more convenient way to discard events this way. I, personally, couldn't figure this out from the documentation so if this is expected behavior please let me know and I can submit an update to the README.

Attempting to work in an org-super-agenda-only mode returns the same error with the following configuration:

("x" "Overview/span1"
         ((agenda ""
                  ((org-super-agenda-groups
                    `((:discard (:deadline (before ,(org-read-date nil nil "-1d")) ))
                      (:discard (:deadline (after ,(org-read-date nil nil "+1d")) ))
                      ))))

          ))
alphapapa commented 1 year ago

Thanks for reporting this. I probably won't have time to debug this soon, so patches welcome.