bug-gnu-emacs
[Top][All Lists]
Advanced

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

Re: awk-mode comment disabilities


From: Alan Mackenzie
Subject: Re: awk-mode comment disabilities
Date: 6 Jun 2001 22:55:58 +0200
Date: Wed, 6 Jun 2001 20:54:46 +0000
User-agent: tin/1.4.4-20000803 ("Vet for the Insane") (UNIX) (Linux/2.0.35 (i686))

[Newsgroups: extended]

Dan Jacobson <jidanni@kimo.fixcomthis.tw> wrote on 02 Jun 2001 04:18:02 +0800:
> Take a file.awk
> {
> a=1
> a=2
> a=3
> a=b;a=c
> a=4
> a=5
> }
> put the cursor at beginning of file, check C-h b for what smart
> indenting commands are available:
> C-c C-q           c-indent-defun
> ESC C-q           c-indent-exp
> try them out.  Nothing happens. Now do C-o to make a new blank line at
> the top of file.  Try them again, wow:
> {
>     a=1
>         a=2
>         a=3
>         a=b;a=c
>                 a=4
>                 a=5
>                 }
> awk mode shouldn't so rawly bind these c-mode functions.  By the way,
> these functions give the message "indenting region...done" which is
> incorrect, as that is the job of a different command.  They should say
> "indenting defun...done", "indenting exp...done".
> -- 

Awk mode is basically cc-mode, slightly altered.

What is happening here is that you are commanding emacs to reindent your
entire function.  The first line "a=1" gets correctly indented.  "a=2"
and "a=3" are treated as _continuations_ of "a=1" because, lacking a
semicolon, "a=1" would be an unfinished statement in the C language.
They are thus indented with respect to "a=1".

"a=b;" is treated as the continuation of, and termination of the "a=1"
statatement.  Then a new statement "a=c" begins which, as far as cc-mode
is concered, is continued by "a=4" and "a=5", which are thus indented
further. 

As a workaround, you can terminate every statement with a semicolon
(yuck!).  Alternatively, use a different editor. :-(

I have identified the place in the cc-mode source code where I think this
is happening.  I'm hoping to post a fix in the near future.

> http://www.geocities.com/jidanni Tel886-4-25854780 e-mail:restore .com.

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove one of them (leaving, say, "a").




reply via email to

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