From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id +NQXL7I3HGRnKQAASxT56A (envelope-from ) for ; Thu, 23 Mar 2023 12:27:46 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 4Dy0LrI3HGQIfQAAauVa8A (envelope-from ) for ; Thu, 23 Mar 2023 12:27:46 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 3E6709288 for ; Thu, 23 Mar 2023 12:27:46 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=o2gOIskr; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1679570866; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=AQ8UeXdVHOawJ+5txM28ejEcVwyh4QMqzmN6vEGzekQ=; b=S9lgYjq3SyaRfQF4CwFs6uFjJRrZvqRQWz8QQkEbw+YGzejrHjUIie/pepee0jpjvr8QiT sdCE/H6HKJbNJa2W4XKjndPwvGjx+iE6lyMdhADlmJFdpJUWCjIESIxXwvb2OJSkDLj+7l sMJyV9WaGB6m56mobeviVvyf7yTAd+r7ryDnPklJUAPFSExPRYeSd/6+IkJCMcrVQh7U+S PCLFnvkc7j/GRIsDSoMclMHs86LwkkR+fExc23lcZfuh2AVsVA3sPf1HKLEPDxFL6AaHbW /HQBu5bupi4EARQOB8xCEN4r3UuS5Ez/KUFgywRFDPee3ZMsQpf1VIejSnwvBw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1679570866; a=rsa-sha256; cv=none; b=XA9Aj8dmYuJ6ZSaWxhJx/ERavBQ3oSA7woZ9OU+yEhxPTuYZLWWuIJT4qBh72al7jnHc4n ZI64edATQpJ5GcoipB8flpVmGjP+3fEOvF0O5wDIYPmU3nD/w1l5Zg5aObVlALtRhTUK7k nCSFPMOvZ5sai4LIZ6tyJBYiFdDH/ElhadnmB0UFnIZD2MelXiheyNbEhNYzJqGlTu91yc lY6PrTOPBQHQD/W50zhF7EA72Mk5m89PUhHHeBGKpWtJ9kGyMI3kvA0gzlgpGUMCt4TrDj aj1TQgr7o83KxUAj58k5ukbkAPvNcU0GJtDSHBJ4SieZTLj3gEjALKKDIWDQHw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=o2gOIskr; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pfJ5p-0002j7-2i; Thu, 23 Mar 2023 07:26:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfJ5l-0002ip-J9 for emacs-orgmode@gnu.org; Thu, 23 Mar 2023 07:26:50 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfJ5i-0000uB-E4 for emacs-orgmode@gnu.org; Thu, 23 Mar 2023 07:26:49 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id B2C2924096C for ; Thu, 23 Mar 2023 12:26:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1679570803; bh=CAiJEtY4BrusPW6/WpP66/SzUct7UwILk7xXloeQbF4=; h=From:To:Cc:Subject:Date:From; b=o2gOIskr2OAALJ1Jc3JrdIIiz9htdoAwAN4MjOip56yiIrgpgO/F5lh74q1788Sjt VseW7eF4Z51nPaol/YUVhh2ro8+dhaub/FQyW/cihDXdDXLGdUtmxz8i3TWR+7Wk9N hSiZIkVEuwoqem/NRHate2lpcRce2wr/zo99cdJzREApx2q1Vb7X5fpd3nDgGoBb7B WsswHrqiFTLoXrPIDM7BB9RNKsC/KHaGIQKtoKtQ4rnz1pgE9A09P4/VH/njrm2vV7 d2oqg/Q/+KgtXDgRe7VAWBIbTHa8fr7hQm2O6GZZYYPXFe0g6VyQlRohSHZlQ9DmLh 22oYx07E6h4/Q== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Pj32V5fNYz9rxP; Thu, 23 Mar 2023 12:26:42 +0100 (CET) From: Ihor Radchenko To: Samuel Wales Cc: Jonas Olofsson , 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/)] In-Reply-To: References: <26396316-1201-4D88-9D81-C87DDDA8885A@apple.com> <874jqdowiz.fsf@localhost> Date: Thu, 23 Mar 2023 11:28:39 +0000 Message-ID: <87ileraeqg.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: X-Migadu-Queue-Id: 3E6709288 X-Spam-Score: -6.56 X-Migadu-Spam-Score: -6.56 X-Migadu-Scanner: scn0.migadu.com List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-TUID: YV8OnU4ULQNB --=-=-= Content-Type: text/plain Samuel Wales 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. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-agenda-Rename-sorting-priority-to-urgency.patch >From d6881c39c91beabdc0bfb29d6dc8a81202a84e40 Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko 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 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 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--