From: Tommy Jollyboat <[email protected]>
To: [email protected]
Subject: [BUG] Numeric priorities only partially supported
Date: Sun, 13 Oct 2024 17:02:04 +0100 [thread overview]
Message-ID: <CANDZv_N394TYMy30-KuEQV+eZ0FEkm4GSjTrkUtDViK_-DkX-Q@mail.gmail.com> (raw)
(tested with Org 9.7.11, I've done my best to search archives and the
bug-tracker)
Back in 2020, commit #4f98694bf introduced numeric priorities,
allowing [#1] to [#64] as an alternative to [#A] to [#Z]. This is also
documented in the manual.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=4f98694bf
https://orgmode.org/manual/Priorities.html
It introduced the new function ~org-priority-to-value~, which replaces
~string-to-char~ for parsing priority strings. It parses numeric prios
as ints (1..64) and alphabetic prios as chars (?A..?Z, which is
65-90).
* PROBLEM
However, various functions within org-mode are still using
~string-to-char~ and giving inconsistent results, because numerical
priorities are parsed wrongly, or sometimes return nil (or #10 to
#64).
* EXAMPLES
With the following heading tree:
* test tree
** [#10] ten
** [#2] two
You can get the correct values 10 and 2 with: (org-priority-to-value
(thing-at-point 'line))
You can get incorrect values nil and ?2 with: (org-element-property
:priority (org-element-at-point)) or (nth 3 (org-heading-components))
And if you sort the test tree by priority (with org-sort-entries,
"p"), it won't change, because [#10] is wrongly interpreted as if it
were [#1].
* SOLUTION
If we agree that numeric priorities should be supported everywhere,
various functions need updating:
Functions that use string-to-char to parse:
- org-entry-put
- org-mobile-edit (in org-mobile.el)
- org-agenda-fontify-priorities (org-agenda.el)
- org-mouse-context-menu (org-mouse.el)
I've confirmed that org-entry-put exhibits wrong behaviour (parsing
1-9 as ?1-?9 and 10-64 as nil). I'm not familiar with the others, as
they're in modules I don't use.
The Org Element API also needs updating:
- ~org-element--headline-parse-title~ implements its own
org-priority-regexp, which doesn't account for multiple characters
- ~org-entry-put~ has bugs, but I don't understand the code well enough
- A couple of functions format priorities as "[#%c]", and should
include a %s case for values under 65.
These should all be fairly safe/uncontroversial changes to make, as
any documents that are impacted were relying on undefined behavior
(such as using chars outside of the range A-Z as priorities).
Hope that's all clear! Sorry it's a bit of an essay.
next reply other threads:[~2024-10-13 16:03 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-13 16:02 Tommy Jollyboat [this message]
2024-10-13 16:11 ` [BUG] Numeric priorities only partially supported Ihor Radchenko
2025-06-08 14:18 ` Derek Chen-Becker
2025-06-08 16:03 ` Ihor Radchenko
2025-06-17 12:29 ` Derek Chen-Becker
2025-07-10 13:19 ` Derek Chen-Becker
2025-07-12 16:11 ` Ihor Radchenko
2025-07-12 19:27 ` Derek Chen-Becker
2025-07-19 12:56 ` Derek Chen-Becker
2025-07-19 13:22 ` Ihor Radchenko
2025-07-19 13:58 ` Derek Chen-Becker
2025-07-19 14:07 ` Ihor Radchenko
2025-07-19 16:04 ` Derek Chen-Becker
2025-07-19 16:29 ` Ihor Radchenko
2025-07-20 23:32 ` Derek Chen-Becker
2025-07-21 16:53 ` Ihor Radchenko
2025-09-13 11:36 ` Derek Chen-Becker
2025-09-13 14:39 ` Rudolf Adamkovič
2025-09-14 12:43 ` Derek Chen-Becker
2025-09-15 7:12 ` Rudolf Adamkovič
2025-09-27 13:24 ` Ihor Radchenko
2025-09-28 14:20 ` Derek Chen-Becker
2025-09-28 16:12 ` Ihor Radchenko
2025-09-28 16:53 ` Derek Chen-Becker
2025-09-28 18:46 ` Derek Chen-Becker
2025-10-06 4:01 ` Derek Chen-Becker
2025-10-11 12:51 ` Ihor Radchenko
2025-10-28 16:21 ` Derek Chen-Becker
2025-10-29 11:25 ` Derek Chen-Becker
2025-11-02 13:08 ` Ihor Radchenko
2025-11-03 13:59 ` Derek Chen-Becker
2025-11-05 18:52 ` Ihor Radchenko
2025-11-05 19:15 ` Derek Chen-Becker
2025-11-07 2:39 ` Derek Chen-Becker
2025-11-07 5:01 ` Jacob S. Gordon
2025-11-19 5:17 ` Derek Chen-Becker
2025-11-08 11:03 ` Ihor Radchenko
2025-11-10 5:01 ` Derek Chen-Becker
2025-11-10 17:32 ` Ihor Radchenko
2025-11-11 1:19 ` Derek Chen-Becker
2025-11-15 18:13 ` Ihor Radchenko
2025-11-15 21:40 ` Derek Chen-Becker
2025-11-15 21:45 ` Ihor Radchenko
2025-11-15 22:51 ` Derek Chen-Becker
2025-11-16 9:30 ` Ihor Radchenko
2025-11-16 14:55 ` Derek Chen-Becker
2025-11-16 22:26 ` Derek Chen-Becker
2025-11-17 5:53 ` Ihor Radchenko
2025-11-16 23:18 ` Derek Chen-Becker
2025-11-17 5:55 ` Ihor Radchenko
2025-11-19 5:15 ` Derek Chen-Becker
2025-11-22 14:15 ` Ihor Radchenko
2025-11-22 15:07 ` Derek Chen-Becker
2025-11-22 15:32 ` Ihor Radchenko
2025-11-22 16:22 ` Derek Chen-Becker
2025-11-22 16:37 ` Ihor Radchenko
2025-11-22 16:52 ` Derek Chen-Becker
2025-11-22 16:55 ` Ihor Radchenko
2025-11-22 16:56 ` Derek Chen-Becker
2025-11-23 12:45 ` Ihor Radchenko
2025-11-23 14:13 ` Derek Chen-Becker
2025-11-23 14:17 ` Ihor Radchenko
2025-11-23 14:17 ` Derek Chen-Becker
2025-11-23 14:54 ` Derek Chen-Becker
2025-11-23 14:57 ` Ihor Radchenko
2025-11-25 3:22 ` Derek Chen-Becker
2025-11-30 11:55 ` Ihor Radchenko
2025-12-04 5:27 ` Derek Chen-Becker
2025-12-04 8:24 ` Christian Moe
2025-12-04 14:51 ` Derek Chen-Becker
2025-12-04 17:52 ` Ihor Radchenko
2025-12-04 23:40 ` Derek Chen-Becker
2025-12-05 13:05 ` Rudolf Adamkovič
2025-12-05 15:21 ` Derek Chen-Becker
2025-12-05 17:23 ` Christian Moe
2025-12-05 17:31 ` Derek Chen-Becker
2025-12-06 12:16 ` Rudolf Adamkovič
2025-12-06 16:45 ` Derek Chen-Becker
2025-12-06 12:03 ` Rudolf Adamkovič
2025-06-08 20:42 ` Jacob S. Gordon
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=CANDZv_N394TYMy30-KuEQV+eZ0FEkm4GSjTrkUtDViK_-DkX-Q@mail.gmail.com \
[email protected] \
[email protected] \
/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.
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).