I am trying to set the foreground color for first line in my buffer which has global-font-lock ON.

Buffer contents -

(add-text-properties 1 8
                                         '(:foreground "red"))
;;since add-text-properties didn't work, i tried with add-face-text-property
(add-face-text-property 1 8 '(:foreground "red"))

When i do eval-buffer, i like to see the first line, (ignore) made red. But it is not so. I referred here to know the function, add-text-properties doesn't work when font-lock mode is ON.

Is there a way one can change the properties for text that lies between a start and end point?

1 Answer 1


When font-lock-mode is in use, you can use the font-lock-face property instead of face.

(add-text-properties 1 8 '(font-lock-face (:foreground "red")))

  • what if you want the face to stay but also want to apply something like an underline?
    – shackra
    Commented Dec 7, 2019 at 2:13
  • 1
    Interesting. You could set font-lock-face to the current value of face plus what you want to add. (defun add-to-font-locked-face (b e v) (put-text-property b e 'font-lock-face (cons v (get-text-property b 'face)))). Then (add-to-font-locked-face 1 11 '(:underline t)). Seems to work well if you add to a whole font locked word.
    – JeanPierre
    Commented Dec 7, 2019 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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