Friday, January 9, 2009

GNU/Emacs font-lock suckage

For months now, my GNU/Emacs has decided to sometimes not syntax highlight my source or ChangeLog files and I didn't know why.

The other day, emacs' failure to syntax highlight xaml.cpp was the final straw. I decided enough was enough with having to M-x font-lock-fontify-buffer everytime I opened a handful of source files, especially ones that I often find need to edit and/or to refer to.

A little digging later and I discovered that GNU/Emacs must have added a feature that disabled font-lock (even if you've specified (setq font-lock-support-mode t) in your ~/.emacs) if the buffer was over some arbitrary size. Either that, or they lowered the arbitrary size to something ridiculously small.

The solution seems to be to add the following line to your ~/.emacs file: (setq font-lock-maximum-size 1000000)

Feel free to append a few more 0's to that number if you find that Emacs still fails to syntax highlight any of your source files.

Update: Another Emacs annoyance can be turned off by adding (setq inhibit-startup-message t) to your ~/.emacs file. I'm not sure why this isn't inhibited by default.

6 comments:

Berto said...

This is the thread that explains why inhibit-startup-messaget isn't activated by default:

http://lists.gnu.org/archive/html/emacs-devel/2007-09/msg00815.html

(in particular this message)

Anonymous said...

Can you reproduce the problem you are having when doing:

emacs -Q ChangeLog

If yes, that is bad, and please report it to bug-gnu-emacs@gnu.org and it will get fixed.

Doing:
(setq font-lock-support-mode t)
in .emacs is not a good idea

In general font-lock should work without doing anything in .emacs in emacs-22+
(

Jeffrey Stedfast said...

emacs -Q ChangeLog works

Why does -Q work? According to the man-page, the -Q option does not seem like it should affect this at all.

Jeffrey Stedfast said...

n/m, apparently it's the '-q' (aka --no-init-file) that makes the difference.

Commenting out (setq font-lock-support-mode t) in my ~/.emacs solved the problem.

Sankar said...

< Fun>
Another solution:
alias emacs=vim
< / Fun>

Jeffrey Stedfast said...

hehe ;-)

Code Snippet Licensing

All code posted to this blog is licensed under the MIT/X11 license unless otherwise stated in the post itself.