Charles Tam via "General discussions about Org-mode."
<emacs-orgmode@gnu.org> writes:

> Here is a patch for timestamp sortation issues in todo-list, as
> documented in the following recent threads:

Thanks!

> This change uses the full timestamp, not just the date, and retrieves
> it by inspecting the headline in its original file, instead of relying
> on the population of text properties.  This is probably a little more
> computationally expensive -- we do this inspection step during *every*
> call to the comparison function, instead of caching its value in a
> text property.  In my personal experience using this across about 50
> agenda files containing a total of about 500 headlines, this has not
> resulted in any noticeable lag.

500 headlines is nothing. Agenda is sometimes used across tens of
thousands of entries. So, performance can be an issue.

> In addition, I felt it was prudent to make a change to this function,
> which is only ever called in the context of agenda sorting, rather
> than to redesign and repair the assignment of text properties that
> happens in org.el:org-scan-tags.  A more proper solution would be to
> make a fix there.  As mentioned, I believe the root cause to be that
> some properties (like time-of-day) are assigned in the weekly/daily
> agenda view and not in any of the other views, and surely
> `org-agenda-sorting-strategy' is not the only functionality affected
> by this discrepancy.

Yup, a proper solution would be making a fix there. Not only because of
performance, but also because we cannot assume that "timestamp"
comparison is always done on the return value of `org-entry-get'. In
particular, when you have timestamps with repeaters, agenda will
calculate 'ts-date taking into account the specific timestamp values at
the current agenda span. Another example is when
`org-agenda-include-inactive-timestamps' is set to t. Then,
timestamp-up/down sorting will act on inactive timestamps as
well. Finally, agenda takes into account *all the timestamps*, not just
the first timestamp returned by `org-entry-get'; if a headline has
multiple active timestamps inside, agenda will show a line for each of
these timestamps and sorting should use the right timestamp associated
with specific agenda line.

In other words, your patch will cause a lot of breakage. (you see now
why I said that adding this feature is not trivial).

What might be done to implement the feature properly is adding a new
text property akin 'ts-date that will hold timestamp value in seconds,
not in days. Say, we can call it 'ts-date-seconds. Then, you can use
that text property in the comparison for more accuracy.

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to