Tiny enhancements to priority handling

* lisp/org.el (org-font-lock-add-priority-faces): Use
`org-priority-regexp'.
(org-priority-regexp): Match multiple characters.

* lisp/org-agenda.el (org-agenda-fontify-priorities): Use
`org-priority-regexp'.

This commit paves the way for more flexibility in priority handling.
For example, `org-priority-[up/down]' could deal with priorities as
numbers (e.g. [#1]) instead of letters.
This commit is contained in:
Bastien 2020-01-30 12:05:07 +01:00
parent 759c1567b1
commit 7b1077def7
2 changed files with 8 additions and 8 deletions

View File

@ -3958,15 +3958,15 @@ FILTER-ALIST is an alist of filters we need to apply when
(save-excursion
(let (b e p ov h l)
(goto-char (point-min))
(while (re-search-forward "\\[#\\(.\\)\\]" nil t)
(while (re-search-forward org-priority-regexp nil t)
(setq h (or (get-char-property (point) 'org-highest-priority)
org-highest-priority)
l (or (get-char-property (point) 'org-lowest-priority)
org-lowest-priority)
p (string-to-char (match-string 1))
b (match-beginning 0)
p (string-to-char (match-string 2))
b (match-beginning 1)
e (if (eq org-agenda-fontify-priorities 'cookies)
(match-end 0)
(match-end 1)
(point-at-eol))
ov (make-overlay b e))
(overlay-put

View File

@ -5886,9 +5886,11 @@ If TAG is a number, get the corresponding match group."
'tag 'org-tag (cdr (assoc tag org-tag-faces)))
'org-tag)))
(defvar org-priority-regexp) ; defined later in the file
(defun org-font-lock-add-priority-faces (limit)
"Add the special priority faces."
(while (re-search-forward "^\\*+ .*?\\(\\[#\\(.\\)\\]\\)" limit t)
(while (re-search-forward org-priority-regexp limit t)
(add-text-properties
(match-beginning 1) (match-end 1)
(list 'face (org-get-priority-face (string-to-char (match-string 2)))
@ -7966,8 +7968,6 @@ Optional argument WITH-CASE means sort case-sensitively."
(org-link-display-format s)
t t) t t))
(defvar org-priority-regexp) ; defined later in the file
(defvar org-after-sorting-entries-or-items-hook nil
"Hook that is run after a bunch of entries or items have been sorted.
When children are sorted, the cursor is in the parent line when this
@ -11625,7 +11625,7 @@ from the `before-change-functions' in the current buffer."
;;;; Priorities
(defvar org-priority-regexp ".*?\\(\\[#\\([A-Z0-9]\\)\\] ?\\)"
(defvar org-priority-regexp ".*?\\(\\[#\\([A-Z0-9]+\\)\\] ?\\)"
"Regular expression matching the priority indicator.")
(defvar org-remove-priority-next-time nil)