emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacs ident


From: Nix
Subject: Re: emacs ident
Date: Tue, 20 Sep 2011 14:24:10 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

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, address@hidden 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]