瀏覽代碼

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.
Bastien 5 年之前
父節點
當前提交
7b1077def7
共有 2 個文件被更改,包括 8 次插入8 次删除
  1. 4 4
      lisp/org-agenda.el
  2. 4 4
      lisp/org.el

+ 4 - 4
lisp/org-agenda.el

@@ -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

+ 4 - 4
lisp/org.el

@@ -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)