Emacs show invisible symbols (\n)
elisp, emacs
Solution
Highlighting newline chars is trivial using the library `highlight-chars.el`:
M-x hc-highlight-chars C-q C-j RET font-lock-comment-face RET
You are prompted for the chars to highlight -- hit `C-q C-j` (inserts a newline char), then hit `RET` to enter the list of chars you inserted (just a newline char here).
You are then prompted for the face to use to highlight those chars (in this case, just one char, newline) -- type `font-lock-comment-face` or whatever other face name you like.
See description of the library here.
And if you want to also change the display to show (the highlighted char) ¬, then just do also what you already tried:
M-: (standard-display-ascii ?\n "¬\n")
The result of #1 + #2 is highlighted `¬` in place of the usual newline display.
Problem
I am trying to highlight several invisible symbols in Emacs, specifically `\n`. I am trying the following: ``` (standard-display-ascii ?\n "¬\n") (font-lock-add-keywords nil '(("¬" . font-lock-comment-face))) ``` Unfortunately, it looks like only typed explicitly symbols will use the specified font-face. Is there a proper way to highlight the display-ascii symbol? One more related question: replacing `nil` with `'lisp-interaction-mode` in the second expression makes it not working anymore. Why is that?