emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch] priorities range reversed


From: Joe Corneli
Subject: [patch] priorities range reversed
Date: Mon, 09 Aug 2021 14:06:43 +0100

In the case of numeric priorities [#1] [#9] and so on, there is a test
that is reversed in org.el.  This appears twice with a slight variation.

;; Are we are less than the highest or greater than the lowest?
(or (< (upcase new) org-priority-highest)
    (> (upcase new) org-priority-lowest))

The test is, in itself (and in principle) just fine.  The problem is
that it then triggers an error, which is exactly the opposite of what’s
wanted!

The attached patch reverses the test so that we enter the error case
when the priority is *outside* of the range of acceptable priority tags.

Here’s some test data for reproducing the problem and testing the
solution (with the patch applied).

Evaluate:

(setq org-default-priority 2)
(setq org-highest-priority 9)
(setq org-lowest-priority 1)

* This is a test
(Run M-x org-priority RET on the above line.)

diff --git a/lisp/org.el b/lisp/org.el
index ce68f4692..bd6fd3146 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11337,7 +11337,7 @@ or a character."
                     (= (upcase org-priority-lowest) org-priority-lowest))
            (setq new (upcase new)))
          (cond ((equal new ?\s) (setq remove t))
-               ((or (< (upcase new) org-priority-highest) (> (upcase new) 
org-priority-lowest))
+               ((or (> (upcase new) org-priority-highest) (< (upcase new) 
org-priority-lowest))
                 (user-error
                  (if nump
                      "Priority must be between `%s' and `%s'"
@@ -11364,8 +11364,8 @@ or a character."
                            org-priority-default
                          (1+ org-priority-default))))))
         (t (user-error "Invalid action")))
-       (when (or (< (upcase new) org-priority-highest)
-                 (> (upcase new) org-priority-lowest))
+       (when (or (> (upcase new) org-priority-highest)
+                 (< (upcase new) org-priority-lowest))
          (if (and (memq action '(up down))
                   (not have) (not (eq last-command this-command)))
              ;; `new' is from default priority

-- 
Dr Joseph A. Corneli (https://github.com/holtzermann17)

HYPERREAL ENTERPRISES LTD is a private company limited by shares, incorporated
25th, June 2019 as Company Number 634284 on the Register of Companies for
Scotland (https://beta.companieshouse.gov.uk/company/SC634284).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]