emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* tsia-up sorting strategy sorts agenda by date and ignores time. How can I change that?
@ 2017-03-20 18:43 Arkady Grudzinsky
  2017-03-21 17:13 ` Matt Lundin
  0 siblings, 1 reply; 4+ messages in thread
From: Arkady Grudzinsky @ 2017-03-20 18:43 UTC (permalink / raw)
  To: emacs-orgmode

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?

Thanks.

-- 
Arkady

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: tsia-up sorting strategy sorts agenda by date and ignores time. How can I change that?
  2017-03-20 18:43 tsia-up sorting strategy sorts agenda by date and ignores time. How can I change that? Arkady Grudzinsky
@ 2017-03-21 17:13 ` Matt Lundin
  2017-03-22 16:25   ` Arkady Grudzinsky
  0 siblings, 1 reply; 4+ messages in thread
From: Matt Lundin @ 2017-03-21 17:13 UTC (permalink / raw)
  To: Arkady Grudzinsky; +Cc: emacs-orgmode

Arkady Grudzinsky <agrudzinsky@gmail.com> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: tsia-up sorting strategy sorts agenda by date and ignores time. How can I change that?
  2017-03-21 17:13 ` Matt Lundin
@ 2017-03-22 16:25   ` Arkady Grudzinsky
  2017-03-22 17:13     ` Arkady Grudzinsky
  0 siblings, 1 reply; 4+ messages in thread
From: Arkady Grudzinsky @ 2017-03-22 16:25 UTC (permalink / raw)
  To: emacs-orgmode

On Tue, Mar 21 2017, Matt Lundin wrote:

> You could use something like this and then add user-defined-up or
> user-defined-down where desired in org-agenda-sorting-strategy:
>
> (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)
>
> 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.

This works.  Awesome!  Thanks.  

-- 
Arkady

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: tsia-up sorting strategy sorts agenda by date and ignores time. How can I change that?
  2017-03-22 16:25   ` Arkady Grudzinsky
@ 2017-03-22 17:13     ` Arkady Grudzinsky
  0 siblings, 0 replies; 4+ messages in thread
From: Arkady Grudzinsky @ 2017-03-22 17:13 UTC (permalink / raw)
  To: emacs-orgmode

On Wed, Mar 22 2017, Arkady Grudzinsky wrote:

> On Tue, Mar 21 2017, Matt Lundin wrote:
>
>> You could use something like this and then add user-defined-up or
>> user-defined-down where desired in org-agenda-sorting-strategy:
>>
>> (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)
>>
>> 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.
>
> This works.  Awesome!  Thanks.  

When this user-defined-up is set in agenda view (C-c a a), the
agenda view throws an error message.

,----
| set-buffer: Wrong type argument: markerp, nil
`----

It works in the todo list views, though, which is good enough for me.

Thanks again.  Just wanted to mention this for the record.

-- 
Arkady

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-03-22 17:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-20 18:43 tsia-up sorting strategy sorts agenda by date and ignores time. How can I change that? Arkady Grudzinsky
2017-03-21 17:13 ` Matt Lundin
2017-03-22 16:25   ` Arkady Grudzinsky
2017-03-22 17:13     ` Arkady Grudzinsky

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).