From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.help Subject: Re: ratliff indentation style, peculiar indentation of close brace Date: Fri, 5 Aug 2016 18:59:30 +0000 (UTC) Organization: muc.de e.V. Message-ID: References: <91c177e3-a59e-4356-8ff2-b01731b8b294@googlegroups.com> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1470423642 11092 195.159.176.226 (5 Aug 2016 19:00:42 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 5 Aug 2016 19:00:42 +0000 (UTC) Injection-Date: Fri, 5 Aug 2016 18:59:30 +0000 (UTC) User-Agent: tin/2.3.1-20141224 ("Tallant") (UNIX) (FreeBSD/10.3-RELEASE-p4 (amd64)) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Aug 05 21:00:39 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bVkMD-0001Rt-Hr for geh-help-gnu-emacs@m.gmane.org; Fri, 05 Aug 2016 21:00:33 +0200 Original-Received: from localhost ([::1]:46743 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVkM7-0000OL-A2 for geh-help-gnu-emacs@m.gmane.org; Fri, 05 Aug 2016 15:00:27 -0400 Original-Path: usenet.stanford.edu!goblin3!goblin.stu.neva.ru!news.tu-darmstadt.de!news.muc.de!.POSTED.news.muc.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Injection-Info: colin.muc.de; posting-host="news.muc.de:2001:608:1000::2"; logging-data="94981"; mail-complaints-to="news-admin@muc.de" Original-Xref: usenet.stanford.edu gnu.emacs.help:218707 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:111070 Archived-At: Hello, Jim Jim Newton wrote: > I'm working on an open source project which uses Ratliff style > indentation for C++ code. I'm not a particular fan but I want to obey > the coding guidelines. I don't find anything with a google search. > Can emacs c++ indentation support this style. Indeed it can, but you'll have to specify this style since it doesn't currently exist in CC Mode. > The curious thing about this style is that it aligns the close brace > with the indentation as follows. > while (something) > do_something(); > do_something_else(); > } ;; brace is commented like this. I think there might be an opening brace missing in there, somewhere. ;-) > Does someone know of a way to make c++ indentation do this? Please read the CC Mode manual, which has a vast section on configuring indentation, and also a sample configuration on page "Sample .emacs File" to help get you started. Now go to line 4, and type C-c C-s. This will display something like "((block-close 40))", and will highlight (for up to 20 seconds) the "anchor point" at buffer position 40. You will notice that this is the start of the "while" keyword. Now do C-c C-o on the line, interactively to change the "offset" for the "syntactic symbol" block-close. Following the prompts, replace the offset "0" with "+" (all without the quote marks). Typing on the line to indent it should now do what you want. You will now want to configure that permanently so that you don't need to go through all of that each time you start Emacs. I would recommend you to create a CC Mode "ratliff style" by inheriting from, say, "k&r" style, then setting the "offset" for block-close with a line something like: (c-offsets-alist . ((block-close . +))) in the appropriate place in the style definition (see the "Sample .emacs File" page in the CC Mode manual, also other pages like "Adding Styles"). Having got that done, you might want to set up auto-newline, so that, for example, typing a closing brace after "do_something_else();" would automatically insert a newline and indent the brace correctly. Incidentally, I don't use this, it drives me crazy, but some people like it. > Thanks if anyone can help. If anything remains unclear, just ask again. Best of luck! -- Alan Mackenzie (Nuremberg, Germany).