I'm writing some very simple code to get data from a web api, i then parse the response and output the result in a buffer.

By default this text is very flat, how can i add keyword highlighting that follows the current theme's colourscheme?

For example, the text in the buffer:


  • Keyword1: data1
  • Keyword2: data2

How can i define, and most importantly apply faces(i think) to the keywords?


1 Answer 1


You have to use the propertize method for that.

For exemple, in your case, to use the font-lock-builtin-face on the Keyword words, you can do:

  (goto-char (point-min))
    (while (re-search-forward "^Keyword[0-9]:" nil t)
      (replace-match (propertize (match-string 0) 'face 'font-lock-builtin-face))))

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.