diff options
| author | Eli Zaretskii | 2000-08-22 09:02:40 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2000-08-22 09:02:40 +0000 |
| commit | f91db65b1f9ed45134ecf73cb4108a7e50e10df8 (patch) | |
| tree | 57dca7de03aa61e6c9146f68156e742f8f2b4516 /man/programs.texi | |
| parent | 6d35b49fdbec015c8dc148c06c4224735c7ea9fd (diff) | |
| download | emacs-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.texi | 44 |
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-; |
| 1226 | Insert or align comment (@code{indent-for-comment}). | 1227 | Call the comment command that is appropriate for the context |
| 1228 | (@code{comment-dwim}). | ||
| 1229 | @item M-x indent-for-comment | ||
| 1230 | Insert or align comment. | ||
| 1227 | @item C-x ; | 1231 | @item C-x ; |
| 1228 | Set comment column (@code{set-comment-column}). | 1232 | Set comment column (@code{set-comment-column}). |
| 1229 | @item C-u - C-x ; | 1233 | @item C-u - C-x ; |
| 1230 | Kill comment on current line (@code{kill-comment}). | 1234 | Kill comment on current line (@code{comment-kill}). |
| 1231 | @item C-M-j | 1235 | @item C-M-j |
| 1232 | Like @key{RET} followed by inserting and aligning a comment | 1236 | Like @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 | |||
| 1235 | Add or remove comment delimiters on all the lines in the region. | 1239 | Add 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}. |
| 1239 | If there is no comment already on the line, a new comment is created, | 1243 | If there is no comment already on the line, a new comment is created, |
| 1240 | aligned at a specific column called the @dfn{comment column}. The comment | 1244 | aligned at a specific column called the @dfn{comment column}. The comment |
| 1241 | is created by inserting the string Emacs thinks comments should start with | 1245 | is 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 | |||
| 1245 | inserted). If the major mode has specified a string to terminate comments, | 1249 | inserted). If the major mode has specified a string to terminate comments, |
| 1246 | that is inserted after point, to keep the syntax valid. | 1250 | that 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 |
| 1249 | already contains the string that starts comments, then @kbd{M-;} just moves | 1253 | comment. If a line already contains the string that starts comments, |
| 1250 | point after it and reindents it to the conventional place. Exception: | 1254 | then @kbd{M-x indent-for-comment} just moves point after it and |
| 1251 | comments starting in column 0 are not moved. | 1255 | reindents it to the conventional place. Exception: comments starting in |
| 1256 | column 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}, | ||
| 1261 | as appropriate for the current context. If the region is active and the | ||
| 1262 | Transient Mark mode is on (@pxref{Transient Mark}), @kbd{M-;} invokes | ||
| 1263 | @code{comment-region}, unless the region consists only of comments, in | ||
| 1264 | which case it invokes @code{uncomment-region}. Otherwise, if the | ||
| 1265 | current line is empty, @kbd{M-;} inserts a comment and indents it. If | ||
| 1266 | the current line is not empty, @kbd{M-;} invokes @code{comment-kill} if | ||
| 1267 | a numeric argument was given, else it reindents the comment on the | ||
| 1268 | current 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 |
| 1254 | comments in certain contexts. For example, in Lisp code, comments which | 1272 | comments 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, | ||
| 1279 | if there is one. The indentation before the start of the comment is killed | 1298 | if there is one. The indentation before the start of the comment is killed |
| 1280 | as well. If there does not appear to be a comment in the line, nothing is | 1299 | as well. If there does not appear to be a comment in the line, nothing is |
| 1281 | done. To reinsert the comment on another line, move to the end of that | 1300 | done. To reinsert the comment on another line, move to the end of that |
| 1282 | line, do @kbd{C-y}, and then do @kbd{M-;} to realign it. Note that | 1301 | line, 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}) |
| 1284 | with a negative argument. That command is programmed so that when it | 1303 | with a negative argument. That command is programmed so that when it |
| 1285 | receives a negative argument it calls @code{kill-comment}. However, | 1304 | receives 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 |
| 1287 | key if you wanted to. | 1306 | key 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 ;} | |||
| 1334 | at. @kbd{C-u C-x ;} sets the comment column to match the last comment | 1354 | at. @kbd{C-u C-x ;} sets the comment column to match the last comment |
| 1335 | before point in the buffer, and then does a @kbd{M-;} to align the | 1355 | before point in the buffer, and then does a @kbd{M-;} to align the |
| 1336 | current line's comment under the previous one. Note that @kbd{C-u - C-x ;} | 1356 | current line's comment under the previous one. Note that @kbd{C-u - C-x ;} |
| 1337 | runs the function @code{kill-comment} as described above. | 1357 | runs 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 |
| 1340 | in the normal fashion affects only the current buffer, but there is a | 1360 | in the normal fashion affects only the current buffer, but there is a |