all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Jonas Olofsson <jonas.olofsson@apple.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [BUG] Agenda not sorting by priority THEN todo state (todo state ignored) [9.6.1 (9.6.1-??-fe92a3c @ /Users/polofsson/.emacs.d/.local/straight/build-28.2/org/)]
Date: Wed, 22 Mar 2023 11:28:20 +0000	[thread overview]
Message-ID: <874jqdowiz.fsf@localhost> (raw)
In-Reply-To: <26396316-1201-4D88-9D81-C87DDDA8885A@apple.com>

Jonas Olofsson <jonas.olofsson@apple.com> writes:

> I am trying to sort my agenda by a number of variables, but it seems
> that todo-state-down is not applied if added after priority-down.
> Instead it seems as if Priority first is applied, then the date the
> item is scheduled.
>
> Repro:
> 1. Set 
>    org-agenda-sorting-strategy
>    '((agenda priority-down todo-state-down)
>      (todo priority-down todo-state-down effort-up category-keep scheduled-up)
>      (tags priority-down todo-state-down effort-up category-keep)
>      (search category-keep))
> 2. Set 
>    org-todo-keywords '(
>                        (sequence "TODO(t!)" "NEXT(n!)" "WAIT(w!)" "|" "DONE(d!)" "CANC(c!)" "DUPE(D!)")
>                        )
> 3. Have three todos scheduled:
>
> * TODO [#C] Test
> SCHEDULED: <2023-03-16 Thu>
> * NEXT [#C] Test
> SCHEDULED: <2023-03-15 Wed>
> * WAIT [#C] Test 
> SCHEDULED: <2023-03-17 Fri>
>
> 4. Go to agenda.
>
> I expect to see items in the following order, since they are the same priority.
> WAIT C Test
> NEXT C Test
> TODO C Test
>
> But I see:
> NEXT C Test
> TODO C Test
> WAIT C Test

Confirmed.

Yet another agenda madness I have no clue about.

`org-agenda-get-scheduled' sets the priority as

'priority (if habitp (org-habit-get-priority habitp)
			      (+ 99 diff (org-get-priority item)))

where diff is the number of overdue days for a given entry.

Further,

`org-agenda-get-deadlines' has

		  'priority
		  ;; Adjust priority to today reminders about deadlines.
		  ;; Overdue deadlines get the highest priority
		  ;; increase, then imminent deadlines and eventually
		  ;; more distant deadlines.
		  (let ((adjust (if today? (- diff) 0)))
		    (+ adjust (org-get-priority item)))

`org-agenda-get-todos' has

	      priority (1+ (org-get-priority txt)))

All these dates back to the initial Org release.

From what I am seeing, these awkward priority adjustments are hard-coded
for fine-tune agenda sorting in some (unknown) scenarios.

Changing them will likely break existing sorting.

To fix this, we should carefully check what will happen if we set the
agenda priority to be the actual user-defined priority. And then fix the
sorting back somehow.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
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	other threads:[~2023-03-22 11:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-19  1:07 [BUG] Agenda not sorting by priority THEN todo state (todo state ignored) [9.6.1 (9.6.1-??-fe92a3c @ /Users/polofsson/.emacs.d/.local/straight/build-28.2/org/)] Jonas Olofsson
2023-03-22 11:28 ` Ihor Radchenko [this message]
2023-03-23  0:56   ` Samuel Wales
2023-03-23 11:28     ` Ihor Radchenko
2023-03-24  3:54       ` Samuel Wales
2023-03-24  3:56         ` Samuel Wales
2023-03-24 11:45         ` Ihor Radchenko
2023-03-25  5:59           ` Samuel Wales
2023-04-02  9:47             ` Ihor Radchenko
2023-04-03  0:30               ` Samuel Wales
2023-04-03  8:59                 ` Ihor Radchenko
2023-04-06  9:44       ` Ihor Radchenko
2023-04-06 23:37         ` Samuel Wales

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

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

  git send-email \
    --in-reply-to=874jqdowiz.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=jonas.olofsson@apple.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.