From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.help Subject: Re: marrying braket for ?: operator Date: Sun, 31 Jul 2005 12:20:59 +0000 Organization: muc.de e.V. -- private internet access Message-ID: References: <878xzr33rg.fsf@wash.edu> <3qkbcd.u8.ln@acm.acm> <87ll3qaunx.fsf@wash.edu> NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1122812624 11270 80.91.229.2 (31 Jul 2005 12:23:44 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 31 Jul 2005 12:23:44 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jul 31 14:23:43 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DzCqQ-0007Mv-3p for geh-help-gnu-emacs@m.gmane.org; Sun, 31 Jul 2005 14:23:06 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DzCt1-0003mq-2Q for geh-help-gnu-emacs@m.gmane.org; Sun, 31 Jul 2005 08:25:47 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news.belwue.de!informatik.tu-muenchen.de!news.muc.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 84 Original-NNTP-Posting-Host: acm.muc.de Original-X-Trace: marvin.muc.de 1122812188 87887 193.149.49.134 (31 Jul 2005 12:16:28 GMT) Original-X-Complaints-To: news-admin@muc.de Original-NNTP-Posting-Date: 31 Jul 2005 12:16:28 GMT User-Agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686)) Original-Xref: shelby.stanford.edu gnu.emacs.help:132784 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:28308 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:28308 Baloff wrote on 29 Jul 2005 18:22:26 +1000: [ .... ] > now that you know my .emacs and the lot how can I get > enum colors { to go to a new line and indent like when I type say > main(){ or for(...) { First remark: this works only when you've got "Auto Newline Mode" enabled, which you obviously already have. C-c C-a will toggle this mode. Second remark: The stuff here is documented in the CC Mode manual on the pages "Auto-newline Insertion" and "Hanging Braces". Third remark: Have a look at a C or C++ source file, and type C-c C-s on a few lines. This will show you the "syntactic context", i.e. CC Mode's syntactic analysis of the line. Put the { of "enum colors {" on its own line, and do C-c C-s there. It will tell you that this sort of brace is a "brace-list-open". In your CC Mode configuration, you need to change the setting `c-hanging-brace-alist'. While in a C/C++ buffer, do C-h C-v and have a look at the value of that variable. It will be something like this: ((brace-list-open) <=================== (block-open after) (defun-open after) (substatement-open after) (block-close . c-snug-do-while)) Each element of this list is itself a list. The first element (e.g. defun-open) gives the type of the brace, and the other elements (either "before", "after", both or none[*]), say where CC Mode is to insert the newlines for this sort of brace. [*] For advanced uses, a function can be specified here instead. For your brace-list-open element, I think you want "after", but you can change that yourself if need be. OK! Let's now go to your Lisp. Where you've got (c-add-style "mc394-style" '("cc-mode" (c-basic-offset . 3) ; In general, indent 3 spaces (c-hanging-braces-alist , you're creating a style called "mc394-style" which inherits from the style called "cc-mode". Since you're changing the style, you probably want to give it a new name, say "baloff-style", in a new file called baloff-style.el. So copy the file and change these lines to this: (c-add-style "baloff-style" '("cc-mode" (c-basic-offset . 3) ; In general, indent 3 spaces (c-hanging-braces-alist . A bit lower down, where you've got: (c-hanging-braces-alist ; These determine whether a newline appears before ; and/or after a brace in various situations. (brace-list-open) (block-open after) ; statement block open brace (defun-open after) ; brace that opens a function definition (substatement-open after); the brace that opens a substatement block (block-close . c-snug-do-while)) , change "(brace-list-open)" to "(brace-list-open after)". Load this new file (M-x load-file), Then from a C++ buffer, do C-c . (that's "control-C dot"), check your new style has been loaded, and set your buffer to this style. Check it does what you want, and if it doesn't, play around with it till it does. Then go through your .emacs, replacing all references to "mc394-style" with "baloff-style". Have fun! -- Alan Mackenzie (Munich, Germany) Email: aacm@muuc.dee; to decode, wherever there is a repeated letter (like "aa"), remove half of them (leaving, say, "a").