org-priority: Fix SPC handling for numeric priorities (bug#52341)

* lisp/org.el (org-priority): When reading numeric priorities, provide
special handling of SPC so that it clears the priority, as advertised.

If the user has configured numeric priorities and tries to clear a
priority by inputting SPC at the prompt, org-priority feeds " " to
string-to-number and ends up with 0 instead of the ?\s (32) that's
used downstream to signal "remove".  Explicitly check for " " and
translate it to ?\s.

Reported-by: "Bruce E. Robertson" <brucer42@gmail.com>
Link: https://list.orgmode.org/877dch89s1.fsf@kyleam.com/
This commit is contained in:
Kyle Meyer 2021-12-06 20:48:46 -05:00
parent a62da701b4
commit 4aca51fcbe
1 changed files with 8 additions and 7 deletions

View File

@ -11323,13 +11323,14 @@ or a character."
(setq (setq
new new
(if nump (if nump
(let ((msg (format "Priority %s-%s, SPC to remove: " (let* ((msg (format "Priority %s-%s, SPC to remove: "
(number-to-string org-priority-highest) (number-to-string org-priority-highest)
(number-to-string org-priority-lowest)))) (number-to-string org-priority-lowest)))
(if (< 9 org-priority-lowest) (s (if (< 9 org-priority-lowest)
(string-to-number (read-string msg)) (read-string msg)
(message msg) (message msg)
(string-to-number (char-to-string (read-char-exclusive))))) (char-to-string (read-char-exclusive)))))
(if (equal s " ") ?\s (string-to-number s)))
(progn (message "Priority %c-%c, SPC to remove: " (progn (message "Priority %c-%c, SPC to remove: "
org-priority-highest org-priority-lowest) org-priority-highest org-priority-lowest)
(save-match-data (save-match-data