unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: gnu-emacs-bug@moderators.isc.org
Subject: bug#14325: 24.3; cc-mode does not initialize correctly w/ -batch
Date: Wed, 1 May 2013 17:23:46 +0000 (UTC)	[thread overview]
Message-ID: <klrj32$t0s$1@colin.muc.de> (raw)
In-Reply-To: <878v3z29r2.fsf@Rainer.invalid>

Achim Gratz <Stromeko@nexgo.de> wrote:
> Alan Mackenzie writes:
>> Yes, the c-after-font-lock-init call will initialise everything properly,
>> though it's more a workaround than a solution.

> So what would be the solution, then?

>> 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.

> Well, Org requires font-lock, it switches font-lock off and on when it
> changes font-lock settings and it uses it for fontification with
> whatever major mode the content wants to have.

OK.  Could you possibly give the exact sequence of Font Lock and CC Mode
calls which lead to the error?

> If there is a code-path that enters cc-mode in uninitialized state, then
> shouldn't cc-mode check for nil instead of crashing Emacs by blindly
> assuming it can funcall the contents of that variable?

The variable is (or should be) initialised by font-lock-mode-hook calling
c-after-font-lock-init.  This should happen when font-lock-mode is called.
The question is why the switching on of Font Lock Mode here fails to do
this.

>> 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.

> Since Org can use the results of the fontification, some of it must
> happen anyway?  Besides, even if I stop jit-lock-mode from being
> used (by adding it to font-lock-inhibit-thing-lock), cc-mode still
> throws an error.

>> 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)

> I've tried to put these (without switching to c-mode since selecting the
> mode is done elsewhere) into various places and still get the same error
> from cc-mode.

OK.

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

> I'd prefer if fontlock-fontify-* would work in batch mode without
> workarounds.  I'll have no problem sticking (when noninteractive ...)
> into the intialization or Org itself if that's the ticket.  I still
> don't have a clue where that should be done.

I'd like to track this down, too.

> Regards,
> Achim.

-- 
Alan Mackenzie (Nuremberg, Germany).






  parent reply	other threads:[~2013-05-01 17:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.24908.1367343951.855.bug-gnu-emacs@gnu.org>
2013-04-30 17:45 ` bug#14325: 24.3; cc-mode does not initialize correctly w/ -batch Achim Gratz
2013-05-01  0:51   ` Glenn Morris
2013-05-01  3:37     ` Glenn Morris
2013-05-01  6:51     ` Achim Gratz
2013-05-01 12:53   ` Alan Mackenzie
2013-05-01 16:26   ` Achim Gratz
2013-05-01 17:23   ` Alan Mackenzie [this message]
2013-05-01 18:15   ` Achim Gratz
2013-05-02 13:04     ` Alan Mackenzie
2013-05-02 18:44   ` Achim Gratz
2013-05-05 14:17   ` Achim Gratz
2013-05-06 13:25   ` Alan Mackenzie
     [not found] ` <klr388$b56$1@colin.muc.de>
2013-05-01 17:59   ` Glenn Morris
2013-05-01 18:55     ` Alan Mackenzie
2013-05-01 19:04       ` Glenn Morris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='klrj32$t0s$1@colin.muc.de' \
    --to=acm@muc.de \
    --cc=gnu-emacs-bug@moderators.isc.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).