Hello, I submitted a patch a few years ago about the same change which I could not follow-up on because I've been quite busy, however most of the refactoring I had done has already been included in some form or another so this time the feature I'm trying to include is much more straightforward, although it could still lead to the parsing clashes the maintainer mentioned in the original thread:
https://lists.gnu.org/archive/html/emacs-orgmode/2022-10/msg00635.html I'm submitting the new patch here, if it's not acceptable to modify this behavior then I'll provide another one to extract the piece of code I want to modify so I can override it with advice.
From 4206e1cd035b9441ca3ae0060a76947fd5d33441 Mon Sep 17 00:00:00 2001 From: drlkf <[email protected]> Date: Sun, 9 Aug 2026 14:41:39 +0200 Subject: [PATCH] org: allow customizing priority marker --- doc/org-manual.org | 16 ++++++++++++++++ lisp/org.el | 21 ++++++++++++++++++--- testing/lisp/test-org.el | 12 ++++++++++++ 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index 94a3865ef..12b9632e1 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -4678,6 +4678,22 @@ Or, using numeric values: : #+PRIORITIES: 1 10 5 +#+vindex: org-priority-prefix +#+vindex: org-priority-suffix +#+vindex: org-priority-regexp +#+vindex: org-make-priority-regexp +You can set your own style of priority marker using +~org-priority-prefix~, ~org-priority-suffix~ and generate the +appropriate ~org-make-priority-regexp~ for ~org-priority-regexp~: + +#+begin_src elisp +(setq org-priority-prefix "<:" + org-priority-suffers ">" + org-priority-regexp (org-make-priority-regexp)) +#+end_src + +: *** TODO <:1> Customize priority marker + ** Breaking Down Tasks into Subtasks :PROPERTIES: :DESCRIPTION: Splitting a task into manageable pieces. diff --git a/lisp/org.el b/lisp/org.el index 59163e252..ede957c0d 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -123,14 +123,29 @@ sure that we are at the beginning of the line.") "Matches a headline, putting stars and text into groups. Stars are put in group 1 and the trimmed body in group 2.") +(defvar org-priority-prefix "[#" + "Marker preceding value in the priority indicator e.g [# in [#A].") + +(defvar org-priority-suffix "]" + "Marker following value in the priority indicator e.g ] in [#A].") + (defvar org-priority-value-regexp "[A-Z]\\|[0-9]\\|[1-5][0-9]\\|6[0-4]" "Regular expression matching valid priority values. The priority value must be a capital Latin alphabetic character, A through Z, or can be an integer value in the range 0 through 64.") +(defun org-make-priority-regexp () + "Generate a correct `org-priority-regexp' using `org-priority' +variables. Useful after setting custom priority markers or value +regexp." + (format ".*?\\(%s\\(%s\\)%s ?\\)" + (regexp-quote org-priority-prefix) + org-priority-value-regexp + (regexp-quote org-priority-suffix))) + (defvar org-priority-regexp - (format ".*?\\(\\[#\\(%s\\)\\] ?\\)" org-priority-value-regexp) + (org-make-priority-regexp) "Regular expression matching the priority indicator. A priority indicator can be e.g. [#A] or [#1]. The value of the priority cookie must be a capital Latin @@ -11613,9 +11628,9 @@ interactive prompt, it will automatically be converted to uppercase." (if (match-end 2) (progn (goto-char (match-end 2)) - (insert " [#" new-value-string "]")) + (insert " " org-priority-prefix new-value-string org-priority-suffix)) (goto-char (match-beginning 3)) - (insert "[#" new-value-string "] ")))) + (insert org-priority-prefix new-value-string org-priority-suffix " ")))) (when org-auto-align-tags (org-align-tags))) (if remove (message "Priority removed") diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 949e75089..37b9e3cfd 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -10678,12 +10678,24 @@ two (let ((cookie (format "[#%c]" p))) (org-priority-valid-cookie-string-p cookie))) (number-sequence ?A ?Z))) + ;; Test all valid numbers (should (seq-every-p (lambda (p) (let ((cookie (format "[#%d]" p))) (org-priority-valid-cookie-string-p cookie))) (number-sequence 0 64))) + + ;; Test all valid numbers with customized markers + (should + (let* ((org-priority-prefix "_") + (org-priority-suffix "|") + (org-priority-regexp (org-make-priority-regexp))) + (seq-every-p (lambda (p) + (let ((cookie (format "_%d|" p))) + (org-priority-valid-cookie-string-p cookie))) + (number-sequence 0 64)))) + ;; Invalid characters (not exhaustive) (should (not (org-priority-valid-cookie-string-p "[#$]"))) -- 2.47.3
best -- drlkf
signature.asc
Description: PGP signature
