On 2026-02-03 14:47, Derek Chen-Becker wrote:
> Agreed. I'm still fairly new to elisp, so I'm not sure if there's
> already an approach to monadic state.

That’s an interesting way to look at it.  I’m not sure.

> My main concern there is that the formatting functions seem to be
> intended to be generic implementations of common functions that hook
> into the export framework.

IMO modifying them is fine and similar to incrementing counters for
other elements, but let’s hear what Ihor thinks.

> If you have time to look at the org-mouse changes, that would be
> helpful.

Sounds good, attached is a patch series containing:

1. org-mouse: Account for numeric priorities

   Substitute the correct conversion functions.

2. ; org-mouse: Refactor priority menus

   This one makes the local and global context menus consistent w.r.t.
   priorities, i.e., selecting the default when none is set and being
   able to remove them.

3. org-mouse: Separate tag and priority menus

   If you have a lot of tags or priorities having them in the same
   menu is inconvenient.

4. org-mouse: Add actions to priority menus

   This lets you increase, decrease, default, and set priorities.

5. ; org-mouse: Fix schedule and deadline actions
6. ; org-mouse: Correct custom agenda entry actions

   These were already broken.

There’s a couple of lingering issues, and I could use your help with
the first:

+ ‘org-agenda-show-priority’ is long gone, so I tried switching to
  ‘org-priority-show’.  However, it and ‘org-get-priority’ both seem
  to be referring to the urgency-transformed priority instead of the
  value.  Is there some other function I should be using?  I found the
  names confusing.

+ This isn’t limited to priorities, but commands are unhappy when
  called from the agenda, even though they seem to work:

  save-current-buffer: Symbol’s value as variable is void: org-mouse-cmd

I also have some other ‘org-mouse’ enhancements but I’ll submit those
later in another thread.

> The other issue I'm still tracking is with font-locking, although
> when I started looking at that it looked a bit intimidating because
> it's not just simple transforms and I'm not familiar with the font
> locking system.

The regular and agenda priority faces should be fixed by ‘b19fc7b3b’,
but I’ll take another look in case I missed something.

Thanks,

-- 
Jacob S. Gordon
[email protected]
Please don’t send me HTML emails or MS Office/Apple iWork documents.
https://useplaintext.email/#etiquette
https://www.fsf.org/campaigns/opendocument
From 7cb94f11aa0dff1109ffc19ce655936981d8a654 Mon Sep 17 00:00:00 2001
From: "Jacob S. Gordon" <[email protected]>
Date: Tue, 3 Feb 2026 16:20:00 -0500
Subject: [PATCH v1 1/6] org-mouse: Account for numeric priorities

* lisp/org-mouse.el (org-mouse-priority-regexp): Construct with
'org-priority-value-regexp' and amend doc string.
(org-mouse-get-priority): Use 'org-priority-to-string' and correct doc
string.
(org-mouse-priority-list): Start from 'org-priority-highest', use
'org-priority-to-string', and add doc string.
(org-mouse-context-menu): Adjust condition for the local context menu,
and use 'org-priority-to-value' in the global context menu.
---
 lisp/org-mouse.el | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/lisp/org-mouse.el b/lisp/org-mouse.el
index cf303ee96..e23a82409 100644
--- a/lisp/org-mouse.el
+++ b/lisp/org-mouse.el
@@ -377,18 +377,21 @@ (defun org-mouse-set-priority (priority)
   "Set the priority of the current headline to PRIORITY."
   (org-priority priority))
 
-(defvar org-mouse-priority-regexp "\\[#\\([A-Z]\\)\\]"
+(defvar org-mouse-priority-regexp
+  (format "\\[#\\(%s\\)\\]" org-priority-value-regexp)
   "Regular expression matching the priority indicator.
 Differs from `org-priority-regexp' in that it doesn't contain the
-leading `.*?'.")
+leading `.*?' and only matches a group for the priority value.")
 
 (defun org-mouse-get-priority (&optional default)
   "Return the priority of the current headline.
-DEFAULT is returned if no priority is given in the headline."
+If the headline does not contain a priority, return `org-priority-default'
+if DEFAULT is non-nil and nil otherwise."
   (save-excursion
     (if (org-mouse-re-search-line org-mouse-priority-regexp)
 	(match-string 1)
-      (when default (char-to-string org-priority-default)))))
+      (when default
+        (org-priority-to-string org-priority-default)))))
 
 (defun org-mouse-delete-timestamp ()
   "Deletes the current timestamp as well as the preceding keyword.
@@ -409,8 +412,9 @@ (defun org-mouse-looking-at (regexp skipchars &optional movechars)
 	  (> (match-end 0) point))))))
 
 (defun org-mouse-priority-list ()
-  (cl-loop for priority from ?A to org-priority-lowest
-	   collect (char-to-string priority)))
+  "Priorities as strings from `org-priority-highest' to `org-priority-lowest'."
+  (cl-loop for priority from org-priority-highest to org-priority-lowest
+           collect (org-priority-to-string priority)))
 
 (defun org-mouse-todo-menu (state)
   "Create the menu with TODO keywords."
@@ -684,7 +688,7 @@ (defun org-mouse-context-menu (&optional event)
 	 "--"
 	 ["Check Deadlines" org-check-deadlines t]
 	 )))
-     ((org-mouse-looking-at org-mouse-priority-regexp "[]A-Z#") ; priority
+     ((org-mouse-looking-at org-mouse-priority-regexp "[]A-Z0-9#") ; priority
       (popup-menu `(nil ,@(org-mouse-keyword-replace-menu
 			   (org-mouse-priority-list) 1 "Priority %s" t))))
      ((funcall get-context :link)
@@ -803,7 +807,7 @@ (defun org-mouse-context-menu (&optional event)
 	    ,@(org-mouse-keyword-menu
 	       (org-mouse-priority-list)
                (lambda (keyword)
-                 (org-mouse-set-priority (string-to-char keyword)))
+                 (org-mouse-set-priority (org-priority-to-value keyword)))
 	       priority "Priority %s")
 	    "--"
 	    ,@(org-mouse-tag-menu))

base-commit: 54aaaa06eec2485b620a83c323890214d70481f2
-- 
Jacob S. Gordon
[email protected]
Please don’t send me HTML emails or MS Office/Apple iWork documents.
https://useplaintext.email/#etiquette
https://www.fsf.org/campaigns/opendocument

From af61b7eb39c5dd3e14721fb68409c2ce5933fc07 Mon Sep 17 00:00:00 2001
From: "Jacob S. Gordon" <[email protected]>
Date: Tue, 3 Feb 2026 16:21:00 -0500
Subject: [PATCH v1 2/6] ; org-mouse: Refactor priority menus

* lisp/org-mouse.el (org-mouse-priority-menu): Refactor priority
menus into a common function.
(org-mouse-context-menu): Use function in local and global context
menus.
---
 lisp/org-mouse.el | 103 ++++++++++++++++++++++++----------------------
 1 file changed, 54 insertions(+), 49 deletions(-)

diff --git a/lisp/org-mouse.el b/lisp/org-mouse.el
index e23a82409..13692c8f2 100644
--- a/lisp/org-mouse.el
+++ b/lisp/org-mouse.el
@@ -416,6 +416,17 @@ (defun org-mouse-priority-list ()
   (cl-loop for priority from org-priority-highest to org-priority-lowest
            collect (org-priority-to-string priority)))
 
+(defun org-mouse-priority-menu ()
+  "Create the priority menu."
+  (append (org-mouse-keyword-menu
+           (org-mouse-priority-list)
+           (lambda (keyword) (org-mouse-set-priority
+                         (org-priority-to-value keyword)))
+           (org-mouse-get-priority t)
+           "Priority %s")
+          '("--"
+            ["None" (org-priority 'remove) t])))
+
 (defun org-mouse-todo-menu (state)
   "Create the menu with TODO keywords."
   (append
@@ -689,8 +700,7 @@ (defun org-mouse-context-menu (&optional event)
 	 ["Check Deadlines" org-check-deadlines t]
 	 )))
      ((org-mouse-looking-at org-mouse-priority-regexp "[]A-Z0-9#") ; priority
-      (popup-menu `(nil ,@(org-mouse-keyword-replace-menu
-			   (org-mouse-priority-list) 1 "Priority %s" t))))
+      (popup-menu `(nil ,@(org-mouse-priority-menu))))
      ((funcall get-context :link)
       (popup-menu
        '(nil
@@ -800,54 +810,49 @@ (defun org-mouse-context-menu (&optional event)
 	  :style toggle :selected org-table-formula-debug]
 	 )))
      ((and (assq :headline contextlist) (not (eolp)))
-      (let ((priority (org-mouse-get-priority t)))
-	(popup-menu
-	 `("Headline Menu"
-	   ("Tags and Priorities"
-	    ,@(org-mouse-keyword-menu
-	       (org-mouse-priority-list)
-               (lambda (keyword)
-                 (org-mouse-set-priority (org-priority-to-value keyword)))
-	       priority "Priority %s")
-	    "--"
-	    ,@(org-mouse-tag-menu))
-	   ("TODO Status"
-	    ,@(org-mouse-todo-menu (org-get-todo-state)))
-	   ["Show Tags"
-	    (with-current-buffer org-mouse-main-buffer (org-agenda-show-tags))
-	    :visible (not org-mouse-direct)]
-	   ["Show Priority"
-	    (with-current-buffer org-mouse-main-buffer (org-agenda-show-priority))
-	    :visible (not org-mouse-direct)]
-	   ,@(if org-mouse-direct '("--") nil)
-	   ["New Heading" org-mouse-insert-heading :visible org-mouse-direct]
-	   ["Set Deadline"
-	    (progn (org-mouse-end-headline) (insert " ") (org-deadline))
-	    :active (not (save-excursion
-			   (org-mouse-re-search-line org-deadline-regexp)))]
-	   ["Schedule Task"
-	    (progn (org-mouse-end-headline) (insert " ") (org-schedule))
-	    :active (not (save-excursion
-			   (org-mouse-re-search-line org-scheduled-regexp)))]
-	   ["Insert Timestamp"
-	    (progn (org-mouse-end-headline) (insert " ") (org-timestamp nil)) t]
+      (popup-menu
+       `("Headline Menu"
+	 ("Tags and Priorities"
+          ,@(org-mouse-priority-menu)
+	  "--"
+	  ,@(org-mouse-tag-menu))
+	 ("TODO Status"
+	  ,@(org-mouse-todo-menu (org-get-todo-state)))
+	 ["Show Tags"
+	  (with-current-buffer org-mouse-main-buffer (org-agenda-show-tags))
+	  :visible (not org-mouse-direct)]
+	 ["Show Priority"
+	  (with-current-buffer org-mouse-main-buffer (org-agenda-show-priority))
+	  :visible (not org-mouse-direct)]
+	 ,@(if org-mouse-direct '("--") nil)
+	 ["New Heading" org-mouse-insert-heading :visible org-mouse-direct]
+	 ["Set Deadline"
+	  (progn (org-mouse-end-headline) (insert " ") (org-deadline))
+	  :active (not (save-excursion
+			 (org-mouse-re-search-line org-deadline-regexp)))]
+	 ["Schedule Task"
+	  (progn (org-mouse-end-headline) (insert " ") (org-schedule))
+	  :active (not (save-excursion
+			 (org-mouse-re-search-line org-scheduled-regexp)))]
+	 ["Insert Timestamp"
+	  (progn (org-mouse-end-headline) (insert " ") (org-timestamp nil)) t]
 					;	 ["Timestamp (inactive)" org-timestamp-inactive t]
-	   "--"
-	   ["Archive Subtree" org-archive-subtree]
-	   ["Cut Subtree"  org-cut-special]
-	   ["Copy Subtree"  org-copy-special]
-	   ["Paste Subtree"  org-paste-special :visible org-mouse-direct]
-	   ("Sort Children"
-	    ["Alphabetically" (org-sort-entries nil ?a)]
-	    ["Numerically" (org-sort-entries nil ?n)]
-	    ["By Time/Date" (org-sort-entries nil ?t)]
-	    "--"
-	    ["Reverse Alphabetically" (org-sort-entries nil ?A)]
-	    ["Reverse Numerically" (org-sort-entries nil ?N)]
-	    ["Reverse By Time/Date" (org-sort-entries nil ?T)])
-	   "--"
-	   ["Move Trees" org-mouse-move-tree :active nil]
-	   ))))
+	 "--"
+	 ["Archive Subtree" org-archive-subtree]
+	 ["Cut Subtree"  org-cut-special]
+	 ["Copy Subtree"  org-copy-special]
+	 ["Paste Subtree"  org-paste-special :visible org-mouse-direct]
+	 ("Sort Children"
+	  ["Alphabetically" (org-sort-entries nil ?a)]
+	  ["Numerically" (org-sort-entries nil ?n)]
+	  ["By Time/Date" (org-sort-entries nil ?t)]
+	  "--"
+	  ["Reverse Alphabetically" (org-sort-entries nil ?A)]
+	  ["Reverse Numerically" (org-sort-entries nil ?N)]
+	  ["Reverse By Time/Date" (org-sort-entries nil ?T)])
+	 "--"
+	 ["Move Trees" org-mouse-move-tree :active nil]
+	 )))
      (t
       (org-mouse-popup-global-menu)))))
 
-- 
Jacob S. Gordon
[email protected]
Please don’t send me HTML emails or MS Office/Apple iWork documents.
https://useplaintext.email/#etiquette
https://www.fsf.org/campaigns/opendocument

From 494734b5e83bedd8250bb666e2721962b3e1796b Mon Sep 17 00:00:00 2001
From: "Jacob S. Gordon" <[email protected]>
Date: Tue, 3 Feb 2026 16:22:00 -0500
Subject: [PATCH v1 3/6] org-mouse: Separate tag and priority menus

* etc/ORG-NEWS (Important announcements and breaking changes):
Announce change.
* lisp/org-mouse.el (org-mouse-context-menu): Separate tag and
priority entries in the global context menu.
---
 etc/ORG-NEWS      | 5 +++++
 lisp/org-mouse.el | 6 ++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 966eafab4..684f0bfbf 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -174,6 +174,11 @@ Previously, =1=, =2=, and =3= would insert priorities =A=, =B=, and
 insert ~org-priority-highest~, ~org-priority-default~, and
 ~org-priority-lowest~, respectively.
 
+*** ~org-mouse~ tag and priority menus are now separate
+
+The "Tags and Priorities" section of the global context menu is split
+into a "Tags" and a "Priorities" section.
+
 ** New features
 
 # We list the most important features, and the features that may
diff --git a/lisp/org-mouse.el b/lisp/org-mouse.el
index 13692c8f2..a092b1d28 100644
--- a/lisp/org-mouse.el
+++ b/lisp/org-mouse.el
@@ -812,10 +812,8 @@ (defun org-mouse-context-menu (&optional event)
      ((and (assq :headline contextlist) (not (eolp)))
       (popup-menu
        `("Headline Menu"
-	 ("Tags and Priorities"
-          ,@(org-mouse-priority-menu)
-	  "--"
-	  ,@(org-mouse-tag-menu))
+	 ("Tags" ,@(org-mouse-tag-menu))
+	 ("Priorities" ,@(org-mouse-priority-menu))
 	 ("TODO Status"
 	  ,@(org-mouse-todo-menu (org-get-todo-state)))
 	 ["Show Tags"
-- 
Jacob S. Gordon
[email protected]
Please don’t send me HTML emails or MS Office/Apple iWork documents.
https://useplaintext.email/#etiquette
https://www.fsf.org/campaigns/opendocument

From 918879c6248ff914c458c8c5284d1e8681e6cdda Mon Sep 17 00:00:00 2001
From: "Jacob S. Gordon" <[email protected]>
Date: Tue, 3 Feb 2026 16:23:00 -0500
Subject: [PATCH v1 4/6] org-mouse: Add actions to priority menus

* etc/ORG-NEWS (New features): Announce change.
* lisp/org-mouse.el (org-mouse-priority-menu): Add actions.
---
 etc/ORG-NEWS      | 5 +++++
 lisp/org-mouse.el | 6 +++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 684f0bfbf..f8fd406cb 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -297,6 +297,11 @@ Warnings are raised on headlines containing out-of-bounds, invalid
 (e.g., =[#-1]=, =[#AA]=), or malformed (e.g., =[#1=, =[#A=)
 priorities.
 
+*** New actions in the ~org-mouse~ priority menus
+
+Priorities can now be removed, increased, decreased, set to the
+default, and set interactively from the priority context menus.
+
 ** New and changed options
 
 # Changes dealing with changing default values of customizations,
diff --git a/lisp/org-mouse.el b/lisp/org-mouse.el
index a092b1d28..25e42a90c 100644
--- a/lisp/org-mouse.el
+++ b/lisp/org-mouse.el
@@ -425,7 +425,11 @@ (defun org-mouse-priority-menu ()
            (org-mouse-get-priority t)
            "Priority %s")
           '("--"
-            ["None" (org-priority 'remove) t])))
+            ["None" (org-priority 'remove) t]
+            ["Increase" (org-priority-up) t]
+            ["Decrease" (org-priority-down) t]
+            ["Default" (org-priority org-priority-default) t]
+            ["Set..." (org-priority 'set) t])))
 
 (defun org-mouse-todo-menu (state)
   "Create the menu with TODO keywords."
-- 
Jacob S. Gordon
[email protected]
Please don’t send me HTML emails or MS Office/Apple iWork documents.
https://useplaintext.email/#etiquette
https://www.fsf.org/campaigns/opendocument

From 5861067464128f49021008ea28352fd7b24903a6 Mon Sep 17 00:00:00 2001
From: "Jacob S. Gordon" <[email protected]>
Date: Tue, 3 Feb 2026 16:24:00 -0500
Subject: [PATCH v1 5/6] ; org-mouse: Fix schedule and deadline actions

* lisp/org-mouse.el (org-mouse-context-menu): Call 'org-deadline' and
'org-schedule' interactively.
---
 lisp/org-mouse.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org-mouse.el b/lisp/org-mouse.el
index 25e42a90c..05d8f4431 100644
--- a/lisp/org-mouse.el
+++ b/lisp/org-mouse.el
@@ -829,11 +829,11 @@ (defun org-mouse-context-menu (&optional event)
 	 ,@(if org-mouse-direct '("--") nil)
 	 ["New Heading" org-mouse-insert-heading :visible org-mouse-direct]
 	 ["Set Deadline"
-	  (progn (org-mouse-end-headline) (insert " ") (org-deadline))
+	  (call-interactively #'org-deadline)
 	  :active (not (save-excursion
 			 (org-mouse-re-search-line org-deadline-regexp)))]
 	 ["Schedule Task"
-	  (progn (org-mouse-end-headline) (insert " ") (org-schedule))
+	  (call-interactively #'org-schedule)
 	  :active (not (save-excursion
 			 (org-mouse-re-search-line org-scheduled-regexp)))]
 	 ["Insert Timestamp"
-- 
Jacob S. Gordon
[email protected]
Please don’t send me HTML emails or MS Office/Apple iWork documents.
https://useplaintext.email/#etiquette
https://www.fsf.org/campaigns/opendocument

From 36a5673bd57ee1a75c55f45c99645cc4da068afc Mon Sep 17 00:00:00 2001
From: "Jacob S. Gordon" <[email protected]>
Date: Tue, 3 Feb 2026 16:25:00 -0500
Subject: [PATCH v1 6/6] ; org-mouse: Correct custom agenda entry actions

* lisp/org-mouse.el (org-mouse-popup-global-menu): Pass agenda keys as
strings.
---
 lisp/org-mouse.el | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lisp/org-mouse.el b/lisp/org-mouse.el
index 05d8f4431..6ff4132f5 100644
--- a/lisp/org-mouse.el
+++ b/lisp/org-mouse.el
@@ -542,8 +542,7 @@ (defun org-mouse-popup-global-menu ()
      "--"
      ,@(org-mouse-keyword-menu
 	(mapcar #'car org-agenda-custom-commands)
-        (lambda (key)
-	  (org-agenda nil (string-to-char key)))
+        (lambda (key) (org-agenda nil key))
 	nil
         (lambda (key)
           (let ((entry (assoc key org-agenda-custom-commands)))
-- 
Jacob S. Gordon
[email protected]
Please don’t send me HTML emails or MS Office/Apple iWork documents.
https://useplaintext.email/#etiquette
https://www.fsf.org/campaigns/opendocument

Reply via email to