Browse Source

New face `org-priority'. Enhance fontification of priority cookies in agenda.

* org-faces.el (org-priority): New face.

* org.el (org-font-lock-add-priority-faces): Use the new face.

* org-agenda.el (org-agenda-fontify-priorities): Use the
org-priority face and add specific agenda face on top of it.
Bastien Guerry 5 years ago
parent
commit
b2abdfb95a
3 changed files with 21 additions and 13 deletions
  1. 11 11
      lisp/org-agenda.el
  2. 8 0
      lisp/org-faces.el
  3. 2 2
      lisp/org.el

+ 11 - 11
lisp/org-agenda.el

@@ -3673,8 +3673,7 @@ generating a new one."
 			(delete-overlay o)))
 	(overlays-in (point-min) (point-max)))
   (save-excursion
-    (let ((inhibit-read-only t)
-	  b e p ov h l)
+    (let (b e p ov h l)
       (goto-char (point-min))
       (while (re-search-forward "\\[#\\(.\\)\\]" nil t)
 	(setq h (or (get-char-property (point) 'org-highest-priority)
@@ -3689,15 +3688,16 @@ generating a new one."
 	      ov (make-overlay b e))
 	(overlay-put
 	 ov 'face
-	 (cond ((org-face-from-face-or-color
-		 'priority nil
-		 (cdr (assoc p org-priority-faces))))
-	       ((and (listp org-agenda-fontify-priorities)
-		     (org-face-from-face-or-color
-		      'priority nil
-		      (cdr (assoc p org-agenda-fontify-priorities)))))
-	       ((equal p l) 'italic)
-	       ((equal p h) 'bold)))
+	 (cons (cond ((org-face-from-face-or-color
+		       'priority nil
+		       (cdr (assoc p org-priority-faces))))
+		     ((and (listp org-agenda-fontify-priorities)
+			   (org-face-from-face-or-color
+			    'priority nil
+			    (cdr (assoc p org-agenda-fontify-priorities)))))
+		     ((equal p l) 'italic)
+		     ((equal p h) 'bold))
+	       'org-priority))
 	(overlay-put ov 'org-type 'org-priority)))))
 
 (defun org-agenda-dim-blocked-tasks (&optional invisible)

+ 8 - 0
lisp/org-faces.el

@@ -394,6 +394,14 @@ determines if it is a foreground or a background color."
 		   (string :tag "Color")
 		   (sexp :tag "Face")))))
 
+(defface org-priority ;; originally copied from font-lock-string-face
+  (org-compatible-face 'font-lock-keyword-face
+    '((((class color) (min-colors 16) (background light)) (:foreground "RosyBrown"))
+      (((class color) (min-colors 16) (background dark)) (:foreground "LightSalmon"))
+      (t (:italic t))))
+  "Face used for priority cookies."
+  :group 'org-faces)
+
 (defcustom org-priority-faces nil
   "Faces for specific Priorities.
 This is a list of cons cells, with priority character in the car

+ 2 - 2
lisp/org.el

@@ -6128,10 +6128,10 @@ When FACE-OR-COLOR is not a string, just return it."
       (add-text-properties
        (match-beginning 0) (match-end 0)
        (list 'face (or (org-face-from-face-or-color
-			'priority 'org-special-keyword
+			'priority 'org-priority
 			(cdr (assoc (char-after (match-beginning 1))
 				    org-priority-faces)))
-		       'org-special-keyword)
+		       'org-priority)
 	     'font-lock-fontified t)))))
 
 (defun org-get-tag-face (kwd)