I have a custom face defined as

(defface my-underlined
  '((t (:underline "red")))
  :group 'my-group)

At some place I underline some words with something like

(add-text-properties (match-beginning 0) (match-end 0) '(font-lock-face my-underlined)))))

What would be a correct way to revert this text properties set on some words (or on all words on demand) as well as restore their syntax highlight that might have existed before? Nothing with font-lock- seems to work. What would be a correct way to underline and revert?

A function underline-region doesn't seem to work. It just inserts ^H_ into the text.

  • 1
    BTW, instead of (add-text-properties .. .. '(PROP VAL)) you can use (put-text-property ... 'PROP 'VAL).
    – Stefan
    Commented Mar 31, 2017 at 20:59

1 Answer 1


See the Emacs Lisp manual section on removing text properties.

remove-list-of-text-properties seems to do what you want.

See related discussion here on the Emacs StackExchange.

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.