bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#14325: 24.3; cc-mode does not initialize correctly w/ -batch


From: Alan Mackenzie
Subject: bug#14325: 24.3; cc-mode does not initialize correctly w/ -batch
Date: Wed, 1 May 2013 12:53:28 +0000 (UTC)
User-agent: tin/1.9.6-20101126 ("Burnside") (UNIX) (FreeBSD/8.4-PRERELEASE (amd64))

Achim Gratz <address@hidden> wrote:

> Publishing from Worg (the community webpages for Org) runs in batch mode
> and uses cc-mode for syntax highlighting for some source code examples.
> While testing the publishing process with Emacs?24 I've come across an
> apparent regression in cc-mode: it tries to use the initial value for
> c-standard-font-lock-fontify-region-function, which happens to be nil to
> do a funcall and errors out since the function slot of that variable is
> void.  I've worked around the error by adding this to the init file:

> --8<---------------cut here---------------start------------->8---
> ;; to have things work correctly in batch-mode
> (require 'font-lock)
> (require 'cc-mode)
> (c-after-font-lock-init)
> --8<---------------cut here---------------end--------------->8---

> I cannot tell if that works correctly in all cases or why this is
> necessary, but simply by switching to Emacs?23 it all works correctly
> without it.

Yes, the c-after-font-lock-init call will initialise everything properly,
though it's more a workaround than a solution.

Font Lock Mode is a minor mode, and part of its initialisation is calling
font-lock-mode-hook.  (font-lock-mode-hook is here c-after-font-lock-init.)
If you run font-lock-fontify-buffer (etc.) without fully initialising Font
Lock Mode, you're liable to run into bugs.  If that were all there were
to it, I'd have nothing more to say, but sadly it's not so simple.

Font Lock Mode is, by default disabled in batch mode.  If you enable it,
this also enables jit-lock-mode (which is surely wrong), which prevents
any fontification actually taking place, since the buffer is never
displayed on the screen to trigger the fontification.

I think the following sequence of commands would fontify the buffer
properly in batch mode:
    (c-mode)
    (setq font-lock-support-mode nil) ; disable jit-lock-mode
    (font-lock-mode 1)
.

However, you'll probably prefer to carry on with using Font Lock Mode
uninitialised.  ;-)  I think Glenn's patch achieves this painlessly.

> Regards,
> Achim.

-- 
Alan Mackenzie (Nuremberg, Germany).






reply via email to

[Prev in Thread] Current Thread [Next in Thread]