Priorities: Allow specific faces for priority cookies

The variable org-priority-faces can now be used to set special faces
for different priority cookies.

Also, in the agenda, the default is now to fontify only the priority
cookie, not the entire task.  See the variable
`org-agenda-fontify-priorities'.
This commit is contained in:
Carsten Dominik 2009-03-03 12:44:53 +01:00
parent 23d9c79654
commit d3d2b3e835
5 changed files with 63 additions and 8 deletions

View File

@ -193,6 +193,19 @@ of tag/property matches is described.
A new =<div id=content>= is wrapped around the entire page,
everything that is inside =<body>=.
*** Faces for priority cookies can now be set freely
The new variable =org-priority-faces= can be used to set faces
for each priority.
*** In agenda, only priority cookies get the special face
So far, an entire task would get a special face when
=org-agenda-fontify-priorities= was set. Now, the default value
for this variable is the symbol =cookies=, which means that on
the cookie is fontified. Set it to =t= if you want the entire
task headline to be fontified.
* Version 6.23
** Overview

View File

@ -1,5 +1,17 @@
2009-03-03 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-agenda-fontify-priorities): New default value
`cookies'.
(org-agenda-fontify-priorities): Renamed from
org-fontify-priorities.
* org.el (org-set-font-lock-defaults): Call
`org-font-lock-add-priority-faces'.
(org-font-lock-add-priority-faces): New function.
* org-faces.el: (org-set-tag-faces): New option.
(org-priority-faces): New variable.
* org-exp.el (org-export-as-html): Add a "content" div around the
entire content of the body tag.
(org-export-html-get-bibliography): New function.

View File

@ -1069,18 +1069,22 @@ it means that the tags should be flushright to that column. For example,
(if (fboundp 'defvaralias)
(defvaralias 'org-agenda-align-tags-to-column 'org-agenda-tags-column))
(defcustom org-agenda-fontify-priorities t
(defcustom org-agenda-fontify-priorities 'cookies
"Non-nil means, highlight low and high priorities in agenda.
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-highest-priority',
`org-default-priority', and `org-lowest-priority' (the default values
are ?A, ?B, and ?C, respectively). The face may be a names face,
are ?A, ?B, and ?C, respectively). The face may be a named face,
or a list like `(:background \"Red\")'."
: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)
(sexp :tag "face")))))
@ -2282,14 +2286,14 @@ Drawers will be excluded, also the line with scheduling/deadline info."
org-agenda-view-columns-initially)
(org-agenda-columns))
(when org-agenda-fontify-priorities
(org-fontify-priorities))
(org-agenda-fontify-priorities))
(when (and org-agenda-dim-blocked-tasks org-blocker-hook)
(org-agenda-dim-blocked-tasks))
(run-hooks 'org-finalize-agenda-hook)
(setq org-agenda-type (get-text-property (point) 'org-agenda-type))
)))
(defun org-fontify-priorities ()
(defun org-agenda-fontify-priorities ()
"Make highest priority lines bold, and lowest italic."
(interactive)
(mapc (lambda (o) (if (eq (org-overlay-get o 'org-type) 'org-priority)
@ -2305,12 +2309,16 @@ Drawers will be excluded, also the line with scheduling/deadline info."
l (or (get-char-property (point) 'org-lowest-priority)
org-lowest-priority)
p (string-to-char (match-string 1))
b (match-beginning 0) e (point-at-eol)
b (match-beginning 0)
e (if (eq org-agenda-fontify-priorities 'cookies)
(match-end 0)
(point-at-eol))
ov (org-make-overlay b e))
(org-overlay-put
ov 'face
(cond ((listp org-agenda-fontify-priorities)
(cdr (assoc p org-agenda-fontify-priorities)))
(cond ((cdr (assoc p org-priority-faces)))
((and (listp org-agenda-fontify-priorities)
(cdr (assoc p org-agenda-fontify-priorities)))
((equal p l) 'italic)
((equal p h) 'bold)))
(org-overlay-put ov 'org-type 'org-priority)))))

View File

@ -323,6 +323,18 @@ list of attributes, like (:foreground \"blue\" :weight bold :underline t)."
(string :tag "keyword")
(sexp :tag "face"))))
(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, or a property
list of attributes, like (:foreground \"blue\" :weight bold :underline t)."
:group 'org-faces
:group 'org-todo
:type '(repeat
(cons
(character :tag "Priority")
(sexp :tag "face"))))
(defvar org-tags-special-faces-re nil)
(defun org-set-tag-faces (var value)
(set var value)

View File

@ -4333,7 +4333,7 @@ between words."
'(2 'org-headline-done t))
nil)
;; Priorities
(list (concat "\\[#[A-Z0-9]\\]") '(0 'org-special-keyword t))
'(org-font-lock-add-priority-faces)
;; Tags
'(org-font-lock-add-tag-faces)
;; Special keywords
@ -4404,6 +4404,16 @@ If KWD is a number, get the corresponding match group."
'font-lock-fontified t))
(backward-char 1))))
(defun org-font-lock-add-priority-faces (limit)
"Add the special priority faces."
(while (re-search-forward "\\[#\\([A-Z0-9]\\)\\]" limit t)
(add-text-properties
(match-beginning 0) (match-end 0)
(list 'face (or (cdr (assoc (char-after (match-beginning 1))
org-priority-faces))
'org-special-keyword)
'font-lock-fontified t))))
(defun org-get-tag-face (kwd)
"Get the right face for a TODO keyword KWD.
If KWD is a number, get the corresponding match group."