emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Joe Corneli via "General discussions about Org-mode." <emacs-orgmode@gnu.org>
To: emacs-orgmode@gnu.org
Subject: [patch] priorities range reversed
Date: Mon, 09 Aug 2021 14:06:43 +0100	[thread overview]
Message-ID: <87v94ewyvw.fsf@Proteus> (raw)

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

             reply	other threads:[~2021-08-09 13:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-09 13:06 Joe Corneli via General discussions about Org-mode. [this message]
2021-08-09 13:51 ` [patch] priorities range reversed 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v94ewyvw.fsf@Proteus \
    --to=emacs-orgmode@gnu.org \
    --cc=joseph.corneli.orgmode@hyperreal.enterprises \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).