From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nix Newsgroups: gmane.emacs.devel Subject: Re: emacs ident Date: Tue, 20 Sep 2011 14:24:10 +0100 Message-ID: <87sjnrl539.fsf@spindle.srvr.nix> References: <34249573.20110817200429@gmail.com> <20110817195242.GA3386@acm.acm> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1316525069 1791 80.91.229.12 (20 Sep 2011 13:24:29 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 20 Sep 2011 13:24:29 +0000 (UTC) Cc: pingved@gmail.com, emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 20 15:24:25 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1R60JE-0007cJ-Tv for ged-emacs-devel@m.gmane.org; Tue, 20 Sep 2011 15:24:25 +0200 Original-Received: from localhost ([::1]:34394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R60JE-0000CT-Gq for ged-emacs-devel@m.gmane.org; Tue, 20 Sep 2011 09:24:24 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:44749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R60JB-00006O-45 for emacs-devel@gnu.org; Tue, 20 Sep 2011 09:24:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R60J9-0004vN-PX for emacs-devel@gnu.org; Tue, 20 Sep 2011 09:24:21 -0400 Original-Received: from icebox.esperi.org.uk ([81.187.191.129]:33760 helo=mail.esperi.org.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R60J9-0004uY-Dr for emacs-devel@gnu.org; Tue, 20 Sep 2011 09:24:19 -0400 Original-Received: from esperi.org.uk (nix@spindle.srvr.nix [192.168.14.15]) by mail.esperi.org.uk (8.14.4/8.14.3) with ESMTP id p8KDOAPk011127; Tue, 20 Sep 2011 14:24:10 +0100 Original-Received: (from nix@localhost) by esperi.org.uk (8.14.4/8.12.11/Submit) id p8KDOA1j031354; Tue, 20 Sep 2011 14:24:10 +0100 Emacs: featuring the world's first municipal garbage collector! In-Reply-To: <20110817195242.GA3386@acm.acm> (Alan Mackenzie's message of "Wed, 17 Aug 2011 19:52:42 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-DCC-URT-Metrics: spindle 1060; Body=3 Fuz1=3 Fuz2=3 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 81.187.191.129 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:144116 Archived-At: On 17 Aug 2011, Alan Mackenzie stated: > Hello, pingved. pingved gave no answer, so I think I'll try (though I don't use this indentation style). > On Wed, Aug 17, 2011 at 08:04:29PM +0400, pingved@gmail.com wrote: >> I need to create indent for code of next format (c-mode or any other >> c-similar mode): > >> void Test(void) { >> (3space)DWORD abc; >> (4space)exit(0); >> (4space){ >> (4space)(3space)DWORD a; >> (4space)(4space)exit(0); >> (4space)} >> } > > It's not entirely clear what you're asking for here. What is the > criterion which distinguishes 3 spaces from 4 spaces (or even 7 or 8)? >From its appearance, I'd say it's whether it's a variable declaration. i.e. where we would write void test (int blah) { int abc = blah % 2; if (abc) { int womble = abc / 2; int splotz = abc * 2; printf ("%i, %i\n", womble, splotz); } test_this_as_well (abc); } pingved would write void test(int blah) { int abc = blah % 2; if(abc){ int womble = abc / 2; int splotz = abc * 2; printf("%i, %i\n", womble, splotz); } test_this_as_well(abc); } This seems to me to require substantial language understanding in order to reliably detect if a line is a variable declaration or not, and is almost certainly not implementable with cc-mode. Indeed, in C++, it is nearly impossible, as determing whether something is a variable declaration or a function call may require either a complete view of the whole translation unit above your current location, or, in the presence of exported templates, a complete view of the entirety of all translation units containing templates used by this one. This is obviously not practical for anything as incremental as cc-mode is, even if it contained a complete compiler for all languages under discussion. > As a matter of interest, why do you want/need such a wierd style? I think the idea is to make it look like indented first lines of paragraphs in printed books. This makes some sense: emulating typography is often a good idea (they have centuries more experience of making things legible than do we mere programmers). But in this case it seems... hard to do automatically. -- NULL && (void)