I have a org file with the following content:
* My Heading
** TODO Make a FOO
** TODO Take action on bar and FOO
** TODO Check if FOO is working
My objective is to highlight the word FOO
from the task headings in org-agenda-mode
. To achieve this, I've tried:
(add-hook 'org-agenda-mode-hook
(lambda ()
(font-lock-add-keywords nil
'(("\\(FOO\\)" 1 '(:background "red"))))))
But nothing changes. My hook is running and if I try Ch v font-lock-keywords
inside the agenda view, the value returned is
(t
(("\\(FOO\\)" 1
'(:background "red")))
("\\(FOO\\)"
(1
'(:background "red"))))
Apart from showing the same item two times, I can't see why this isn't working. Does ignore font-lock-mode
settings? If so, how could I add a "custom" keyword hightlight to org-agenda-mode
?
EDIT :
Mx emacs-version
is GNU Emacs 24.4.1 (i686-pc-mingw32)
Mx org-version
is Org-mode version 8.2.10
As @lawlist suggested, the *Org-Agenda*
buffer does not use font-lock-mode
. The easiest way to achieve what I want in the agenda view is to use HiLock as suggested in this question :
(defface my-hi-lock-face '((t (:background "red"
:foreground "yellow"
:bold t)))
"my-hi-lock-face")
(add-hook 'org-finalize-agenda-hook
(lambda ()
(highlight-regexp "\\(FOO\\)" "my-hi-lock-face")))
Note the hook I'm using: this one runs again everytime I redraw my agenda buffer.
I don't have the time to try and understand what's wrong in your code, but you can have a look at my Emacs-Leuven.el file (L976-1015): I do the same for the words "FIXME", "XXX" and "BUG".
https://github.com/fniessen/emacs-leuven/blob/master/emacs-leuven.el
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.