Emacs: font explanation

I have been using Emacs for a long time and I have configured it quite a lot. I even wrote simple ELisp functions, and now I'm using macros more and more. I don't know a knowledgeable Emacs user anywhere, but I'm not a complete newbie.

I use nxhtml, mumamo, dired, ido, custom keybindings and so many things that I have added over the years that I don’t remember all of them; )

But something that I never really understood: what is the "font lock" mode and why does it bother me?

For example, I read that nxhtml and nxml, if I remember correctly, do not use font locking. Maybe I did not understand this part very well, but in any case: what does it change as a user?

Or take, for example, this description about WhiteSpace:

Note that when WhiteSpace is turned on, WhiteSpace saves the font lock state, that is, if the font lock function is enabled. And WhiteSpace restores the font lock state when it is turned off. So, if WhiteSpace is turned on and font lock is turned off, WhiteSpace also turns on font-lock to highlight spaces, but font lock will be turned off when WhiteSpace is off. So enable font lock before WhiteSpace is turned on if you want font lock to continue after WhiteSpace is turned off.

Good Excellent. I understand it. But what will change if the font lock function continues or not?

Basically, I just don't β€œget it,” no matter how much I read about the subject.

Any example / explanation that "font-lock" is under Emacs, and why it concerns me, would be very welcome!

+8
emacs font-lock
source share
2 answers

font-lock-mode == colorful highligthing syntax. global-font-lock-mode allows global-font-lock-mode to lock fonts for each mode in Emacs. The old version of Emacs required you to enable it manually, the newer version (in my opinion, 23+) will enable this by default. I can’t imagine that many people will want to disable this feature, since it makes some type of content (like source code) extremely readable. Each mode that uses the font-lock function depends on a specific set of faces - a combination of font properties such as size, bold, underline, italics, and color. The main facets used by most modes:

 font-lock-builtin-face font-lock-comment-face font-lock-comment-delimiter-face font-lock-constant-face font-lock-doc-face font-lock-doc-string-face font-lock-function-name-face font-lock-keyword-face font-lock-negation-char-face font-lock-preprocessor-face font-lock-string-face font-lock-type-face font-lock-variable-name-face font-lock-warning-face 

You can easily override your values ​​if you want, or use a different color theme. Some mods also define additional faces.

+10
source share

It displays your code with all different colors (red for comments, green for class names, etc.). If this happens, you will get a black and white code instead. Open some code and run Mx font-lock-mode a couple of times to see how it turns on and off.

+4
source share

All Articles