Mercurial > emacs
comparison lisp/progmodes/c-mode.el @ 1181:5897b220ad8e
*** empty log message ***
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 20 Sep 1992 22:45:13 +0000 |
parents | 835b1e570621 |
children | 5f4300ccc93f |
comparison
equal
deleted
inserted
replaced
1180:9bf82484415d | 1181:5897b220ad8e |
---|---|
249 (setq comment-start-place (point)))))) | 249 (setq comment-start-place (point)))))) |
250 (if (or first-line | 250 (if (or first-line |
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 |
264 ;; is the appropriate part of the start of this line, | 265 ;; is the appropriate part of the start of this line, |
265 ;; up to the column at which text should be indented. | 266 ;; up to the column at which text should be indented. |
280 ;; should not be filled into paragraphs they are next to. | 281 ;; should not be filled into paragraphs they are next to. |
281 (concat paragraph-start | 282 (concat paragraph-start |
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)) |
308 (forward-line -1) | 322 (forward-line -1) |
309 (search-forward "*/") | 323 (search-forward "*/") |