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?


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.


(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.
  • I have added the code on the example but it didn't help – alper Feb 19 '20 at 13:12
  • 2
    Did you also replace "#FF0000" with hl-todo-TODO in hl-todo-keyword-faces? – Tobias Feb 19 '20 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.