1

I am using following setup in my .emacs file:

(setq hl-todo-keyword-faces
      '(("TODO"   . "#FF0000")
        ("FIXME"  . "#FF0000")
        ("DEBUG"  . "#A020F0")
        ("GOTCHA" . "#FF4500")
        ("STUB"   . "#1E90FF")))

Here all those keywords shown as bold and as their defined color.

In addition to that, I want to provide yellow background highlight color to all. Is it possible?

alper
  • 1,370
  • 1
  • 13
  • 35

1 Answers1

3

The doc string of hl-todo-keyword-faces says:

Each entry has the form (KEYWORD . COLOR). KEYWORD is used as part of a regular expression. If (regexp-quote KEYWORD) is not equal to KEYWORD, then it is ignored by `hl-todo-insert-keyword'. Instead of a color (a string), each COLOR may alternatively be a face.

So COLOR can also be a face. You can define your own faces with defface.

Example:

(defface hl-todo-TODO
  '((t :background "#f0ffd0" :foreground "#ff0000" :inherit (hl-todo)))
  "Face for highlighting the HOLD keyword.")
  • The hl-todo-TODO is the face name which you can put into hl-todo-keyword-faces instead of the color string "#FF0000".
  • The third arg of defface is the face specification which is an alist that maps terminal types to attributes. Use t as terminal type if you do not care.
  • Behind the t the property list with the face attributes starts. You can inherit from face hl-todo and set your own foreground and background color.
  • The last arg of defface is the doc string for the face.
Tobias
  • 33,167
  • 1
  • 37
  • 77