aboutsummaryrefslogtreecommitdiffstats
path: root/man/programs.texi
diff options
context:
space:
mode:
authorEli Zaretskii2000-08-22 09:02:40 +0000
committerEli Zaretskii2000-08-22 09:02:40 +0000
commitf91db65b1f9ed45134ecf73cb4108a7e50e10df8 (patch)
tree57dca7de03aa61e6c9146f68156e742f8f2b4516 /man/programs.texi
parent6d35b49fdbec015c8dc148c06c4224735c7ea9fd (diff)
downloademacs-f91db65b1f9ed45134ecf73cb4108a7e50e10df8.tar.gz
emacs-f91db65b1f9ed45134ecf73cb4108a7e50e10df8.zip
Document comment-dwim and the new binding of M-;.
Document that kill-comment is now an alias for comment-kill.
Diffstat (limited to 'man/programs.texi')
-rw-r--r--man/programs.texi44
1 files changed, 32 insertions, 12 deletions
diff --git a/man/programs.texi b/man/programs.texi
index fd5fd2737d9..b2a1f4c15cc 100644
--- a/man/programs.texi
+++ b/man/programs.texi
@@ -1217,17 +1217,21 @@ provides special commands for editing and inserting comments.
1217@kindex M-; 1217@kindex M-;
1218@cindex indentation for comments 1218@cindex indentation for comments
1219@findex indent-for-comment 1219@findex indent-for-comment
1220@findex comment-dwim
1220 1221
1221 The comment commands insert, kill and align comments. 1222 The comment commands insert, kill and align comments.
1222 1223
1223@c WideCommands 1224@c WideCommands
1224@table @kbd 1225@table @kbd
1225@item M-; 1226@item M-;
1226Insert or align comment (@code{indent-for-comment}). 1227Call the comment command that is appropriate for the context
1228(@code{comment-dwim}).
1229@item M-x indent-for-comment
1230Insert or align comment.
1227@item C-x ; 1231@item C-x ;
1228Set comment column (@code{set-comment-column}). 1232Set comment column (@code{set-comment-column}).
1229@item C-u - C-x ; 1233@item C-u - C-x ;
1230Kill comment on current line (@code{kill-comment}). 1234Kill comment on current line (@code{comment-kill}).
1231@item C-M-j 1235@item C-M-j
1232Like @key{RET} followed by inserting and aligning a comment 1236Like @key{RET} followed by inserting and aligning a comment
1233(@code{indent-new-comment-line}). 1237(@code{indent-new-comment-line}).
@@ -1235,7 +1239,7 @@ Like @key{RET} followed by inserting and aligning a comment
1235Add or remove comment delimiters on all the lines in the region. 1239Add or remove comment delimiters on all the lines in the region.
1236@end table 1240@end table
1237 1241
1238 The command that creates a comment is @kbd{M-;} (@code{indent-for-comment}). 1242 The command that creates a comment is @kbd{M-x indent-for-comment}.
1239If there is no comment already on the line, a new comment is created, 1243If there is no comment already on the line, a new comment is created,
1240aligned at a specific column called the @dfn{comment column}. The comment 1244aligned at a specific column called the @dfn{comment column}. The comment
1241is created by inserting the string Emacs thinks comments should start with 1245is created by inserting the string Emacs thinks comments should start with
@@ -1245,10 +1249,24 @@ indentation is done to a suitable boundary (usually, at least one space is
1245inserted). If the major mode has specified a string to terminate comments, 1249inserted). If the major mode has specified a string to terminate comments,
1246that is inserted after point, to keep the syntax valid. 1250that is inserted after point, to keep the syntax valid.
1247 1251
1248 @kbd{M-;} can also be used to align an existing comment. If a line 1252 @kbd{M-x indent-for-comment} can also be used to align an existing
1249already contains the string that starts comments, then @kbd{M-;} just moves 1253comment. If a line already contains the string that starts comments,
1250point after it and reindents it to the conventional place. Exception: 1254then @kbd{M-x indent-for-comment} just moves point after it and
1251comments starting in column 0 are not moved. 1255reindents it to the conventional place. Exception: comments starting in
1256column 0 are not moved.
1257
1258 @kbd{M-;} (@code{comment-dwim}) conveniently combines
1259@code{indent-for-comment} with @code{comment-region} and
1260@code{uncomment-region}, described below in @ref{Multi-Line Comments},
1261as appropriate for the current context. If the region is active and the
1262Transient Mark mode is on (@pxref{Transient Mark}), @kbd{M-;} invokes
1263@code{comment-region}, unless the region consists only of comments, in
1264which case it invokes @code{uncomment-region}. Otherwise, if the
1265current line is empty, @kbd{M-;} inserts a comment and indents it. If
1266the current line is not empty, @kbd{M-;} invokes @code{comment-kill} if
1267a numeric argument was given, else it reindents the comment on the
1268current line. (The @dfn{dwim} in @code{comment-dwim} is an acronym for
1269``Do What I Mean''.)
1252 1270
1253 Some major modes have special rules for indenting certain kinds of 1271 Some major modes have special rules for indenting certain kinds of
1254comments in certain contexts. For example, in Lisp code, comments which 1272comments in certain contexts. For example, in Lisp code, comments which
@@ -1275,16 +1293,18 @@ useful for moving directly to the start of the comment.
1275 1293
1276@kindex C-u - C-x ; 1294@kindex C-u - C-x ;
1277@findex kill-comment 1295@findex kill-comment
1278 @kbd{C-u - C-x ;} (@code{kill-comment}) kills the comment on the current line, 1296@findex comment-kill
1297 @kbd{C-u - C-x ;} (@code{comment-kill}) kills the comment on the current line,
1279if there is one. The indentation before the start of the comment is killed 1298if there is one. The indentation before the start of the comment is killed
1280as well. If there does not appear to be a comment in the line, nothing is 1299as well. If there does not appear to be a comment in the line, nothing is
1281done. To reinsert the comment on another line, move to the end of that 1300done. To reinsert the comment on another line, move to the end of that
1282line, do @kbd{C-y}, and then do @kbd{M-;} to realign it. Note that 1301line, do @kbd{C-y}, and then do @kbd{M-;} to realign it. Note that
1283@kbd{C-u - C-x ;} is not a distinct key; it is @kbd{C-x ;} (@code{set-comment-column}) 1302@kbd{C-u - C-x ;} is not a distinct key; it is @kbd{C-x ;} (@code{set-comment-column})
1284with a negative argument. That command is programmed so that when it 1303with a negative argument. That command is programmed so that when it
1285receives a negative argument it calls @code{kill-comment}. However, 1304receives a negative argument it calls @code{comment-kill}. However,
1286@code{kill-comment} is a valid command which you could bind directly to a 1305@code{comment-kill} is a valid command which you could bind directly to a
1287key if you wanted to. 1306key if you wanted to. (For compatibility with previous versions,
1307@code{kill-comment} is provided as an alias to @code{comment-kill}.)
1288 1308
1289@node Multi-Line Comments 1309@node Multi-Line Comments
1290@subsection Multiple Lines of Comments 1310@subsection Multiple Lines of Comments
@@ -1334,7 +1354,7 @@ can set it to a number explicitly. Alternatively, the command @kbd{C-x ;}
1334at. @kbd{C-u C-x ;} sets the comment column to match the last comment 1354at. @kbd{C-u C-x ;} sets the comment column to match the last comment
1335before point in the buffer, and then does a @kbd{M-;} to align the 1355before point in the buffer, and then does a @kbd{M-;} to align the
1336current line's comment under the previous one. Note that @kbd{C-u - C-x ;} 1356current line's comment under the previous one. Note that @kbd{C-u - C-x ;}
1337runs the function @code{kill-comment} as described above. 1357runs the function @code{comment-kill} as described above.
1338 1358
1339 The variable @code{comment-column} is per-buffer: setting the variable 1359 The variable @code{comment-column} is per-buffer: setting the variable
1340in the normal fashion affects only the current buffer, but there is a 1360in the normal fashion affects only the current buffer, but there is a