emacs-devel
[Top][All Lists]
Advanced

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

Re: cc-mode 5.31 doesn't like eval-after-load c-set-style


From: Alan Mackenzie
Subject: Re: cc-mode 5.31 doesn't like eval-after-load c-set-style
Date: Wed, 7 Dec 2005 17:08:12 +0000 (GMT)

Hi, Andrew!

On Wed, 7 Dec 2005, Andrew M. Scott wrote:

>FYI, I had also posted this on Dec 5th on the emacs-pretest-bug list
>(no response yet):
>http://lists.gnu.org/archive/html/emacs-pretest-bug/2005-12/msg00075.html

Sorry!  bug-cc-mode (even as a cc:) is always a better place, because
important emails there don't get swamped by other important emails.

>I've had the following code snippet in my .emacs file for ages, but
>only recently (since cc-mode 5.31?) has it produced errors like this
>one. I see the issue with both a Dec 5, 2005 and Nov 2004 CVS Emacs
>build I had available. I also tried cc-mode 5.31.1 that I saw on
>sourceforge, but get the same error.

>% emacs -q

>Eval the following code snippet:
>(eval-after-load "cc-mode"
>    '(progn
>      (c-set-style "gnu")
>      ))

OK, that code's wrong!  `c-set-style' applies to an individual buffer,
and if you do it in the eval-after-load form, the current buffer is
somewhat ill-defined.  For example, if you did (load-library 'cc-mode),
Bad Things might happen.

An extra check was added fairly recently to c-set-style because Bad
Things were happening when people called it for non-CC Mode buffers.

Are you sure you don't really want (setq c-default-style "gnu"),
[or even, (setq c-default-style '((java-mode . "java") (awk-mode .
"awk")))?]  You can even do this with customize-group <ret> c <ret>.

Or is it that you've got the default style set to "linux" and you want
the first buffer to be loaded, junk.c, to get "gnu"?

>C-x C-f junk.c

What happens is this:  this command loads junk.c, sees it needs c-mode,
so it loads cc-mode.elc.  It then tries to set the style "gnu" on junk.c
before it's had a chance to initialise c-mode on it. 

The error message in this case "Buffer junk.c is not a CC Mode buffer" is
perhaps suboptimal.  Do you think "Buffer junk.c is not a CC Mode buffer,
or hasn't been initialized yet" might be better?

What exactly do you see as the bug?  Is it the obscure error message, or 
do you really, really, absolutely unavoidably HAVE to set junk.c's style
in this eval-after-load? 

[ .... ]

>Thanks,
>Andy Scott

-- 
Alan Mackenzie (Munich, Germany)






reply via email to

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