Subject: bug#9448: 24.0.50; Comments in Awk scripts not fontified with comment face

From: Alan Mackenzie <[email-masked]>
Date: Thu, 8 Sep 2011 08:33:11 +0000

Hi, Stefan

On Wed, Sep 07, 2011 at 10:12:40PM -0400, Stefan Monnier wrote:
> > If I'm right about this, a solution would be to insert
> >    (makunbound 'awk-mode-syntax-table)

> I wouldn't consider this as a solution.

It doesn't work anyway.  ;-)

> I see a few solutions, tho:
> - move the defvar from cc-awk to cc-mode.

Undesirable.

> - move the define-derived-mode to cc-awk (sounds natural, from my
>   "I haven't looked at the code" point of view).

That's beginning to sound serious.  CC Mode is structured so that the
interface with the "OS" bit of the host Emacs is in cc-mode.el.

> - add a ":syntax-table awk-mode-syntax-table" argument to define-derived-mode.

I've tried :syntax-table nil, and this doesn't generate
awk-mode-syntax-table.  It appears to work.

> > at the top of the mode initialisation.  Why on earth does
> > `define-derived-mode' have the temerity to create an empty, thus useless,
> > syntax table?

> It's actually not empty: it inherits from the parent.  This is taken
> directly from the original define-derived-mode, which was oddly meant
> for end-users.
> It also has the advantage to ensure that every major-mode defined with
> define-derived-mode will have a foo-mode-syntax-table.

> > Maybe this should be taken out of the macro.

> Maybe so, yes.  I'm not completely sure.  In any case it's too late to
> do that for Emacs-24.  But we could try it out in Emacs-25.

OK.

One other thing is bothering me quite a bit.  Just before all this, at
L1530 in cc-mode.el is the line

    (defvar awk-mode-syntax-table)

.  This ought to prevent my solution above from working, but it doesn't.
Glenn, I think you put this line in.  Why?  Would it be OK to take it out
again?

BTW, I've found out why deleting cc-fonts.elc does what it does.  There
is a "(cc-require-when-compile 'cc-awk)" in cc-fonts.el.  When this file
isn't byte compiled, that form loads cc-awk.elc, and this happens before
the bulk of cc-mode.elc is loaded.  That form should probably be removed,
since it no longer serves a purpose.

Glenn, what on earth brought you to try deleting cc-fonts.elc?  It seems
a stroke of genius, but how did you come to consider it?  :-)

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).