all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [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/)]
@ 2023-03-19  1:07 Jonas Olofsson
  2023-03-22 11:28 ` Ihor Radchenko
  0 siblings, 1 reply; 13+ messages in thread
From: Jonas Olofsson @ 2023-03-19  1:07 UTC (permalink / raw)
  To: emacs-orgmode



Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

     https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.
------------------------------------------------------------------------

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

It seems the sorting is based on the scheduled time - NOT the todo state
(since they are the same priority). 

I've checked various things and priority, habit, all other
org-agenda-sorting-strategy variables sort ok if indepdendently applied.
I am only able to reproduce this issuey when I have todo-state-down
AFTER priority-down in org-agenda-sorting-strategies.

Any help appreciated.

Regards,
Jonas


Emacs  : GNU Emacs 28.2 (build 1, aarch64-apple-darwin21.6.0, Carbon Version 165 AppKit 2113.6)
of 2022-09-15
Package: Org mode version 9.6.1 (9.6.1-??-fe92a3c @ /Users/polofsson/.emacs.d/.local/straight/build-28.2/org/)


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

* 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/)]
  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
  2023-03-23  0:56   ` Samuel Wales
  0 siblings, 1 reply; 13+ messages in thread
From: Ihor Radchenko @ 2023-03-22 11:28 UTC (permalink / raw)
  To: Jonas Olofsson; +Cc: emacs-orgmode

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>


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

* 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/)]
  2023-03-22 11:28 ` Ihor Radchenko
@ 2023-03-23  0:56   ` Samuel Wales
  2023-03-23 11:28     ` Ihor Radchenko
  0 siblings, 1 reply; 13+ messages in thread
From: Samuel Wales @ 2023-03-23  0:56 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Jonas Olofsson, emacs-orgmode

perhaps we could have 2 names: one for the priority cookie setting and
one for whatever the agenda does.


On 3/22/23, Ihor Radchenko <yantar92@posteo.net> wrote:
> 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>
>
>


-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com


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

* 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/)]
  2023-03-23  0:56   ` Samuel Wales
@ 2023-03-23 11:28     ` Ihor Radchenko
  2023-03-24  3:54       ` Samuel Wales
  2023-04-06  9:44       ` Ihor Radchenko
  0 siblings, 2 replies; 13+ messages in thread
From: Ihor Radchenko @ 2023-03-23 11:28 UTC (permalink / raw)
  To: Samuel Wales; +Cc: Jonas Olofsson, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 242 bytes --]

Samuel Wales <samologist@gmail.com> writes:

> perhaps we could have 2 names: one for the priority cookie setting and
> one for whatever the agenda does.

This is a good idea. Thanks!

See the attached fix making use of Samuel's suggestion.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-agenda-Rename-sorting-priority-to-urgency.patch --]
[-- Type: text/x-patch, Size: 15087 bytes --]

From d6881c39c91beabdc0bfb29d6dc8a81202a84e40 Mon Sep 17 00:00:00 2001
Message-Id: <d6881c39c91beabdc0bfb29d6dc8a81202a84e40.1679570866.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Thu, 23 Mar 2023 12:20:19 +0100
Subject: [PATCH] org-agenda: Rename sorting "priority" to "urgency"

* lisp/org-habit.el (org-habit-get-priority): Rename to
`org-habit-get-urgency'.
* lisp/org-compat.el (org-habit-get-priority): Obsolete the old name.
* lisp/org-agenda.el (org-agenda-sorting-strategy):
* lisp/org-agenda.el (org-search-view):
(org-agenda-get-todos):
(org-agenda-get-timestamps):
(org-agenda-get-progress):
(org-agenda-get-deadlines):
(org-agenda-get-scheduled):
(org-agenda-get-blocks):
(org-entries-lessp): Alter priority-up and priority-down sorting
strategies to only sort by actual priority.  Rename the previous
composite sorting rank to urgency, corresponding to the new urgency-up
and urgency-down sorting strategies.  Store the new rank in 'urgency
text property.  Update the docstrings accordingly.  Use `urgency-down'
in place of `priority-down' in the default sorting strategy.
(org-set-sorting-strategy): Use `urgency-down' in place of
`priority-down'.
* etc/ORG-NEWS ("Priority" used to sort items in agenda is renamed to
"urgency"): Document the change.
* doc/org-manual.org (Sorting of agenda items): Update manual using
"urgency" term in place of confusing "priority".

Thanks to Samuel Wales for the idea how to fix the inconsistency.

Reported-by: Jonas Olofsson <jonas.olofsson@apple.com>
Link: https://orgmode.org/list/26396316-1201-4D88-9D81-C87DDDA8885A@apple.com
---
 doc/org-manual.org | 16 +++++------
 etc/ORG-NEWS       | 15 ++++++++++
 lisp/org-agenda.el | 72 +++++++++++++++++++++++++++++-----------------
 lisp/org-compat.el |  2 ++
 lisp/org-habit.el  |  4 +--
 5 files changed, 73 insertions(+), 36 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 37fd3df14..ff06694a8 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -9419,16 +9419,16 @@ *** Sorting of agenda items
   time-of-day specification.  These entries are shown at the beginning
   of the list, as a /schedule/ for the day.  After that, items remain
   grouped in categories, in the sequence given by ~org-agenda-files~.
-  Within each category, items are sorted by priority (see
-  [[*Priorities]]), which is composed of the base priority (2000 for
-  priority =A=, 1000 for =B=, and 0 for =C=), plus additional
-  increments for overdue scheduled or deadline items.
+  Within each category, items are sorted by urgency, which is composed
+  of the base priority (see [[*Priorities]]; 2000 for priority =A=, 1000
+  for =B=, and 0 for =C=), plus additional increments for overdue
+  scheduled or deadline items.
 
 - For the TODO list, items remain in the order of categories, but
-  within each category, sorting takes place according to priority (see
-  [[*Priorities]]).  The priority used for sorting derives from the
-  priority cookie, with additions depending on how close an item is to
-  its due or scheduled date.
+  within each category, sorting takes place according to urgency.  The
+  urgency used for sorting derives from the priority cookie, with
+  additions depending on how close an item is to its due or scheduled
+  date.
 
 - For tags matches, items are not sorted at all, but just appear in
   the sequence in which they are found in the agenda files.
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 4ca13af17..2b055a76a 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -13,6 +13,21 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
 
 * Version 9.7 (not released yet)
 ** Important announcements and breaking changes
+*** "Priority" used to sort items in agenda is renamed to "urgency"
+
+Previously, ~priority-up~ and ~priority-down~ in
+~org-agenda-sorting-strategy~ used a composite rank depending on
+item's priority (=[#A]=, =[#B]=, =[#C]=, etc) and overdue time to
+order agenda items (see "11.4.3 Sorting of agenda items" section of
+Org manual).
+
+Now, this composite rank is renamed to =urgency= and the relevant
+sorting strategies are renamed to ~urgency-up~ and ~urgency-down~.
+~priority-up~ and ~priority-down~ sort by item's priority only.
+
+Users relying on the previous composite ranking should adjust their
+agenda sorting settings.
+
 *** =python-mode.el (MELPA)= support in =ob-python.el= is removed
 
 =python-mode.el= support has been removed from =ob-python.el=.  The
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 892d88a77..263f242d4 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -85,7 +85,7 @@ (declare-function org-habit-insert-consistency-graphs
 		  "org-habit" (&optional line))
 (declare-function org-is-habit-p "org-habit" (&optional pom))
 (declare-function org-habit-parse-todo "org-habit" (&optional pom))
-(declare-function org-habit-get-priority "org-habit" (habit &optional moment))
+(declare-function org-habit-get-urgency "org-habit" (habit &optional moment))
 (declare-function org-agenda-columns "org-colview" ())
 (declare-function org-add-archive-files "org-archive" (files))
 (declare-function org-capture "org-capture" (&optional goto keys))
@@ -267,6 +267,7 @@ (defconst org-sorting-choice
     (const category-keep) (const category-up) (const category-down)
     (const tag-down) (const tag-up)
     (const priority-up) (const priority-down)
+    (const urgency-up) (const urgency-down)
     (const todo-state-up) (const todo-state-down)
     (const effort-up) (const effort-down)
     (const habit-up) (const habit-down)
@@ -1617,9 +1618,9 @@ (defgroup org-agenda-sorting nil
   :group 'org-agenda)
 
 (defcustom org-agenda-sorting-strategy
-  '((agenda habit-down time-up priority-down category-keep)
-    (todo   priority-down category-keep)
-    (tags   priority-down category-keep)
+  '((agenda habit-down time-up urgency-down category-keep)
+    (todo   urgency-down category-keep)
+    (tags   urgency-down category-keep)
     (search category-keep))
   "Sorting structure for the agenda items of a single day.
 This is a list of symbols which will be used in sequence to determine
@@ -1646,6 +1647,12 @@ (defcustom org-agenda-sorting-strategy
 tag-down           Sort alphabetically by last tag, Z-A.
 priority-up        Sort numerically by priority, high priority last.
 priority-down      Sort numerically by priority, high priority first.
+urgency-up         Sort numerically by urgency, high urgency last.
+                   Urgency is calculated based on item's priority,
+                   and proximity to scheduled time and deadline.  See
+                   info node `(org)Sorting of agenda items' for
+                   details.
+urgency-down       Sort numerically by urgency, high urgency first.
 todo-state-up      Sort by todo state, tasks that are done last.
 todo-state-down    Sort by todo state, tasks that are done first.
 effort-up          Sort numerically by estimated effort, high effort last.
@@ -4884,6 +4891,7 @@ (defun org-search-view (&optional todo-only string edit-at)
 			  'org-todo-regexp org-todo-regexp
 			  'level level
 			  'org-complex-heading-regexp org-complex-heading-regexp
+                          'urgency 1000
 			  'priority 1000
 			  'type "search")
 			(push txt ee)
@@ -5640,7 +5648,7 @@ (defun org-agenda-get-todos ()
 					      "\\|")
 				   "\\)"))
 			  (t org-not-done-regexp))))
-	 marker priority category level tags todo-state
+	 marker priority urgency category level tags todo-state
 	 ts-date ts-date-type ts-date-pair
 	 ee txt beg end inherited-tags todo-state-end-pos
          effort effort-minutes)
@@ -5678,15 +5686,18 @@ (defun org-agenda-get-todos ()
 			   (memq 'todo org-agenda-use-tag-inheritance))))
 	      tags (org-get-tags nil (not inherited-tags))
 	      level (make-string (org-reduced-level (org-outline-level)) ? )
-	      txt (org-agenda-format-item ""
-                                (org-add-props txt nil
-                                  'effort effort
-                                  'effort-minutes effort-minutes)
-                                level category tags t)
-	      priority (1+ (org-get-priority txt)))
+	      txt (org-agenda-format-item
+                   ""
+                   (org-add-props txt nil
+                     'effort effort
+                     'effort-minutes effort-minutes)
+                   level category tags t)
+              urgency (1+ (org-get-priority txt))
+	      priority (org-get-priority txt))
 	(org-add-props txt props
 	  'org-marker marker 'org-hd-marker marker
 	  'priority priority
+          'urgency urgency
           'effort effort 'effort-minutes effort-minutes
 	  'level level
 	  'ts-date ts-date
@@ -5916,9 +5927,10 @@ (defun org-agenda-get-timestamps (&optional deadlines)
                        'effort-minutes effort-minutes)
                      level category tags time-stamp org-ts-regexp habit?)))
 	      (org-add-props item props
-		'priority (if habit?
-			      (org-habit-get-priority (org-habit-parse-todo))
-			    (org-get-priority item))
+		'urgency (if habit?
+ 			     (org-habit-get-urgency (org-habit-parse-todo))
+			   (org-get-priority item))
+                'priority (org-get-priority item)
 		'org-marker (org-agenda-new-marker pos)
 		'org-hd-marker (org-agenda-new-marker)
 		'date date
@@ -6172,7 +6184,7 @@ (defun org-agenda-get-progress ()
 	  (setq priority 100000)
 	  (org-add-props txt props
 	    'org-marker marker 'org-hd-marker hdmarker 'face 'org-agenda-done
-	    'priority priority 'level level
+	    'urgency priority 'priority priority 'level level
             'effort effort 'effort-minutes effort-minutes
 	    'type type 'date date
 	    'undone-face 'org-warning 'done-face 'org-agenda-done)
@@ -6473,13 +6485,14 @@ (defun org-agenda-get-deadlines (&optional with-hour)
 		       'level level
                        'effort effort 'effort-minutes effort-minutes
 		       'ts-date deadline
-		       'priority
-		       ;; Adjust priority to today reminders about deadlines.
-		       ;; Overdue deadlines get the highest priority
+		       'urgency
+		       ;; Adjust urgency to today reminders about deadlines.
+		       ;; Overdue deadlines get the highest urgency
 		       ;; increase, then imminent deadlines and eventually
 		       ;; more distant deadlines.
 		       (let ((adjust (if today? (- diff) 0)))
 		         (+ adjust (org-get-priority item)))
+                       'priority (org-get-priority item)
 		       'todo-state todo-state
 		       'type (if upcoming? "upcoming-deadline" "deadline")
 		       'date (if upcoming? date deadline)
@@ -6615,13 +6628,14 @@ (defun org-agenda-get-deadlines (&optional with-hour)
 		  'level level
                   'effort effort 'effort-minutes effort-minutes
 		  'ts-date deadline
-		  'priority
-		  ;; Adjust priority to today reminders about deadlines.
-		  ;; Overdue deadlines get the highest priority
+		  'urgency
+		  ;; Adjust urgency to today reminders about deadlines.
+		  ;; Overdue deadlines get the highest urgency
 		  ;; increase, then imminent deadlines and eventually
 		  ;; more distant deadlines.
 		  (let ((adjust (if today? (- diff) 0)))
 		    (+ adjust (org-get-priority item)))
+                  'priority (org-get-priority item)
 		  'todo-state todo-state
 		  'type (if upcoming? "upcoming-deadline" "deadline")
 		  'date (if upcoming? date deadline)
@@ -6871,8 +6885,9 @@ (defun org-agenda-get-scheduled (&optional deadlines with-hour)
 		       'warntime warntime
 		       'level level
                        'effort effort 'effort-minutes effort-minutes
-		       'priority (if habitp (org-habit-get-priority habitp)
-			           (+ 99 diff (org-get-priority item)))
+		       'urgency (if habitp (org-habit-get-urgency habitp)
+			          (+ 99 diff (org-get-priority item)))
+                       'priority (org-get-priority item)
 		       'org-habit-p habitp
 		       'todo-state todo-state)
 	             (push item scheduled-items)))))))
@@ -7056,8 +7071,9 @@ (defun org-agenda-get-scheduled (&optional deadlines with-hour)
 		  'warntime warntime
 		  'level level
                   'effort effort 'effort-minutes effort-minutes
-		  'priority (if habitp (org-habit-get-priority habitp)
-			      (+ 99 diff (org-get-priority item)))
+		  'urgency (if habitp (org-habit-get-urgency habitp)
+			     (+ 99 diff (org-get-priority item)))
+                  'priority (org-get-priority item)
 		  'org-habit-p habitp
 		  'todo-state todo-state)
 	        (push item scheduled-items)))))))
@@ -7169,6 +7185,7 @@ (defun org-agenda-get-blocks ()
 		'level level
                 'effort effort 'effort-minutes effort-minutes
 		'todo-state todo-state
+                'urgency (org-get-priority txt)
 		'priority (org-get-priority txt))
 	      (push txt ee))))
 	(goto-char pos)))
@@ -7530,7 +7547,7 @@ (defun org-set-sorting-strategy (key)
             org-agenda-sorting-strategy
 	  (or (cdr (assq key org-agenda-sorting-strategy))
 	      (cdr (assq 'agenda org-agenda-sorting-strategy))
-	      '(time-up category-keep priority-down)))))
+	      '(time-up category-keep urgency-down)))))
 
 (defun org-get-time-of-day (s &optional string)
   "Check string S for a time of day.
@@ -7877,6 +7894,9 @@ (defun org-entries-lessp (a b)
 	 (priority-up     (and (org-em 'priority-up 'priority-down ss)
 			       (org-cmp-values a b 'priority)))
 	 (priority-down   (if priority-up (- priority-up) nil))
+	 (urgency-up     (and (org-em 'urgency-up 'urgency-down ss)
+			      (org-cmp-values a b 'urgency)))
+	 (urgency-down   (if urgency-up (- urgency-up) nil))
 	 (effort-up       (and (org-em 'effort-up 'effort-down ss)
 			       (org-cmp-effort a b)))
 	 (effort-down     (if effort-up (- effort-up) nil))
diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index c47a4e8c2..5620f038b 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -387,6 +387,8 @@ (define-obsolete-function-alias 'org-pop-to-buffer-same-window 'pop-to-buffer-sa
 (define-obsolete-function-alias 'org-string-match-p 'string-match-p "9.0")
 
 ;;;; Functions and variables from previous releases now obsolete.
+(define-obsolete-function-alias 'org-habit-get-priority
+  'org-habit-get-urgency "Org 9.7")
 (define-obsolete-function-alias 'org-timestamp-format
   'org-format-timestamp "Org 9.6")
 (define-obsolete-variable-alias 'org-export-before-processing-hook
diff --git a/lisp/org-habit.el b/lisp/org-habit.el
index fb6a48b5f..ea935fe7c 100644
--- a/lisp/org-habit.el
+++ b/lisp/org-habit.el
@@ -263,8 +263,8 @@ (defsubst org-habit-done-dates (habit)
 (defsubst org-habit-repeat-type (habit)
   (nth 5 habit))
 
-(defsubst org-habit-get-priority (habit &optional moment)
-  "Determine the relative priority of a habit.
+(defsubst org-habit-get-urgency (habit &optional moment)
+  "Determine the relative urgency of a habit.
 This must take into account not just urgency, but consistency as well."
   (let ((pri 1000)
 	(now (if moment (time-to-days moment) (org-today)))
-- 
2.39.1


[-- Attachment #3: Type: text/plain, Size: 224 bytes --]


-- 
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>

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

* 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/)]
  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-04-06  9:44       ` Ihor Radchenko
  1 sibling, 2 replies; 13+ messages in thread
From: Samuel Wales @ 2023-03-24  3:54 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Jonas Olofsson, emacs-orgmode

thank you for that.  surely now fewer users will be confused.

i find that when 2 things are being conflated, whether in software or
in anything else, it is useful to change the name of both of them for
maximum clarity, future git searches, etc.

thus, perhaps i would suggest somthign like this slight tweak instead.

  priority-cookie-up
  priority-cookie-and-planning-urgency-up

if not too verbose.  reasoning: urgency is occasionally considered
orthogonal to priority in some philosophies, and some users have
:urgent: tags.  so this might eliminate slightly more confusion in
principle.


On 3/23/23, Ihor Radchenko <yantar92@posteo.net> wrote:
> Samuel Wales <samologist@gmail.com> writes:
>
>> perhaps we could have 2 names: one for the priority cookie setting and
>> one for whatever the agenda does.
>
> This is a good idea. Thanks!
>
> See the attached fix making use of Samuel's suggestion.
>
>


-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com


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

* 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/)]
  2023-03-24  3:54       ` Samuel Wales
@ 2023-03-24  3:56         ` Samuel Wales
  2023-03-24 11:45         ` Ihor Radchenko
  1 sibling, 0 replies; 13+ messages in thread
From: Samuel Wales @ 2023-03-24  3:56 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Jonas Olofsson, emacs-orgmode

[feel free to ignore those suggestions as surely there are better
alterntives, and urgency is still good.]

On 3/23/23, Samuel Wales <samologist@gmail.com> wrote:
> thank you for that.  surely now fewer users will be confused.
>
> i find that when 2 things are being conflated, whether in software or
> in anything else, it is useful to change the name of both of them for
> maximum clarity, future git searches, etc.
>
> thus, perhaps i would suggest somthign like this slight tweak instead.
>
>   priority-cookie-up
>   priority-cookie-and-planning-urgency-up
>
> if not too verbose.  reasoning: urgency is occasionally considered
> orthogonal to priority in some philosophies, and some users have
> :urgent: tags.  so this might eliminate slightly more confusion in
> principle.
>
>
> On 3/23/23, Ihor Radchenko <yantar92@posteo.net> wrote:
>> Samuel Wales <samologist@gmail.com> writes:
>>
>>> perhaps we could have 2 names: one for the priority cookie setting and
>>> one for whatever the agenda does.
>>
>> This is a good idea. Thanks!
>>
>> See the attached fix making use of Samuel's suggestion.
>>
>>
>
>
> --
> The Kafka Pandemic
>
> A blog about science, health, human rights, and misopathy:
> https://thekafkapandemic.blogspot.com
>


-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com


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

* 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/)]
  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
  1 sibling, 1 reply; 13+ messages in thread
From: Ihor Radchenko @ 2023-03-24 11:45 UTC (permalink / raw)
  To: Samuel Wales; +Cc: Jonas Olofsson, emacs-orgmode

Samuel Wales <samologist@gmail.com> writes:

> i find that when 2 things are being conflated, whether in software or
> in anything else, it is useful to change the name of both of them for
> maximum clarity, future git searches, etc.
>
> thus, perhaps i would suggest somthign like this slight tweak instead.
>
>   priority-cookie-up
>   priority-cookie-and-planning-urgency-up

I do not like the idea of changing both the names. The current change
will ensure that existing uses of "priority-up"/"priority-down" sorting
strategies won't be affected too much. Forcing every Org user who
customized agenda sorting to change the variable values is not
acceptable.

Note that the patch, despite changing the actual meaning of
priority-up/down, makes it more conforming with
`org-agenda-sorting-strategy' docstring. So, this change is, in fact,
safe.

> if not too verbose.  reasoning: urgency is occasionally considered
> orthogonal to priority in some philosophies, and some users have
> :urgent: tags.  so this might eliminate slightly more confusion in
> principle.

I am neutral wrt "urgency" term. We can use some other.

I do not like the verbosity. Even something like
"priority-and-urgency-up/down" sounds awkward, IMHO.

-- 
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>


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

* 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/)]
  2023-03-24 11:45         ` Ihor Radchenko
@ 2023-03-25  5:59           ` Samuel Wales
  2023-04-02  9:47             ` Ihor Radchenko
  0 siblings, 1 reply; 13+ messages in thread
From: Samuel Wales @ 2023-03-25  5:59 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Jonas Olofsson, emacs-orgmode

it is all ok with me, but not everybody has personal test cases for
sorting sequence, and soembvody might get bitten by a subtle change
like this which pop up every once in a while.  thus the conflated
thing -> 2 names.  the old one could be deprecated or so, i was
thinking.  i get your points though and didn't realize about the
docstroing.  i have no strong opinion on this; just wanted the idea of
disambiguating out there.  as long as 2 things are not conflated
that's good.


On 3/24/23, Ihor Radchenko <yantar92@posteo.net> wrote:
> Samuel Wales <samologist@gmail.com> writes:
>
>> i find that when 2 things are being conflated, whether in software or
>> in anything else, it is useful to change the name of both of them for
>> maximum clarity, future git searches, etc.
>>
>> thus, perhaps i would suggest somthign like this slight tweak instead.
>>
>>   priority-cookie-up
>>   priority-cookie-and-planning-urgency-up
>
> I do not like the idea of changing both the names. The current change
> will ensure that existing uses of "priority-up"/"priority-down" sorting
> strategies won't be affected too much. Forcing every Org user who
> customized agenda sorting to change the variable values is not
> acceptable.
>
> Note that the patch, despite changing the actual meaning of
> priority-up/down, makes it more conforming with
> `org-agenda-sorting-strategy' docstring. So, this change is, in fact,
> safe.
>
>> if not too verbose.  reasoning: urgency is occasionally considered
>> orthogonal to priority in some philosophies, and some users have
>> :urgent: tags.  so this might eliminate slightly more confusion in
>> principle.
>
> I am neutral wrt "urgency" term. We can use some other.
>
> I do not like the verbosity. Even something like
> "priority-and-urgency-up/down" sounds awkward, IMHO.
>
> --
> 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>
>


-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com


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

* 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/)]
  2023-03-25  5:59           ` Samuel Wales
@ 2023-04-02  9:47             ` Ihor Radchenko
  2023-04-03  0:30               ` Samuel Wales
  0 siblings, 1 reply; 13+ messages in thread
From: Ihor Radchenko @ 2023-04-02  9:47 UTC (permalink / raw)
  To: Samuel Wales; +Cc: Jonas Olofsson, emacs-orgmode

Samuel Wales <samologist@gmail.com> writes:

> it is all ok with me, but not everybody has personal test cases for
> sorting sequence, and soembvody might get bitten by a subtle change
> like this which pop up every once in a while.

What you are describing is https://xkcd.com/1172/
We have no obligation to preserve backwards compatibility for people
relying on bugs.

Since the documentation previously told users that
priority-up/priority-down sort by priority, we have no obligation to
care about the fact that Org did not behave as described.

We just need to preserve the default agenda behaviour described in the
manual, which my patch does.

-- 
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>


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

* 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/)]
  2023-04-02  9:47             ` Ihor Radchenko
@ 2023-04-03  0:30               ` Samuel Wales
  2023-04-03  8:59                 ` Ihor Radchenko
  0 siblings, 1 reply; 13+ messages in thread
From: Samuel Wales @ 2023-04-03  0:30 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Jonas Olofsson, emacs-orgmode

i was not intending to talk about that xkcd.  there has been confusion
about 2 definitions of priority, and your urgent will likely help.  if
the docs referred to priority cookies, your argument is good.  i did
not think every reference did incl code.


On 4/2/23, Ihor Radchenko <yantar92@posteo.net> wrote:
> Samuel Wales <samologist@gmail.com> writes:
>
>> it is all ok with me, but not everybody has personal test cases for
>> sorting sequence, and soembvody might get bitten by a subtle change
>> like this which pop up every once in a while.
>
> What you are describing is https://xkcd.com/1172/
> We have no obligation to preserve backwards compatibility for people
> relying on bugs.
>
> Since the documentation previously told users that
> priority-up/priority-down sort by priority, we have no obligation to
> care about the fact that Org did not behave as described.
>
> We just need to preserve the default agenda behaviour described in the
> manual, which my patch does.
>
> --
> 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>
>


-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com


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

* 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/)]
  2023-04-03  0:30               ` Samuel Wales
@ 2023-04-03  8:59                 ` Ihor Radchenko
  0 siblings, 0 replies; 13+ messages in thread
From: Ihor Radchenko @ 2023-04-03  8:59 UTC (permalink / raw)
  To: Samuel Wales; +Cc: Jonas Olofsson, emacs-orgmode

Samuel Wales <samologist@gmail.com> writes:

> i was not intending to talk about that xkcd.  there has been confusion
> about 2 definitions of priority, and your urgent will likely help.  if
> the docs referred to priority cookies, your argument is good.  i did
> not think every reference did incl code.

Well. I am pretty sure that the docstring in org-agenda was talking
about agenda-specific priorities. However, it was against Org's
terminology even 15 years ago - the earliest time I can track the
discussed docstring and manual entry in Git history. Now and earlier,
Org manual introduced priorities as [#A]-[#C] basically everywhere with
a single exception: when talking about agenda default sorting

    "Within each category, items are sorted by priority
    (@pxref{Priorities}), which is composed of the base priority (2000 for
    priority @samp{A}, 1000 for @samp{B}, and 0 for @samp{C}), plus
    additional increments for overdue scheduled or deadline items."

Notably, no reference has been ever made to this statement in the manual
from `org-agenda-sorting-strategy' docstring.

So, the terminology here has been confusing since forever and the only
clue about agenda special treatment of "priority" term has been in the
manual, not even linked to `org-agenda-sorting-strategy',- only to the
"default order" of agenda sorting.

My patch does not affect the default agenda sorting, so the previous
manual's claim is not contradicted. My commit also solves the
terminology confusion. Thus, I observe no regression and see not why we
should not be free to adjust how agenda treats 'priority-up/down in
`org-agenda-sorting-strategy'.

-- 
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>


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

* 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/)]
  2023-03-23 11:28     ` Ihor Radchenko
  2023-03-24  3:54       ` Samuel Wales
@ 2023-04-06  9:44       ` Ihor Radchenko
  2023-04-06 23:37         ` Samuel Wales
  1 sibling, 1 reply; 13+ messages in thread
From: Ihor Radchenko @ 2023-04-06  9:44 UTC (permalink / raw)
  To: Samuel Wales; +Cc: Jonas Olofsson, emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

> See the attached fix making use of Samuel's suggestion.

Applied, onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=8fab6eeef
Fixed.

-- 
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>


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

* 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/)]
  2023-04-06  9:44       ` Ihor Radchenko
@ 2023-04-06 23:37         ` Samuel Wales
  0 siblings, 0 replies; 13+ messages in thread
From: Samuel Wales @ 2023-04-06 23:37 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Jonas Olofsson, emacs-orgmode

thank you.

On 4/6/23, Ihor Radchenko <yantar92@posteo.net> wrote:
> Ihor Radchenko <yantar92@posteo.net> writes:
>
>> See the attached fix making use of Samuel's suggestion.
>
> Applied, onto main.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=8fab6eeef
> Fixed.
>
> --
> 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>
>


-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com


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

end of thread, other threads:[~2023-04-06 23:39 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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.