From b2abdfb95a61f9d694bf66e94121d6c5d245d4fa Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Thu, 24 Jan 2013 14:16:11 +0100 Subject: [PATCH] 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. --- lisp/org-agenda.el | 22 +++++++++++----------- lisp/org-faces.el | 8 ++++++++ lisp/org.el | 4 ++-- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 1d58b6946..5ff6b22d5 100644 --- a/lisp/org-agenda.el +++ b/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) diff --git a/lisp/org-faces.el b/lisp/org-faces.el index 606db0814..de5a08c40 100644 --- a/lisp/org-faces.el +++ b/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 diff --git a/lisp/org.el b/lisp/org.el index 45842d5bd..5bebb5f03 100644 --- a/lisp/org.el +++ b/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)