all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* indent-region to indent comments
@ 2003-12-10 19:56 Suhas Pai
  0 siblings, 0 replies; 2+ messages in thread
From: Suhas Pai @ 2003-12-10 19:56 UTC (permalink / raw)



If I mark a region and indent it, I find that it
only idents the source lines and not the comment lines.
If my comment-column is set, why the indenting skips
comments?  This will save me ton of time having to
do each one using "esc ;".  I could always write a macro
but I don't know how to bind a macro to a key. 

Please help.

Before:
-------

int main(int argc, char **argv)
{
   int a = 5;           // first comment
   double b = 5.0;   // second comment
   long c = 3;   // third comment
   b = a + c; // so as not to get unused variable error

   return 0;
}

Expect after ident-region:
--------------------------
int main(int argc, char **argv)
{
   int a = 5;         // first comment
   double b = 5.0;    // second comment
   long c = 3;        // third comment
   b = a + c;         // so as not to get unused variable error

   return 0;
}


Thanks,
Suhas

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

* Re: indent-region to indent comments
       [not found] <mailman.1528.1071089915.399.help-gnu-emacs@gnu.org>
@ 2003-12-10 20:30 ` Peter Milliken
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Milliken @ 2003-12-10 20:30 UTC (permalink / raw)


indent-region only works on indenting the beginnings of lines. It knows
nothing about comments on the end of lines or the contents of the lines
after the first character.

To achieve what you want, you need to use a lovely little utility called
align.el. Then you could get this:

int main(int argc, char **argv)
{
   int    a = 5;                // first comment
   double b = 5.0;              // second comment
   long   c = 3;                // third comment

   b = a + c;                   // so as not to get unused variable error

   return 0;
}

Note that the declarations are aligned as well :-) Align.el has tremendous
power and works off a set of relatively simple rules. You can create your
own alignment rules quite easily.

Peter




"Suhas Pai" <spai@qualcomm.com> wrote in message
news:mailman.1528.1071089915.399.help-gnu-emacs@gnu.org...
>
> If I mark a region and indent it, I find that it
> only idents the source lines and not the comment lines.
> If my comment-column is set, why the indenting skips
> comments?  This will save me ton of time having to
> do each one using "esc ;".  I could always write a macro
> but I don't know how to bind a macro to a key.
>
> Please help.
>
> Before:
> -------
>
> int main(int argc, char **argv)
> {
>    int a = 5;           // first comment
>    double b = 5.0;   // second comment
>    long c = 3;   // third comment
>    b = a + c; // so as not to get unused variable error
>
>    return 0;
> }
>
> Expect after ident-region:
> --------------------------
> int main(int argc, char **argv)
> {
>    int a = 5;         // first comment
>    double b = 5.0;    // second comment
>    long c = 3;        // third comment
>    b = a + c;         // so as not to get unused variable error
>
>    return 0;
> }
>
>
> Thanks,
> Suhas
>
>

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

end of thread, other threads:[~2003-12-10 20:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-10 19:56 indent-region to indent comments Suhas Pai
     [not found] <mailman.1528.1071089915.399.help-gnu-emacs@gnu.org>
2003-12-10 20:30 ` Peter Milliken

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.