[Top][All Lists]
[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: |
Andrew M. Scott |
Subject: |
Re: cc-mode 5.31 doesn't like eval-after-load c-set-style |
Date: |
Wed, 7 Dec 2005 12:08:36 -0700 |
>>>>> "Alan" == Alan Mackenzie <address@hidden> writes:
Alan> 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
Alan> Sorry! bug-cc-mode (even as a cc:) is always a better place,
You're right :-) I should have cc'd bug-cc-mode on the original report.
>> 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") ))
Alan> OK, that code's wrong! `c-set-style' applies to an
Alan> individual buffer, and if you do it in the eval-after-load
Alan> form, the current buffer is somewhat ill-defined. For
Alan> example, if you did (load-library 'cc-mode), Bad Things
Alan> might happen.
Thanks. This was a legacy code fragment.
Alan> An extra check was added fairly recently to c-set-style
Alan> because Bad Things were happening when people called it for
Alan> non-CC Mode buffers.
Which explains why I'm just seeing the error when the cc-mode 5.31
rotation showed up. Thanks.
Alan> Are you sure you don't really want (setq c-default-style
Alan> "gnu"), [or even, (setq c-default-style '((java-mode .
Alan> "java") (awk-mode . "awk")))?] You can even do this with
Alan> customize-group <ret> c <ret>.
Yes. These are the right way to do it.
Alan> Or is it that you've got the default style set to "linux"
Alan> and you want the first buffer to be loaded, junk.c, to get
Alan> "gnu"?
>> C-x C-f junk.c
Alan> What happens is this: this command loads junk.c, sees it
Alan> needs c-mode, so it loads cc-mode.elc. It then tries to set
Alan> the style "gnu" on junk.c before it's had a chance to
Alan> initialise c-mode on it.
Alan> The error message in this case "Buffer junk.c is not a CC
Alan> Mode buffer" is perhaps suboptimal. Do you think "Buffer
Alan> junk.c is not a CC Mode buffer, or hasn't been initialized
Alan> yet" might be better?
Alan> What exactly do you see as the bug? Is it the obscure error
Alan> message, or do you really, really, absolutely unavoidably
Alan> HAVE to set junk.c's style in this eval-after-load?
I think the current "error message" is sufficient. I don't think any
cc-mode or Emacs code changes are needed for this issue. The fix is for
me to use setq c-default-style or c-set-style directly.
Thanks,
Andy Scott