unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* how to align the comments to start from the same column?
@ 2007-07-10  2:44 William Xue
  2007-07-10 11:31 ` Alan Mackenzie
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: William Xue @ 2007-07-10  2:44 UTC (permalink / raw)
  To: emacs-devel

Hi,
when I am coding in cpp files, I will use M-; to make some comments, like  
following:

                         IoCreateFileSpecifyDeviceObjectHint(&h_rd_file, //  
file handle
                                                             GENERIC_READ |  
GENERIC_WRITE, // desire access
                                                             &rd_file_obj_attr,  
// object attributes
                                                             &rd_io_status_block,  
// io status block
                                                             0, //  
allocation size
                                                             FILE_ATTRIBUTE_NORMAL,  
// file attributes
                                                             FILE_SHARE_READ,  
// share access

Is there a way to format the comments to the same column?

I want something like:

1. select the codes as a region
2. press a magic keybinding
3. the comments align to the longest column of comments in the region.

:)

-- 
Sincerely yours,
William

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

* Re: how to align the comments to start from the same column?
  2007-07-10  2:44 how to align the comments to start from the same column? William Xue
@ 2007-07-10 11:31 ` Alan Mackenzie
  2007-07-10 13:41 ` Stefan Monnier
  2007-07-13 18:18 ` Dan Nicolaescu
  2 siblings, 0 replies; 8+ messages in thread
From: Alan Mackenzie @ 2007-07-10 11:31 UTC (permalink / raw)
  To: William Xue; +Cc: emacs-devel

Hi, William!

On Tue, Jul 10, 2007 at 10:44:58AM +0800, William Xue wrote:
> Hi,
> when I am coding in cpp files, I will use M-; to make some comments, like  
> following:

>             IoCreateFileSpecifyDeviceObjectHint(&h_rd_file, // file handle
>                         GENERIC_READ |  GENERIC_WRITE, // desire access
>                             &rd_file_obj_attr,  // object attributes
>                               &rd_io_status_block,  // io status block
>                                   0, //  allocation size
>                             FILE_ATTRIBUTE_NORMAL,  // file attributes
>                             FILE_SHARE_READ,  // share access
 
[ Note: the above code appeared to go well beyond column 70.  I've
"re-unformatted" it to make it fit.  I don't think I've distorted its
meaning.]
 
> Is there a way to format the comments to the same column?

> I want something like:

> 1. select the codes as a region
> 2. press a magic keybinding
> 3. the comments align to the longest column of comments in the region.

There is nothing quite like that at the moment.  However, you can
realign the comments on each line, one after the other.  First, set the
user option comment-column to a sensible value (say, 40), whether by
customize-variable or set-variable, or whatever.  Then do M-; on each
line.  This is described on the page "Comment Commands" of the Emacs
manual.

Another point: this thread would probably be more appropriate on
help-gnu-emacs@gnu.org rather than emacs-devel.

> -- 
> Sincerely yours,
> William

-- 
Alan Mackenzie (Ittersbach, Germany).

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

* Re: how to align the comments to start from the same column?
  2007-07-10  2:44 how to align the comments to start from the same column? William Xue
  2007-07-10 11:31 ` Alan Mackenzie
@ 2007-07-10 13:41 ` Stefan Monnier
  2007-07-11  1:44   ` William Xue
  2007-07-13 18:18 ` Dan Nicolaescu
  2 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2007-07-10 13:41 UTC (permalink / raw)
  To: William Xue; +Cc: emacs-devel

> when I am coding in cpp files, I will use M-; to make some comments, like
> following:

>                         IoCreateFileSpecifyDeviceObjectHint(&h_rd_file, //
> file handle
>                                                             GENERIC_READ |
> GENERIC_WRITE, // desire access
>                                                             &rd_file_obj_attr,
> // object attributes
>                                                             &rd_io_status_block,
> // io status block
>                                                             0, //
> allocation size
>                                                             FILE_ATTRIBUTE_NORMAL,
> // file attributes
>                                                             FILE_SHARE_READ,
> // share access

> Is there a way to format the comments to the same column?

> I want something like:

> 1. select the codes as a region
> 2. press a magic keybinding
> 3. the comments align to the longest column of comments in the region.

The Emacs-22.1 version of M-; already tries to align comments on
neighbouring lines.  This feature has been slightly improved in Emacs-CVS,
but if it doesn't work for you in Emacs-22.1, then it probably won't work
any better in Emacs-CVS.

The most likely reason why it may appear not to work is that it only aligns
comments if it can do so without pushing them past the `comment-fill-column'
(which defaults to `fill-column').  So try setting this value to something
larger (or better yet: reformat your code so as not to use so many
columns ;-).


        Stefan

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

* Re: how to align the comments to start from the same column?
  2007-07-10 13:41 ` Stefan Monnier
@ 2007-07-11  1:44   ` William Xue
  2007-07-11  4:01     ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: William Xue @ 2007-07-11  1:44 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Tue, 10 Jul 2007 21:41:03 +0800, Stefan Monnier  
<monnier@iro.umontreal.ca> wrote:

>> when I am coding in cpp files, I will use M-; to make some comments,  
>> like
>> following:
>
>>                         IoCreateFileSpecifyDeviceObjectHint(&h_rd_file,  
>> //
>> file handle
>>                                                             GENERIC_READ  
>> |
>> GENERIC_WRITE, // desire access
>>                                                             &rd_file_obj_attr,
>> // object attributes
>>                                                             &rd_io_status_block,
>> // io status block
>>                                                             0, //
>> allocation size
>>                                                             FILE_ATTRIBUTE_NORMAL,
>> // file attributes
>>                                                             FILE_SHARE_READ,
>> // share access
>
>> Is there a way to format the comments to the same column?
>
>> I want something like:
>
>> 1. select the codes as a region
>> 2. press a magic keybinding
>> 3. the comments align to the longest column of comments in the region.
>
> The Emacs-22.1 version of M-; already tries to align comments on
> neighbouring lines.  This feature has been slightly improved in  
> Emacs-CVS,
> but if it doesn't work for you in Emacs-22.1, then it probably won't work
> any better in Emacs-CVS.
>
> The most likely reason why it may appear not to work is that it only  
> aligns
> comments if it can do so without pushing them past the  
> `comment-fill-column'
> (which defaults to `fill-column').  So try setting this value to  
> something
> larger (or better yet: reformat your code so as not to use so many
> columns ;-).

enlarged the value do a litter neat.

but like the following codes:
---8<--------------------------------------------->8---
BOOLEAN RDFastIoReadCompressed(IN PFILE_OBJECT FileObject,   //
                                IN PLARGE_INTEGER FileOffset, //
                                IN ULONG Length,              //
                                IN ULONG LockKey,             //
                                OUT PVOID Buffer,             //
                                OUT PMDL* MdlChain,           //
                                IN OUT PIO_STATUS_BLOCK  
IoStatus,             //
                                OUT COMPRESSED_DATA_INFO*  
CompressedDataInfo, //
                                IN ULONG  
CompressedDataInfoLength,            //
                                IN PDEVICE_OBJECT  
DeviceObject)               //
{
         return FALSE;
}
---8<--------------------------------------------->8---

the '//' of MdlChain could not be a row to  IoStatus's.

it seems M-; could not back-reference in some situation.

>
>
>         Stefan
>



-- 
Sincerely yours,
William

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

* Re: how to align the comments to start from the same column?
  2007-07-11  1:44   ` William Xue
@ 2007-07-11  4:01     ` Stefan Monnier
  2007-07-11  7:03       ` William Xue
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2007-07-11  4:01 UTC (permalink / raw)
  To: William Xue; +Cc: emacs-devel

> but like the following codes:
[...]
> the '//' of MdlChain could not be a row to  IoStatus's.

> it seems M-; could not back-reference in some situation.

I believe your example came out all wrapped, so it was not understandable.
But I believe your complaint is that if one of the lines (let's call it L)
can't be aligned, then the ones after L do not get aligned with the
ones before L.  If so, yes, it's a limitation and I'm not sure how/if it
should be lifted.



        Stefan

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

* Re: how to align the comments to start from the same column?
  2007-07-11  4:01     ` Stefan Monnier
@ 2007-07-11  7:03       ` William Xue
  0 siblings, 0 replies; 8+ messages in thread
From: William Xue @ 2007-07-11  7:03 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Wed, 11 Jul 2007 12:01:56 +0800, Stefan Monnier  
<monnier@iro.umontreal.ca> wrote:

>> but like the following codes:
> [...]
>> the '//' of MdlChain could not be a row to  IoStatus's.
>
>> it seems M-; could not back-reference in some situation.
>
> I believe your example came out all wrapped, so it was not  
> understandable.
> But I believe your complaint is that if one of the lines (let's call it  
> L)
> can't be aligned, then the ones after L do not get aligned with the
> ones before L.  If so, yes, it's a limitation and I'm not sure how/if it
> should be lifted.
>
>

Got it. Thanks for your explanation.

>
>         Stefan



-- 
Sincerely yours,
William

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

* Re: how to align the comments to start from the same column?
  2007-07-10  2:44 how to align the comments to start from the same column? William Xue
  2007-07-10 11:31 ` Alan Mackenzie
  2007-07-10 13:41 ` Stefan Monnier
@ 2007-07-13 18:18 ` Dan Nicolaescu
  2007-07-14  6:04   ` William Xue
  2 siblings, 1 reply; 8+ messages in thread
From: Dan Nicolaescu @ 2007-07-13 18:18 UTC (permalink / raw)
  To: William Xue; +Cc: emacs-devel

"William Xue" <william.xue@gmail.com> writes:

  > Hi,
  > when I am coding in cpp files, I will use M-; to make some comments,
  > like  following:
  > 
  >                         IoCreateFileSpecifyDeviceObjectHint(&h_rd_file,
  > //  file handle
  >                                                             GENERIC_READ
  > |  GENERIC_WRITE, // desire access
  >                                                             &rd_file_obj_attr,
  > // object attributes
  >                                                             &rd_io_status_block,
  > // io status block
  >                                                             0, //
  > allocation size
  >                                                             FILE_ATTRIBUTE_NORMAL,
  > // file attributes
  >                                                             FILE_SHARE_READ,
  > // share access
  > 
  > Is there a way to format the comments to the same column?
  > 
  > I want something like:
  > 
  > 1. select the codes as a region
  > 2. press a magic keybinding
  > 3. the comments align to the longest column of comments in the region.


You can find this package: 

;;; bc-mode.el --- Minor mode for formatting right-margin block comments.
;;
;; Copyright (C) 1991-1996 Steve Burgett <burgett@eecs.berkeley.edu>
;; $Id: bc-mode.el,v 1.1 1996/10/19 18:54:00 burgett Exp burgett $
;;
;; Author: Steve Burgett <burgett@eecs.berkeley.edu>
;; Created: July 1992
;; Version: 1.1
;; Keywords: comment minor-mode programming editing
;; HTTP: http://robotics.eecs.berkeley.edu/~burgett/

It has very sophisticated comment handling, I think it does what you want. 

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

* Re: how to align the comments to start from the same column?
  2007-07-13 18:18 ` Dan Nicolaescu
@ 2007-07-14  6:04   ` William Xue
  0 siblings, 0 replies; 8+ messages in thread
From: William Xue @ 2007-07-14  6:04 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: emacs-devel

On Sat, 14 Jul 2007 02:18:49 +0800, Dan Nicolaescu <dann@ics.uci.edu>  
wrote:

> "William Xue" <william.xue@gmail.com> writes:
>
>   > Hi,
>   > when I am coding in cpp files, I will use M-; to make some comments,
>   > like  following:
>   >
>   >                          
> IoCreateFileSpecifyDeviceObjectHint(&h_rd_file,
>   > //  file handle
>   >                                                              
> GENERIC_READ
>   > |  GENERIC_WRITE, // desire access
>   >                                                              
> &rd_file_obj_attr,
>   > // object attributes
>   >                                                              
> &rd_io_status_block,
>   > // io status block
>   >                                                             0, //
>   > allocation size
>   >                                                              
> FILE_ATTRIBUTE_NORMAL,
>   > // file attributes
>   >                                                              
> FILE_SHARE_READ,
>   > // share access
>   >
>   > Is there a way to format the comments to the same column?
>   >
>   > I want something like:
>   >
>   > 1. select the codes as a region
>   > 2. press a magic keybinding
>   > 3. the comments align to the longest column of comments in the  
> region.
>
>
> You can find this package:
>
> ;;; bc-mode.el --- Minor mode for formatting right-margin block comments.
> ;;
> ;; Copyright (C) 1991-1996 Steve Burgett <burgett@eecs.berkeley.edu>
> ;; $Id: bc-mode.el,v 1.1 1996/10/19 18:54:00 burgett Exp burgett $
> ;;
> ;; Author: Steve Burgett <burgett@eecs.berkeley.edu>
> ;; Created: July 1992
> ;; Version: 1.1
> ;; Keywords: comment minor-mode programming editing
> ;; HTTP: http://robotics.eecs.berkeley.edu/~burgett/
>
> It has very sophisticated comment handling, I think it does what you  
> want.

Thanks for the information. But the url seems invalid here.
I have googled about it, not found any place to download it.
---8<--------------------------------------------->8---
;;; bc-mode.el --- BC code editing commands for Emacs
;; Copyright (C) 2005  Kumar Appaiah

;; Author: Kumar Appaiah <akumar_NOSPAM@ee.iitm.ac.in>
;; Keywords:

---8<--------------------------------------------->8---
this file seems not the same with yours.

Could you send it to me by mail?
In advance thanks!

-- 
Sincerely yours,
William

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

end of thread, other threads:[~2007-07-14  6:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-10  2:44 how to align the comments to start from the same column? William Xue
2007-07-10 11:31 ` Alan Mackenzie
2007-07-10 13:41 ` Stefan Monnier
2007-07-11  1:44   ` William Xue
2007-07-11  4:01     ` Stefan Monnier
2007-07-11  7:03       ` William Xue
2007-07-13 18:18 ` Dan Nicolaescu
2007-07-14  6:04   ` William Xue

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