emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] tsia-up sorting strategy sorts agenda by date and ignores time.


From: Matt Lundin
Subject: Re: [O] tsia-up sorting strategy sorts agenda by date and ignores time. How can I change that?
Date: Tue, 21 Mar 2017 12:13:02 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Arkady Grudzinsky <address@hidden> writes:

> Hi,
>
> I'd like to sort my tasks in agenda by inactive creation
> timestamp which includes the time portion.  I have found that
> tsia-up strategy ignores the time portion of the timestamp.  Is
> there a way to take time into account?

Unfortunately, the org sorting relies on org-time-string-to-absolute,
which converts time strings to days only, so the default is just a day
to day comparison.

You could use something like this and then add user-defined-up or
user-defined-down where desired in org-agenda-sorting-strategy:

--8<---------------cut here---------------start------------->8---
(defun my-sort-by-inactive-timestamp-incl-time (a b)
  (let* ((ma (get-text-property 1 'org-marker a))
         (mb (get-text-property 1 'org-marker b))
         (tsa (with-current-buffer (marker-buffer ma)
                 (org-entry-get (marker-position ma) "TIMESTAMP_IA")))
         (tsb (with-current-buffer (marker-buffer mb)
                 (org-entry-get (marker-position mb) "TIMESTAMP_IA")))
         (seca (if tsa (org-time-string-to-seconds tsa) 0))
         (secb (if tsb (org-time-string-to-seconds tsb) 0)))
    (cond ((> seca secb) 1)
          ((> secb seca) -1)
          (t nil))))

(setq org-agenda-cmp-user-defined 'my-sort-by-inactive-timestamp-incl-time)
--8<---------------cut here---------------end--------------->8---

I imagine there are ways to do this more elegantly (e.g., by iterating
over a and b), but this gets the job done for me.

Best,
Matt



reply via email to

[Prev in Thread] Current Thread [Next in Thread]