Derek Chen-Becker <de...@chen-becker.org> writes:

> I guess looking at https://orgmode.org/manual/Priorities.html, it's not
> clearly defined what valid ranges are. Are upper and lower cases considered
> equivalent? Is it strictly A-Z, or a-z, or 1-64? If it's not numeric, do
> we just allow any character whose value is >= 65? For example, 一,二, 三, 四?
> Technically, is 1 the highest possible numeric priority or would zero (or a
> negative number) be valid? I feel like maybe we should update the manual at
> the same time, and precisely specify what the allowed values are. I can
> sort of reverse engineer from the code, but is this documented anywhere
> other than the manual?

Well. You cannot reverse engineer.

1. org-priority-regexp is ".*?\\(\\[#\\([A-Z0-9]+\\)\\] ?\\)"
2. org-element.el is
   (priority (and (looking-at "\\[#.\\][ \t]*")
                            (progn (goto-char (match-end 0))
                                   (aref (match-string 0) 2))))
3. https://orgmode.org/worg/org-syntax.html (following the parser)
   PRIORITY (optional)
   A single alphanumeric character preceded by a hash sign # and
   enclosed within square brackets (e.g. [#A] or [#1]). This is called a
   “priority cookie”.

4. 5.4 Priorities in the manual says, "A", "B", "C", "integers, which
   must all be strictly inferior to 65", "earlier in alphabet" (implying
   some kind of ordered alphabet, but not CJK)

5. org-priority-highest
   If you set org-priority-highest to a numeric value inferior to
   65, Org assumes you want to use digits for the priority cookie.
   If you set it to >=65, Org assumes you want to use alphabetical
   characters.

6. org-priority-get-priority-function is a defcustom, implying that
   priority might be less restrictive

7. (org-element-property :priority (org-element-at-point)) always
   returns a number/character (and must be interpreted back by
   org-element-interpret-data)

8. Some places in the code
   (`org-latex-format-headline-default-function') plainly assume that
   priority is formattable with (format "%c" ...)

I'd say that the simplest approach will be using the most restrictive
definition of priority: either a number between 0-64 or a single
alphabetic character (with code >=65).

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
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 via email to