unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* emacs ident
@ 2011-08-17 16:04 pingved
  2011-08-17 19:52 ` Alan Mackenzie
  0 siblings, 1 reply; 3+ messages in thread
From: pingved @ 2011-08-17 16:04 UTC (permalink / raw)
  To: emacs-devel

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)}
}

But emacs doesn't support this style :(
Can Developers fix this?
THX!




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: emacs ident
  2011-08-17 16:04 emacs ident pingved
@ 2011-08-17 19:52 ` Alan Mackenzie
  2011-09-20 13:24   ` Nix
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Mackenzie @ 2011-08-17 19:52 UTC (permalink / raw)
  To: pingved; +Cc: emacs-devel

Hello, pingved.

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)?

> But emacs doesn't support this style :(

That's the first I've heard of it.  ;-)  If you've not done so already,
read the CC Mode manual which should have come with your Emacs.  In
particular, read the chapters "Indentation Engine Basics" and
"Customizing Indentation".  It may well be that you might have to write a
function to put on `c-special-indent-hook', depending on how unsystematic
your indentation scheme actually is.

As a matter of interest, why do you want/need such a wierd style?

> Can Developers fix this?

There's nothing broken, so there's nothing to fix.

> THX!

-- 
Alan Mackenzie (Nuremberg, Germany).



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: emacs ident
  2011-08-17 19:52 ` Alan Mackenzie
@ 2011-09-20 13:24   ` Nix
  0 siblings, 0 replies; 3+ messages in thread
From: Nix @ 2011-09-20 13:24 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: pingved, emacs-devel

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)



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-09-20 13:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-17 16:04 emacs ident pingved
2011-08-17 19:52 ` Alan Mackenzie
2011-09-20 13:24   ` Nix

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).