emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sebastien Vauban" <sva-news-D0wtAvR13HarG/iDocfnWg@public.gmane.org>
To: emacs-orgmode-mXXj517/zsQ@public.gmane.org
Subject: Re: [BUG] `org-agenda-sorting-strategy' does not work in `tags-todo'
Date: Thu, 13 Feb 2014 10:58:44 +0100	[thread overview]
Message-ID: <86ppmruyej.fsf@somewhere.org> (raw)
In-Reply-To: 87wqklk681.fsf@bzg.ath.cx

Hi Bastien,

Bastien wrote:
> Sebastien Vauban writes:
>
>>> Calendar for today
>>> 2013-09-12 Thu ________________________________________________
>>>  5 d ago      TODO 1Buy dog food
>>>  4 d ago      TODO 2Check weekend hours at the gym
>>>  3 d ago      TODO 3Do jogging
>>>  Deadline     TODO 4Mail package to Susan
>>
>> Anybody having a hint on this?
>
> That's because deadline-up/down is active in "agenda" agenda views,
> not in tags view -- and "DEADLINE<=\"<today>\"" ... is a tag search,
> not an "agenda" agenda view.
>
> I know the answer cannot be 100% satisfying, but sorting by date
> in this case would require to add a text property to each agenda
> entry, and would be certainly too time consuming (not tested.)

Though, not speaking of fundamental differences (such as: you have to
write specific code to skip different types of entries), going the
"agenda" agenda view approach is not (yet) satisfying.

Let's consider the following ecm.org file:

--8<---------------cut here---------------start------------->8---
* List of tasks

** TODO Pay electricity bill (before 18/02)
   DEADLINE: <2014-02-18 Tue -3d>

... but first wait for my pay of the first half of the month (15/02).

** TODO Renew newspaper subscription
   DEADLINE: <2014-02-19 Wed>

** TODO Subscribe to new gym club
   DEADLINE: <2014-03-01 Sat>

My goal is to begin in March.

** TODO Make dentist appointment
   DEADLINE: <2014-04-01 Tue -60d>

Call the dentist much time in advance, because she's got a very long waiting
list.
--8<---------------cut here---------------end--------------->8---

The 26-line "agenda" agenda view:

--8<---------------cut here---------------start------------->8---
    (add-to-list 'org-agenda-custom-commands
                 `("x" "Future tasks (by due date) -- AGENDA VIEW"
                   ((agenda ""
                            ((org-agenda-overriding-header "This week")
                             (org-agenda-skip-function
                              '(my-skip-entry-unless-deadline-in-n-days-or-more 1))
                             (org-deadline-warning-days 7)))
                    (agenda ""
                            ((org-agenda-format-date "")
                             (org-agenda-overriding-header "Following 3 weeks")
                             (org-agenda-skip-function
                              '(my-skip-entry-unless-deadline-in-n-days-or-more 7))
                             (org-deadline-warning-days 28))))
                   ((org-agenda-clockreport-mode nil)
                    (org-agenda-format-date "")
                    (org-agenda-span 'day)
                    (org-agenda-sorting-strategy '(deadline-up))
                    (org-agenda-use-time-grid nil))) t)

    (defun my-skip-entry-unless-deadline-in-n-days-or-more (n)
      "Skip entries that have no deadline, or that have a deadline earlier than in N days."
      (let* ((dl (org-entry-get nil "DEADLINE")))
        (if (or (not dl)
                (equal dl "")
                (org-time< dl (+ (org-time-today) (* n 86400))))
            (progn (outline-next-heading) (point)))))
--8<---------------cut here---------------end--------------->8---

displays:

--8<---------------cut here---------------start------------->8---
This week:
 In 6 d       TODO Renew newspaper subscription
 In 47 d      TODO Make dentist appointment

Following 3 weeks:
 In 16 d      TODO Subscribe to new gym club
 In 47 d      TODO Make dentist appointment
--8<---------------cut here---------------end--------------->8---

This is wrong for 2 tasks:

- "Make dentist appointment" (with a -60d "warning" specifier) appears in both
  "this week" and "following 3 weeks" lists, while it shouldn't appear at all,
  as its deadline doesn't fall within the search ranges.

- "Pay electricity bill" (with a -3d "warning" specifier) doesn't appear in
  "this week" list, while it should.

The 8-line "tags" agenda view:

--8<---------------cut here---------------start------------->8---
    (add-to-list 'org-agenda-custom-commands
                 `("x" "Future tasks (by due date) -- TODO-TAGS VIEW"
                   ((tags-todo "DEADLINE>\"<+0d>\"+DEADLINE<=\"<+7d>\""
                               ((org-agenda-overriding-header "This week")))
                    (tags-todo "DEADLINE>\"<+7d>\"+DEADLINE<=\"<+28d>\""
                               ((org-agenda-overriding-header "Following 3 weeks"))))
                   ((org-agenda-skip-function '(org-agenda-skip-entry-if 'notdeadline))
                    (org-agenda-sorting-strategy '(deadline-up)))) t)
--8<---------------cut here---------------end--------------->8---

does output the right tasks:

--8<---------------cut here---------------start------------->8---
This week:
 ecm:         TODO Pay electricity bill (before 18/02)
 ecm:         TODO Renew newspaper subscription

Following 3 weeks:
 ecm:         TODO Subscribe to new gym club
--8<---------------cut here---------------end--------------->8---

Though the "deadline-up" sorting does not work, as demo'ed in the previous post.

Is there a solution (or work around) that would allow to see the right
tasks (based on the deadline date, not on the "warning" specifier),
sorted by due date?  Any hint?

Best regards,
  Seb

-- 
Sebastien Vauban

  reply	other threads:[~2014-02-13  9:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-12 12:55 [BUG] `org-agenda-sorting-strategy' does not work in `tags-todo' Sebastien Vauban
2013-10-21 21:07 ` Sebastien Vauban
2013-11-06 13:30   ` Bastien
2014-02-13  9:58     ` Sebastien Vauban [this message]
2014-03-21  7:55       ` Bastien
     [not found]         ` <87mwgkf0jq.fsf-E3UqQZAQFPqWIDz0JBNUog@public.gmane.org>
2014-03-31 14:17           ` Sebastien Vauban
2015-01-05 12:41             ` Nick

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86ppmruyej.fsf@somewhere.org \
    --to=sva-news-d0wtavr13harg/idocfnwg@public.gmane.org \
    --cc=emacs-orgmode-mXXj517/zsQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).