branch: externals/org
commit b19fc7b3b30b437201e05c414dff2a95f31e2899
Author: Jacob S. Gordon <[email protected]>
Commit: Ihor Radchenko <[email protected]>
org-faces: Correct font locking of numeric priorities
* lisp/org-agenda.el (org-agenda-fontify-priorities): Use
`org-priority-to-value' instead of `string-to-char'.
(org-agenda-fontify-priorities):
* lisp/org-faces.el (org-priority-faces): Correct type to an alist and
add non-negative numbers as an option for the key.
* lisp/org.el (org-font-lock-add-priority-faces): Use
`org-priority-to-value' instead of `string-to-char'.
(org-get-priority-face): Generalize doc string.
---
lisp/org-agenda.el | 27 ++++++++++++++-------------
lisp/org-faces.el | 21 ++++++++++++---------
lisp/org.el | 4 ++--
3 files changed, 28 insertions(+), 24 deletions(-)
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index f6ccc1a090..106a0919b7 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -2025,23 +2025,24 @@ When t, the highest priority entries are bold, lowest
priority italic.
However, settings in `org-priority-faces' will overrule these faces.
When this variable is the symbol `cookies', only fontify the
cookies, not the entire task.
-This may also be an association list of priority faces, whose
-keys are the character values of `org-priority-highest',
-`org-priority-default', and `org-priority-lowest' (the default values
-are ?A, ?B, and ?C, respectively). The face may be a named face, a
-color as a string, or a list like `(:background \"Red\")'.
-If it is a color, the variable `org-faces-easy-properties'
-determines if it is a foreground or a background color."
+
+This may also be an association list of priority faces, whose keys are
+priorities and values are faces. The face may be a named face, a color
+as a string, or a list like `(:background \"Red\")'. If it is a color,
+the variable `org-faces-easy-properties' determines if it is a
+foreground or a background color."
:group 'org-agenda-line-format
:type '(choice
(const :tag "Never" nil)
(const :tag "Defaults" t)
(const :tag "Cookies only" cookies)
- (repeat :tag "Specify"
- (list (character :tag "Priority" :value ?A)
- (choice :tag "Face "
- (string :tag "Color")
- (sexp :tag "Face"))))))
+ (alist :tag "Association list"
+ :key-type (choice :tag "Priority"
+ (character :tag "Character" :value ?A)
+ (natnum :tag "Number" :value 1))
+ :value-type (choice :tag "Face "
+ (string :tag "Color")
+ (sexp :tag "Face")))))
(defcustom org-agenda-day-face-function nil
"Function called to determine what face should be used to display a day.
@@ -4129,7 +4130,7 @@ agenda display, configure `org-agenda-finalize-hook'."
org-priority-highest)
l (or (get-char-property (point) 'org-priority-lowest)
org-priority-lowest)
- p (string-to-char (match-string 2))
+ p (org-priority-to-value (match-string 2))
b (match-beginning 1)
e (if (eq org-agenda-fontify-priorities 'cookies)
(1+ (match-end 2))
diff --git a/lisp/org-faces.el b/lisp/org-faces.el
index 85a24b00a5..b0f5ef9d7e 100644
--- a/lisp/org-faces.el
+++ b/lisp/org-faces.el
@@ -325,20 +325,23 @@ determines if it is a foreground or a background color."
(defcustom org-priority-faces nil
"Faces for specific Priorities.
-This is a list of cons cells, with priority character in the car
-and faces in the cdr. The face can be a symbol, a color
-as a string, or a property list of attributes, like
+This is an association list, whose keys are priorities and values are
+faces. The face can be a symbol, a color as a string, or a property
+list of attributes, like
(:foreground \"blue\" :weight bold :underline t).
If it is a color string, the variable `org-faces-easy-properties'
determines if it is a foreground or a background color."
:group 'org-faces
:group 'org-todo
- :type '(repeat
- (cons
- (character :tag "Priority")
- (choice :tag "Face "
- (string :tag "Color")
- (sexp :tag "Face")))))
+ :type '(choice (const :tag "Defaults" nil)
+ (alist :tag "Association list"
+ :key-type
+ (choice :tag "Priority"
+ (character :tag "Character" :value ?A)
+ (natnum :tag "Number" :value 1))
+ :value-type (choice :tag "Face "
+ (string :tag "Color")
+ (sexp :tag "Face")))))
(defvar org-tags-special-faces-re nil)
(defun org-set-tag-faces (var value)
diff --git a/lisp/org.el b/lisp/org.el
index fca3394934..445f0d9ea4 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6291,7 +6291,7 @@ If KWD is a number, get the corresponding match group."
(defun org-get-priority-face (priority)
"Get the right face for PRIORITY.
-PRIORITY is a character."
+PRIORITY is a number from 0-64 or a character value from ?A to ?Z."
(or (org-face-from-face-or-color
'priority 'org-priority (cdr (assq priority org-priority-faces)))
'org-priority))
@@ -6313,7 +6313,7 @@ If TAG is a number, get the corresponding match group."
(end (1+ (match-end 2))))
(add-face-text-property
beg end
- (org-get-priority-face (string-to-char (match-string 2))))
+ (org-get-priority-face (org-priority-to-value (match-string 2))))
(add-text-properties
beg end
(list 'font-lock-fontified t)))))