Hi people,
I share my beginner journey to 'how does this whitespace mode works ? I JUST WANT NON BREAKABLE SPACE TO BE DISPLAYED'
(yes, I was yelling because it took me too much time for such a simple ask)
​
I will only use [https://www.emacswiki.org/emacs/WhiteSpace](https://www.emacswiki.org/emacs/WhiteSpace)
# What I wanted :
Just display invisible char in visible way.
# Why so frustrating ?
Because I comes from vim, and was used to :
`:set listchars=nbsp:·,tab:▸␣`
(see example at [https://linuxhint.com/show-hidden-invisible-characters-vim/](https://linuxhint.com/show-hidden-invisible-characters-vim/) )
and "voilà"
# The conf
(custom-set-faces! ; this function comes from doom emacs, don't know the emacs way
'(whitespace-hspace :foreground "#FF0000" :background "#FFFFFF") ; hard space, non breakable space, used with whitespace.el
'(whitespace-tab :foreground "#FFFFFF" :background "#000000") ; tab face
)
(setq
whitespace-style '(face tabs spaces trailing space-before-tab indentation empty space-after-tab tab-mark space-mark)
whitespace-display-mappings
'((space-mark ?\ [? ] [? ]) ; space see here < >
(space-mark ?\xA0 [?\xA4] [?_]) ; hardspace see here < >
(tab-mark ?\t [187 9] [92 9]) ; tab see here < >
(newline-mark ?\n [?\xB6 ?\n] [?$ ?\n]); end-of-line <no demo>
))
(global-whitespace-mode)
# The result
Before :
[no whitespace mode and not configured. See nothing](https://preview.redd.it/gqttunrlbef81.png?width=629&format=png&auto=webp&s=92dbea58b3052a8ea560f02b5bedf608e886bf1a)
​
The default whitespace-style setup is :
whitespace-style '(face tabs spaces trailing lines space-before-tab newline indentation empty space-after-tab space-mark tab-mark newline-mark missing-newline-at-eof)
which display a very ugly document (unless doom emacs change it a bit) :
[All those dot makes code unreadable for me, also hard space not displayed properly](https://preview.redd.it/lyxtfloqbef81.png?width=825&format=png&auto=webp&s=12c87530e207f64c712da070f336c56e713b8641)
With the new configuration :
[At least I can see non breakable spaces !!](https://preview.redd.it/vonfoa1wbef81.png?width=638&format=png&auto=webp&s=e2ccfbb0d81437304c2245155654d25c6302ceb4)
# Notes
I'm a beginner, be careful with this code as it might be not 'emacs way'.
It was hard for me to understand that "whitespace-style" tell to emacs whether to display a custom face and / or a custom char mapping AND that you have to both set the face and the mapping (and disable / reenable mode after tweaking some variables).
I learn that non breakable space is named hard space in emacs.
But now, it's **better than vim** (of course) since I have full control.
Full control gives ugly things :
(setq whitespace-display-mappings
'((space-mark ?e [?💖] [?_]))
)
==>
[Something VERY ugly](https://preview.redd.it/odwjtjr5def81.png?width=657&format=png&auto=webp&s=bb1814ad1a4f4073e051d5c0464a3ce5f0801ad6)