diff options
| author | Glenn Morris | 2007-11-03 03:00:32 +0000 |
|---|---|---|
| committer | Glenn Morris | 2007-11-03 03:00:32 +0000 |
| commit | eb0c4c308497fa8af6ee20354d4168898743f334 (patch) | |
| tree | 445a1fe8cb080fe2bc050f80e7bacf7cd02d398c | |
| parent | cfe80861d875ba3e7b4424df59b72dde0be9360b (diff) | |
| download | emacs-eb0c4c308497fa8af6ee20354d4168898743f334.tar.gz emacs-eb0c4c308497fa8af6ee20354d4168898743f334.zip | |
(comment-dwim): Call comment-insert-comment-function, if defined, for
blank lines. Doc fix.
| -rw-r--r-- | lisp/newcomment.el | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/lisp/newcomment.el b/lisp/newcomment.el index dbc07f5bad0..2de4fa025fd 100644 --- a/lisp/newcomment.el +++ b/lisp/newcomment.el | |||
| @@ -1152,7 +1152,8 @@ is passed on to the respective function." | |||
| 1152 | If the region is active and `transient-mark-mode' is on, call | 1152 | If the region is active and `transient-mark-mode' is on, call |
| 1153 | `comment-region' (unless it only consists of comments, in which | 1153 | `comment-region' (unless it only consists of comments, in which |
| 1154 | case it calls `uncomment-region'). | 1154 | case it calls `uncomment-region'). |
| 1155 | Else, if the current line is empty, insert a comment and indent it. | 1155 | Else, if the current line is empty, call `comment-insert-comment-function' |
| 1156 | if it is defined, otherwise insert a comment and indent it. | ||
| 1156 | Else if a prefix ARG is specified, call `comment-kill'. | 1157 | Else if a prefix ARG is specified, call `comment-kill'. |
| 1157 | Else, call `comment-indent'. | 1158 | Else, call `comment-indent'. |
| 1158 | You can configure `comment-style' to change the way regions are commented." | 1159 | You can configure `comment-style' to change the way regions are commented." |
| @@ -1164,15 +1165,19 @@ You can configure `comment-style' to change the way regions are commented." | |||
| 1164 | ;; FIXME: If there's no comment to kill on this line and ARG is | 1165 | ;; FIXME: If there's no comment to kill on this line and ARG is |
| 1165 | ;; specified, calling comment-kill is not very clever. | 1166 | ;; specified, calling comment-kill is not very clever. |
| 1166 | (if arg (comment-kill (and (integerp arg) arg)) (comment-indent)) | 1167 | (if arg (comment-kill (and (integerp arg) arg)) (comment-indent)) |
| 1167 | (let ((add (comment-add arg))) | 1168 | ;; Inserting a comment on a blank line. comment-indent calls |
| 1168 | ;; Some modes insist on keeping column 0 comment in column 0 | 1169 | ;; c-i-c-f if needed in the non-blank case. |
| 1169 | ;; so we need to move away from it before inserting the comment. | 1170 | (if comment-insert-comment-function |
| 1170 | (indent-according-to-mode) | 1171 | (funcall comment-insert-comment-function) |
| 1171 | (insert (comment-padright comment-start add)) | 1172 | (let ((add (comment-add arg))) |
| 1172 | (save-excursion | 1173 | ;; Some modes insist on keeping column 0 comment in column 0 |
| 1173 | (unless (string= "" comment-end) | 1174 | ;; so we need to move away from it before inserting the comment. |
| 1174 | (insert (comment-padleft comment-end add))) | 1175 | (indent-according-to-mode) |
| 1175 | (indent-according-to-mode)))))) | 1176 | (insert (comment-padright comment-start add)) |
| 1177 | (save-excursion | ||
| 1178 | (unless (string= "" comment-end) | ||
| 1179 | (insert (comment-padleft comment-end add))) | ||
| 1180 | (indent-according-to-mode))))))) | ||
| 1176 | 1181 | ||
| 1177 | ;;;###autoload | 1182 | ;;;###autoload |
| 1178 | (defcustom comment-auto-fill-only-comments nil | 1183 | (defcustom comment-auto-fill-only-comments nil |