From: Alan Mackenzie <acm@muc.de>
Cc: bug-cc-mode@gnu.org, emacs-devel@gnu.org
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) [thread overview]
Message-ID: <Pine.LNX.3.96.1051207163436.304C-100000@acm.acm> (raw)
In-Reply-To: <17302.64294.256799.692482@chlr5836.ch.intel.com>
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)
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
next parent reply other threads:[~2005-12-07 17:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <17302.64294.256799.692482@chlr5836.ch.intel.com>
2005-12-07 17:08 ` Alan Mackenzie [this message]
2005-12-07 19:08 ` cc-mode 5.31 doesn't like eval-after-load c-set-style Andrew M. Scott
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=Pine.LNX.3.96.1051207163436.304C-100000@acm.acm \
--to=acm@muc.de \
--cc=bug-cc-mode@gnu.org \
--cc=emacs-devel@gnu.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).