all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [patch] priorities range reversed
@ 2021-08-09 13:06 Joe Corneli via General discussions about Org-mode.
  2021-08-09 13:51 ` Joe Corneli via General discussions about Org-mode.
  2021-09-26 13:44 ` Bastien
  0 siblings, 2 replies; 5+ messages in thread
From: Joe Corneli via General discussions about Org-mode. @ 2021-08-09 13:06 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 884 bytes --]

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.)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: priorities_reversed.patch --]
[-- Type: text/x-diff, Size: 1001 bytes --]

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

[-- Attachment #3: Type: text/plain, Size: 280 bytes --]



-- 
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).

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-09-29 11:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-09 13:06 [patch] priorities range reversed Joe Corneli via General discussions about Org-mode.
2021-08-09 13:51 ` Joe Corneli via General discussions about Org-mode.
2021-08-31 15:14   ` Timothy
2021-09-26 13:44 ` Bastien
2021-09-29 11:27   ` Bastien Guerry

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.