;;; ~/.emacs.d/init.el

 '(inhibit-startup-screen t)
 '(initial-scratch-message #("++"
                             0 2 (face underline))))

I expect to see an underscore in *scratch*, but it's not there.

How to achieve this?

1 Answer 1


Change face to font-lock-face in order for font-lock-mode to handle that.

If font-lock-mode was disabled then your original approach would work, but when it's enabled (which it is by default) you need to work with it so that it doesn't clobber pre-existing faces.

  • If I change "++" to ";+", it doesn't work. It seems that ";+" will use the face for comment. How to prevent this?
    – shynur
    Commented May 28, 2023 at 16:09
  • Makes sense -- if you insert a comment into the buffer, you can expect it to be fontified as a comment. I'm not sure if there's a trivial way to underline text other than via the face property. You can disable font-lock-mode for the buffer, but that obviously has other consequences. Otherwise, looking at (elisp)Displaying Faces suggests that an overlay might be an option for you. Or you can fake an underline via composition of glyphs: (insert (mapconcat (lambda (char) (compose-string (concat (char-to-string char) "_"))) "; foo" "")) (experimental; there might be a cleaner way).
    – phils
    Commented May 28, 2023 at 23:30

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.