diff options
| author | Richard M. Stallman | 1992-09-20 22:45:13 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1992-09-20 22:45:13 +0000 |
| commit | f37dc9fbe5f8d8adbcde72d32a1db03dee077bac (patch) | |
| tree | ad4e5a8387043b31657cdf0e4c80846335c7b231 | |
| parent | de946e5aace1792b42d23e91aff4f5a27734ecba (diff) | |
| download | emacs-f37dc9fbe5f8d8adbcde72d32a1db03dee077bac.tar.gz emacs-f37dc9fbe5f8d8adbcde72d32a1db03dee077bac.zip | |
*** empty log message ***
| -rw-r--r-- | lisp/progmodes/c-mode.el | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/lisp/progmodes/c-mode.el b/lisp/progmodes/c-mode.el index 395d6416824..d51e67586c0 100644 --- a/lisp/progmodes/c-mode.el +++ b/lisp/progmodes/c-mode.el | |||
| @@ -251,13 +251,14 @@ preserving the comment indentation or line-starting decorations." | |||
| 251 | ;; t if we enter a comment between start of function and this line. | 251 | ;; t if we enter a comment between start of function and this line. |
| 252 | (eq (calculate-c-indent) t) | 252 | (eq (calculate-c-indent) t) |
| 253 | ;; t if this line contains a comment starter. | 253 | ;; t if this line contains a comment starter. |
| 254 | (save-excursion (beginning-of-line) | 254 | (setq first-line |
| 255 | (prog1 | 255 | (save-excursion (beginning-of-line) |
| 256 | (re-search-forward comment-start-skip | 256 | (prog1 |
| 257 | (save-excursion (end-of-line) | 257 | (re-search-forward comment-start-skip |
| 258 | (point)) | 258 | (save-excursion (end-of-line) |
| 259 | t) | 259 | (point)) |
| 260 | (setq comment-start-place (point))))) | 260 | t) |
| 261 | (setq comment-start-place (point)))))) | ||
| 261 | ;; Inside a comment: fill one comment paragraph. | 262 | ;; Inside a comment: fill one comment paragraph. |
| 262 | (let ((fill-prefix | 263 | (let ((fill-prefix |
| 263 | ;; The prefix for each line of this paragraph | 264 | ;; The prefix for each line of this paragraph |
| @@ -282,26 +283,39 @@ preserving the comment indentation or line-starting decorations." | |||
| 282 | "\\|^[ \t]*/\\*[ \t]*$\\|^[ \t]*\\*/[ \t]*$\\|^[^ \t/*]")) | 283 | "\\|^[ \t]*/\\*[ \t]*$\\|^[ \t]*\\*/[ \t]*$\\|^[^ \t/*]")) |
| 283 | (paragraph-separate | 284 | (paragraph-separate |
| 284 | (concat paragraph-separate | 285 | (concat paragraph-separate |
| 285 | "\\|^[ \t]*/\\*[ \t]*$\\|^[ \t]*\\*/[ \t]*$\\|^[^ \t/*]"))) | 286 | "\\|^[ \t]*/\\*[ \t]*$\\|^[ \t]*\\*/[ \t]*$\\|^[^ \t/*]")) |
| 287 | (chars-to-delete 0)) | ||
| 286 | (save-restriction | 288 | (save-restriction |
| 287 | ;; Don't fill the comment together with the code following it. | 289 | ;; Don't fill the comment together with the code following it. |
| 288 | ;; So temporarily exclude everything before the comment start, | 290 | ;; So temporarily exclude everything before the comment start, |
| 289 | ;; and everything after the line where the comment ends. | 291 | ;; and everything after the line where the comment ends. |
| 290 | ;; If comment-start-place is non-nil, the comment starter is there. | 292 | ;; If comment-start-place is non-nil, the comment starter is there. |
| 291 | ;; Otherwise, point is inside the comment. | 293 | ;; Otherwise, point is inside the comment. |
| 292 | (narrow-to-region (or comment-start-place | 294 | (narrow-to-region (save-excursion |
| 293 | (save-excursion | 295 | (if comment-start-place |
| 294 | (search-backward "/*") | 296 | (goto-char comment-start-place) |
| 295 | (beginning-of-line) | 297 | (search-backward "/*")) |
| 296 | (point))) | 298 | ;; Protect text before the comment start |
| 299 | ;; by excluding it. Add spaces to bring back | ||
| 300 | ;; proper indentation of that point. | ||
| 301 | (let ((column (current-column))) | ||
| 302 | (prog1 (point) | ||
| 303 | (setq chars-to-delete column) | ||
| 304 | (insert-char ?\ column)))) | ||
| 297 | (save-excursion | 305 | (save-excursion |
| 298 | (if comment-start-place | 306 | (if comment-start-place |
| 299 | (goto-char (+ comment-start-place 2))) | 307 | (goto-char (+ comment-start-place 2))) |
| 300 | (search-forward "*/" nil 'move) | 308 | (search-forward "*/" nil 'move) |
| 301 | (forward-line 1) | 309 | (forward-line 1) |
| 302 | (point))) | 310 | (point))) |
| 311 | |||
| 303 | (fill-paragraph arg) | 312 | (fill-paragraph arg) |
| 304 | (save-excursion | 313 | (save-excursion |
| 314 | ;; Delete the chars we inserted to avoid clobbering | ||
| 315 | ;; the stuff before the comment start. | ||
| 316 | (goto-char (point-min)) | ||
| 317 | (if (> chars-to-delete 0) | ||
| 318 | (delete-region (point) (+ (point) chars-to-delete))) | ||
| 305 | ;; Find the comment ender (should be on last line of buffer, | 319 | ;; Find the comment ender (should be on last line of buffer, |
| 306 | ;; given the narrowing) and don't leave it on its own line. | 320 | ;; given the narrowing) and don't leave it on its own line. |
| 307 | (goto-char (point-max)) | 321 | (goto-char (point-max)) |