From: Alex Giorev <alex.giorev@gmail.com>
To: emacs-orgmode@gnu.org
Subject: A couple of `org-priority' fixes
Date: Sat, 5 Feb 2022 01:05:32 +0200 [thread overview]
Message-ID: <CAMq3WZghzy5FoiyXY4SwbQhHa8AnOAhKtZHrkCtewGZ60Da2wQ@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 634 bytes --]
I found a couple of problems in org-priority, I think these patches fix
them.
- The first patch is truly minor, it just adds a bit to the docstring
- The problem which prompted the second patch arises when all priorities
are lowercase (you can test this by evaluating (setq org-priority-highest
?a org-priority-lowest ?z org-priority-default ?o) and then trying to set
the priority to some lowercase letter)
- The problem solved by the third patch arises when numerical priorities
are used and 32 is given as the argument, 32 being the character code of
the space character, because that character is used to signal property
removal.
[-- Attachment #1.2: Type: text/html, Size: 694 bytes --]
[-- Attachment #2: 0001-lisp-org.el-Add-remove-action-in-org-priority-docstr.patch --]
[-- Type: text/x-patch, Size: 883 bytes --]
From 4f2b192743e4f8056a1e6682dbffa3d236700b46 Mon Sep 17 00:00:00 2001
From: alexgiorev <alex.giorev@gmail.com>
Date: Sat, 5 Feb 2022 00:33:54 +0200
Subject: [PATCH 1/3] lisp/org.el: Add `remove' action in org-priority
docstring
* lisp/org.el (org-priority): Add `remove' action in org-priority docstring
TINYCHANGE
---
lisp/org.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/org.el b/lisp/org.el
index ef8d460e1..2543498de 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11346,7 +11346,7 @@ When called interactively with a `\\[universal-argument]' prefix,
show the priority in the minibuffer instead of changing it.
When called programmatically, ACTION can be `set', `up', `down',
-or a character."
+`remove', or a character."
(interactive "P")
(when show
;; Deprecation warning inserted for Org 9.2; once enough time has
--
2.25.1
[-- Attachment #3: 0002-lisp-org.el-Remove-upcase-new-in-org-priority.patch --]
[-- Type: text/x-patch, Size: 1648 bytes --]
From 524ee9c37c99019b6e700c98919ebb1bd8fd57c7 Mon Sep 17 00:00:00 2001
From: alexgiorev <alex.giorev@gmail.com>
Date: Sat, 5 Feb 2022 00:43:40 +0200
Subject: [PATCH 2/3] lisp/org.el: Remove (upcase new) in `org-priority'
* lisp/org.el (org-priority): After the new priority is computed,
when checking if it is within the bounds defined by
`org-priority-highest' and `org-priority-lowest', the priority is
upcased, but this leads to an error when all priorities are lowercase
letters.
TINYCHANGE
---
lisp/org.el | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 2543498de..757c306bc 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11391,7 +11391,7 @@ When called programmatically, ACTION can be `set', `up', `down',
(= (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 (< new org-priority-highest) (> new org-priority-lowest))
(user-error
(if nump
"Priority must be between `%s' and `%s'"
@@ -11418,8 +11418,8 @@ When called programmatically, ACTION can be `set', `up', `down',
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 (< new org-priority-highest)
+ (> new org-priority-lowest))
(if (and (memq action '(up down))
(not have) (not (eq last-command this-command)))
;; `new' is from default priority
--
2.25.1
[-- Attachment #4: 0003-lisp-org.el-Fix-priority-32-removing-the-cookie-in-o.patch --]
[-- Type: text/x-patch, Size: 2271 bytes --]
From 5aea96e258b694d25aa9ebc0012f499d09b415b6 Mon Sep 17 00:00:00 2001
From: alexgiorev <alex.giorev@gmail.com>
Date: Sat, 5 Feb 2022 00:50:26 +0200
Subject: [PATCH 3/3] lisp/org.el: Fix priority 32 removing the cookie in
org-priority
* lisp/org.el (org-priority): When numerical priorities are used, and
the caller supplies 32 as the new priority value, the priority cookie
is removed because this is the code point of the space character. This
patch fixes this so that supplying 32 will change the priority to 32.
TINYCHANGE
---
lisp/org.el | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 757c306bc..3ffddff94 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11382,21 +11382,23 @@ When called programmatically, ACTION can be `set', `up', `down',
(read-string msg)
(message msg)
(char-to-string (read-char-exclusive)))))
- (if (equal s " ") ?\s (string-to-number s)))
+ (if (equal s " ")
+ (progn (setq remove t) ?\s)
+ (string-to-number s)))
(progn (message "Priority %c-%c, SPC to remove: "
org-priority-highest org-priority-lowest)
(save-match-data
- (setq new (read-char-exclusive)))))))
+ (setq new (read-char-exclusive)
+ remove (= new ?\s)))))))
(when (and (= (upcase org-priority-highest) org-priority-highest)
(= (upcase org-priority-lowest) org-priority-lowest))
(setq new (upcase new)))
- (cond ((equal new ?\s) (setq remove t))
- ((or (< new org-priority-highest) (> 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))))
+ (when (or (< new org-priority-highest) (> 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)))
((eq action 'up)
(setq new (if have
(1- current) ; normal cycling
--
2.25.1
next reply other threads:[~2022-02-04 23:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-04 23:05 Alex Giorev [this message]
2022-05-01 2:38 ` A couple of `org-priority' fixes Ihor Radchenko
2022-10-19 3:13 ` Ihor Radchenko
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=CAMq3WZghzy5FoiyXY4SwbQhHa8AnOAhKtZHrkCtewGZ60Da2wQ@mail.gmail.com \
--to=alex.giorev@gmail.com \
--cc=emacs-orgmode@gnu.org \
/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).