I would like to fontify headlines with the same color/weight as their TODO keywords. So for example, the default is like this:
TODO Headline
And I want it to look like this:
TODO Headline
Any ideas?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityYou can find out what face is applied to the text under point (the cursor) with the command M-x describe-face
.
By doing this, I learned that the face applied to TODO
keywords is called org-todo
. The Face for top-level headings is org-level-1
.
You can customize faces using via M-x customize-face
. You can set attributes individually, or you can apply the attributes from one face directly to another using the Inherit attribute. In your case, set the Inherit attribute for org-level-1
to org-todo
.
When you're done, C-c C-c
in the customize buffer will set your changes temporarily, and C-c C-s
will save them permanently.
For DONE-keywords, there is a variable org-fontify-done-headline
that activates fontification of the whole headline. To do this also for "not-done" keywords, we have to add a similar extra font-lock rule for org. The easiest way to do this is by modifying org-font-lock-extra-keywords
using org-font-lock-set-keywords-hook
(this then runs when initializing each buffer, as TODO-keywords etc. can vary).
The following works for the case of fontifying “not-done” headlines:
(defface aj/org-headline-todo '((t :inherit org-todo :weight normal))
"Face for TODO headlines."
:group 'org-faces)
(defun aj/org-fontify-todo-headlines ()
"Add rule for fontifying not-done headlines in org-mode."
(push (list (format org-heading-keyword-regexp-format org-not-done-regexp)
'(2 'aj/org-headline-todo t))
org-font-lock-extra-keywords))
(add-hook 'org-font-lock-set-keywords-hook #'aj/org-fontify-todo-headlines)
The custom face that inherits from org-todo
can of course be customized to suit your needs.