From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Andrew M. Scott" Newsgroups: gmane.emacs.cc-mode.general,gmane.emacs.devel Subject: Re: cc-mode 5.31 doesn't like eval-after-load c-set-style Date: Wed, 7 Dec 2005 12:08:36 -0700 Message-ID: <17303.13108.561122.334495@chlr5836.ch.intel.com> References: <17302.64294.256799.692482@chlr5836.ch.intel.com> Reply-To: amscott1@sedona.ch.intel.com (Andrew M. Scott) NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1133982942 30853 80.91.229.2 (7 Dec 2005 19:15:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 7 Dec 2005 19:15:42 +0000 (UTC) Cc: "Andrew M. Scott" , bug-cc-mode@gnu.org, emacs-devel@gnu.org Original-X-From: cc-mode-help-admin@lists.sourceforge.net Wed Dec 07 20:15:37 2005 Return-path: Original-Received: from lists-outbound.sourceforge.net ([66.35.250.225]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Ek4hw-00012P-Fy for sf-cc-mode-help@m.gmane.org; Wed, 07 Dec 2005 20:12:04 +0100 Original-Received: from sc8-sf-list1-b.sourceforge.net (sc8-sf-list1-b.sourceforge.net [10.3.1.7]) by sc8-sf-spam2.sourceforge.net (Postfix) with ESMTP id 8E9FA16442; Wed, 7 Dec 2005 11:12:03 -0800 (PST) Original-Received: from sc8-sf-mx2-b.sourceforge.net ([10.3.1.92] helo=mail.sourceforge.net) by sc8-sf-list1.sourceforge.net with esmtp (Exim 4.30) id 1Ek4ho-0004pm-PF for cc-mode-help@lists.sourceforge.net; Wed, 07 Dec 2005 11:11:56 -0800 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by mail.sourceforge.net with esmtps (TLSv1:DES-CBC3-SHA:168) (Exim 4.44) id 1Ek4hn-000202-3j for cc-mode-help@lists.sourceforge.net; Wed, 07 Dec 2005 11:11:56 -0800 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by fencepost.gnu.org with esmtp (Exim 4.34) id 1Ek4hA-0002Kj-Sw for bug-cc-mode@gnu.org; Wed, 07 Dec 2005 14:11:17 -0500 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.34) id 1Ek4iq-0000eH-34 for bug-cc-mode@gnu.org; Wed, 07 Dec 2005 14:13:01 -0500 Original-Received: from [143.182.124.5] (helo=petasus.ch.intel.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Ek4ip-0008EO-KC; Wed, 07 Dec 2005 14:12:59 -0500 Original-Received: from sedona.intel.com (sedona.ch.intel.com [143.182.201.200]) by petasus.ch.intel.com (8.12.9-20030918-01/8.12.10/d: small-solo.mc,v 1.2 2004/09/17 18:05:04 root Exp $) with ESMTP id jB7J93EA032306; Wed, 7 Dec 2005 19:09:03 GMT Original-Received: from chlr5836.ch.intel.com (chlr5836.ch.intel.com [10.2.120.162]) by sedona.intel.com (8.12.10/8.12.9/d:) with ESMTP id jB7J8bpv021381; Wed, 7 Dec 2005 12:08:37 -0700 (MST) X-Envelope-From: amscott1@sedona.ch.intel.com Original-Received: from chlr5836.ch.intel.com (localhost [127.0.0.1]) by chlr5836.ch.intel.com (8.12.10/8.12.8/MailSET/client) with ESMTP id jB7J8bin032519; Wed, 7 Dec 2005 12:08:37 -0700 Original-Received: (from amscott1@localhost) by chlr5836.ch.intel.com (8.12.10/8.12.8/MailSET/Submit) id jB7J8aPN032516; Wed, 7 Dec 2005 12:08:36 -0700 Original-To: Alan Mackenzie In-Reply-To: X-Mailer: VM 7.19 under Emacs 22.0.50.1 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on monty-python X-Spam-Level: X-Spam-Status: No, hits=0.0 required=5.0 tests=none autolearn=no version=2.63 X-Spam-Score: 0.0 (/) X-Spam-Report: Spam Filtering performed by sourceforge.net. See http://spamassassin.org/tag/ for more details. Report problems to http://sf.net/tracker/?func=add&group_id=1&atid=200001 Original-Sender: cc-mode-help-admin@lists.sourceforge.net Errors-To: cc-mode-help-admin@lists.sourceforge.net X-BeenThere: cc-mode-help@lists.sourceforge.net X-Mailman-Version: 2.0.9-sf.net Precedence: bulk List-Unsubscribe: , List-Id: Bug reports, feature requests, and general talk about CC Mode. List-Post: List-Help: List-Subscribe: , List-Archive: X-Original-Date: Wed, 7 Dec 2005 12:08:36 -0700 Xref: news.gmane.org gmane.emacs.cc-mode.general:2767 gmane.emacs.devel:47142 Archived-At: >>>>> "Alan" == Alan Mackenzie 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 c . 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 ------------------------------------------------------- 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