Next: , Previous: , Up: Editing Programs   [Contents][Index]


7.1 Comment Manipulation

Hemlock has commenting commands which can be used in almost any language. The behavior of these commands is determined by several Hemlock variables which language modes should define appropriately.

Command: Indent for Comment (bound to M-;)

This is the most basic commenting command. If there is already a comment on the current line, then this moves the point to the start of the comment. If there no comment, this creates an empty one.

This command normally indents the comment to start at Comment Column. The comment indents differently in the following cases:

  1. If the comment currently starts at the beginning of the line, or if the last character in the Comment Start appears three times, then the comment remains unmoved.
  2. If the last character in the Comment Start appears two times, then the comment is indented like a line of code.
  3. If text on the line prevents the comment occurring in the desired position, this places the comment at the end of the line, separated from the text by a space.

Although the rules about replication in the comment start are oriented toward Lisp commenting styles, you can exploit these properties in other languages.

When given a prefix argument, this command indents any existing comment on that many consecutive lines. This is useful for fixing up the indentation of a group of comments.

Command: Indent New Comment Line (bound to M-j, M-Linefeed)

This commend ends the current comment and starts a new comment on a blank line, indenting the comment the same way that Indent for Comment does. When not in a comment, this command is the same as Indent New Line.

Command: Up Comment Line (bound to M-p)
Command: Down Comment Line (bound to M-n)

These commands are similar to Previous Line or Next Line followed by Indent for Comment. Any empty comment on the current line is deleted before moving to the new line.

Command: Kill Comment (bound to C-M-;)

This command kills any comment on the current line. When given a prefix argument, it kills comments on that many consecutive lines. Undo will restore the unmodified text.

Command: Set Comment Column (bound to C-x ;)

This command sets the comment column to its prefix argument. If used without a prefix argument, it sets the comment column to the column the point is at.

Hemlock Variable: Comment Start (initial value nil)
Hemlock Variable: Comment End (initial value nil)
Hemlock Variable: Comment Begin (initial value nil)
Hemlock Variable: Comment Column (initial value 0)

These variables determine the behavior of the comment commands.

Comment Start

The string which indicates the start of a comment. If this is nil, then there is no defined comment syntax.

Comment End

The string which ends a comment. If this is nil, then the comment is terminated by the end of the line.

Comment Begin

The string inserted to begin a new comment.

Comment Column

The column that normal comments start at.


Next: Indentation, Previous: Editing Programs, Up: Editing Programs   [Contents][Index]