alphapapa / org-super-agenda

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

Entries without a timestamp can have a `dotime` text property and get pulled into `:time-grid` groups #264

Closed floli closed 2 weeks ago

floli commented 2 weeks ago

OS/platform

Linux

Emacs version and provenance

GNU Emacs 29.4 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.42, cairo version 1.18.0) Arch Binary Packages

Emacs command

/usr/bin/emacs --init-directory=$PWD

Org version and provenance

Org mode version 9.7.6 (9.7.6-7a4527 @ /home/florian/Cloud.XGM/super-agenda/elpa/org-9.7.6/)

org-super-agenda package version and provenance

org-super-agenda-20240630.18 installed via package-install

Actions taken

M-x org-agenda t

Observed results

Global list of TODO items of type: ALL
Press ‘N r’ (e.g. ‘0 r’) to search again: (0)[ALL] (1)DONE (2)TODO

 time-grid
  test:       TODO dated item
  test:       TODO undated item

Expected results

I do not expect undated item to show up in section time-grid

Backtrace

No response

Etc.

Complete init.el:

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(setq package-check-signature nil)

(setq org-directory "/home/florian/Cloud.XGM/super-agenda")
(setq org-agenda-files (list org-directory))

(use-package org-super-agenda
  :ensure t
  :config (progn
            (org-super-agenda-mode t)

            (setq org-super-agenda-groups
                  '(
                    (:name "time-grid"
                     :time-grid t)
                    (:name "Todo"
                           :todo "TODO" )
                    (:name "catch-all"
                           :anything t)

                    )                  
                  )))

Example org-file:

* TODO dated item
SCHEDULED: <2024-07-04 Do 14:00>
* TODO undated item

Related discussion: https://www.reddit.com/r/orgmode/comments/1du90tx/superagenda_items_not_showing_on_time_grid_as/

alphapapa commented 2 weeks ago

Thanks. Note that Org 9.6.15 is the version included with Emacs and is now well-outdated. Please install the latest version of Org from GNU ELPA, restart Emacs, ensure that the newer version is loaded, and then see if this problem persists.

Also, please include the Org file with the items you're expecting to appear in the agenda so that I can reproduce the problem identically.

floli commented 2 weeks ago

Updated the original posting accordingly. The results did not change.

alphapapa commented 2 weeks ago

Thanks.

This appears to be a bug in Org Agenda's code. As you can see here: https://github.com/alphapapa/org-super-agenda/blob/17954dc4b064d7fb09719222045d31feae8aa923/org-super-agenda.el#L455-L471 the :time-grid selector in org-super-agenda checks to see whether the line in the Agenda buffer has a dotime text property that is not an empty string.

However, in the example you provided, when I press C-u C-x = on the undated item line in the Agenda buffer, I see that it has the dotime text property with the value t, the same as the dated item. That appears to be incorrect, since the item has no "do time" (no timestamp at all, in fact).

floli commented 2 weeks ago

Great find! Do you take it to upstream or should I?

alphapapa commented 2 weeks ago

My time is very limited for these projects, so I'd appreciate it if you would. I'd suggest asking on the Org mailing list. Be advised that they might not consider this a bug, as here the implementation is the specification, and org-super-agenda isn't part of it. The question is how we can determine whether a line is supposed to be on the time grid via the text properties, and AFAIK this used to work.

yantar92 commented 2 weeks ago

However, in the example you provided, when I press C-u C-x = on the undated item line in the Agenda buffer, I see that it has the dotime text property with the value t, the same as the dated item. That appears to be incorrect, since the item has no "do time" (no timestamp at all, in fact).

You are not right. DOTIME is simply storing the corresponding argument to the org-agenda-format-item. When it is something like t (or other non-string, non-nil value), it means that org-agenda-format-entry should search for time specification in the heading title. If org-super-agenda is expecting DOTIME to be a string or nil, its expectation is erroneous.

I advice using time-of-day property instead.

Of course, all these things are undocumented, as it usually goes with the agenda.

alphapapa commented 2 weeks ago

@yantar92 Thanks. Yes, it was all trial-and-error back when I was originally developing these features. I don't know what changed between now and then, but at least it seems to work now (or we'll see what bug reports come in after this change).

@floli Please let me know if it works for you now.

yantar92 commented 2 weeks ago

I don't know what changed between now and then...

AFAIK, nothing changed. But dotime may have non-string values for certain types of agendas - ones you may not see frequently.

I am now rewriting that part of agenda. I hope to come up with something a bit more consistent. Or at least to document these things.

alphapapa commented 2 weeks ago

I am now rewriting that part of agenda. I hope to come up with something a bit more consistent. Or at least to document these things.

Do you intend to make the rewrite backward-compatible with org-super-agenda? I would not relish having to maintain a completely different set of selectors for different Org versions.

yantar92 commented 2 weeks ago

I will deprecate some properties and remove them eventually (+1 major release after deprecation).

Below if WIP analysis on what is need and what is not needed. Things that are "unused" will be deprecated. Other things may also be deprecated after I look into rewriting the functions that use the relevant properties. Sometimes, properties are there for a single user function.

      - [-] go through every text property and make sure that nothing is broken
    - [ ] org-heading
      - somewhat similar to txt - use to extract title for comparison
      - also used to highlight todo
    - [ ] txt
      - used, need to review further
    - [X] format
      - unsed
    - [X] time-of-day
      - used when sorting
    - [ ] time
      - [ ] Used in ~org-agenda-add-entry-to-org-agenda-diary-file~, which should be fixed anyway
    - [X] duration
      - Used by ~org-columns--collect-values~
    - [ ] extra-space
    - [X] org-category
      - used when sorting
    - [ ] tags
      - set separately, for the whole buffer; ??? Potential problem
    - [ ] org-priority-highest
    - [ ] org-priority-lowest
      - [ ] can get rid by rewriting fontification
    - [X] breadcrumbs
      - unused
    - [ ] level
      - org-agenda-do-in-region
    - [X] extra
      - unused
    - [X] dotime
      - unused
    - [X] org-marker
      - used everywhere
    - [X] org-hd-marker
      - used everywhere
    - [X] todo-state
      - used for sorting
    - [X] ts-date
      - used for sorting
    - [X] priority
      - used for sorting
    - [ ] type
      - used in org-cmp-ts
      - also used by ~org-agenda-kill~ (why??)
    - [X] effort
      - unused
    - [X] effort-minutes
      - used for comparison
    - [X] urgency
      - used for comparison
    - [ ] warntime
      - used by ~org-agenda-to-appt~
      - [ ] single user - may potentially query there
    - [ ] date
      - [ ] org-fix-agenda-info need to study
    - [ ] undone-face
    - [ ] done-face
      - both used in a single function ~org-agenda-change-all-lines~
        - [ ] may it be factored out?
    - [X] org-habit-p
      - used for comparison
      - used by agenda habit integration
    - [ ] org-not-done-regexp
      - [ ] only used by org-agenda-to-appt
    - [ ] org-todo-regexp
      - used by org-agenda-to-appt
      - [ ] org-fix-agenda-info (check what it does)
      - [ ] org-agenda-highlight-todo
      - [ ] used to compare heading titles, alphabetically ~org-cmp-alpha~
    - [X] org-complex-heading-regexp
      - unused
    - [X] org-agenda-diary-link
      - used to mark diary entries
floli commented 1 week ago

@floli Please let me know if it works for you now.

I think so.

given the org file:

* TODO dated and timed item
SCHEDULED: <2024-07-16 Di 14:00>
* TODO dated item
<2024-07-16 So>
* TODO undated item

time-grid catches item that are to appear on the time-grid in the current view, i.e. using org-agenda t it catches no items at all, as there is no time grid. On org-agenda a it catches the dated and timed item, but not the dated item.

If that is the intended behavior, it works for me.

I will check if it fixed my original problem (see my original posting at reddit), but for that specific bug, it is fixed.

Best Thanks!