Sure, but there's the check in the let to set `nump' based on the
highest/lowest priority. I could add that as a condition to the upcase
transform:

      (when (and (= (upcase org-priority-highest) org-priority-highest)
                 (= (upcase org-priority-lowest) org-priority-lowest)
                 (not nump))
        (setq new (upcase new)))

I'm also not clear on why we upcase again when checking the bounds:

((or (< (upcase new) org-priority-highest) (> (upcase new)
org-priority-lowest))

Perhaps I can break out validation of the range into its own function
(easier to test) to avoid conflation with the logic to set/modify.

Cheers,

Derek


On Sat, Jul 19, 2025 at 7:22 AM Ihor Radchenko <yanta...@posteo.net> wrote:

> Derek Chen-Becker <de...@chen-becker.org> writes:
>
> > Just double-checking my understanding of things, but it looks like
> > `org-priority' already handles number inputs, despite the docstring:
> >
> >          ((or (eq action 'set)
> >               (integerp action))
> >           (if (not (eq action 'set))
> >               (setq new action)
>
> > My read of that is that if the argument to `org-priority` is an actual
> > integer (not an integer string), then it uses that integer as the new
> > value. Am I missing something?
>
> 1. (integerp ?a) ; => t and (characterp 30) ;=> t,  so you can never tell
> 2. The code has
>    (and (= (upcase org-priority-highest) org-priority-highest)
>         (= (upcase org-priority-lowest) org-priority-lowest))
>    and, more importantly
>    ((or (< (upcase new) org-priority-highest) (> (upcase new)
> org-priority-lowest))
>                  (user-error
>                   (if nump
>                       "Priority must be between `%s' and `%s'"
>                     "Priority must be between `%c' and `%c'")
>                   org-priority-highest org-priority-lowest))
>    - those only work reliably for priority being not too large number
>    (up to 64). (upcase 1) ; => 1, but (upcase 98) ; => 66. So, handling
>    of numbers is not reliable at best:
>         ;; Numerical priorities are limited to 64, beyond that number,
>         ;; assume the priority cookie is a character.
>
> --
> 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>
>


-- 
+---------------------------------------------------------------+
| Derek Chen-Becker                                             |
| GPG Key available at https://keybase.io/dchenbecker and       |
| https://pgp.mit.edu/pks/lookup?search=derek%40chen-becker.org |
| Fngrprnt: EB8A 6480 F0A3 C8EB C1E7  7F42 AFC5 AFEE 96E4 6ACC  |
+---------------------------------------------------------------+

Reply via email to