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?
I just booted up emacs, did the command M-x
, and typed
whitespace-mode
Afterwards I got a $
indicator for newlines.
To only show newlines the following can be used:
(global-whitespace-newline-mode)
or an alternative:
(setq whitespace-style '(face newline-mark))
(whitespace-mode t)
And to use the custom symbol ¬
for it:
(setq whitespace-display-mappings
'((newline-mark 10 [172 10])))
Then the whitespace-newline
font-lock can be used to customize the style.
Edit:
For some reason placing this customization in .emacs
config results in faces styles not applying to the symbol, I am not sure why (would be great if somebody could explain this). Using hooks works fine:
(add-hook 'prog-mode-hook
(lambda ()
(whitespace-newline-mode t)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With