Mercurial > emacs
comparison lisp/simple.el @ 12624:8ba65cbc8abe
(indent-new-comment-line): fill-prefix overrides comment indentation.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 21 Jul 1995 01:43:21 +0000 |
parents | c0a5d0d00c18 |
children | 1a81e79198c6 |
comparison
equal
deleted
inserted
replaced
12623:903fb74f5b36 | 12624:8ba65cbc8abe |
---|---|
2417 | 2417 |
2418 This command is intended for styles where you write a comment per line, | 2418 This command is intended for styles where you write a comment per line, |
2419 starting a new comment (and terminating it if necessary) on each line. | 2419 starting a new comment (and terminating it if necessary) on each line. |
2420 If you want to continue one comment across several lines, use \\[newline-and-indent]. | 2420 If you want to continue one comment across several lines, use \\[newline-and-indent]. |
2421 | 2421 |
2422 If a fill column is specified, it overrides the use of the comment column | |
2423 or comment indentation. | |
2424 | |
2422 The inserted newline is marked hard if `use-hard-newlines' is true, | 2425 The inserted newline is marked hard if `use-hard-newlines' is true, |
2423 unless optional argument SOFT is non-nil." | 2426 unless optional argument SOFT is non-nil." |
2424 (interactive) | 2427 (interactive) |
2425 (let (comcol comstart) | 2428 (let (comcol comstart) |
2426 (skip-chars-backward " \t") | 2429 (skip-chars-backward " \t") |
2427 (delete-region (point) | 2430 (delete-region (point) |
2428 (progn (skip-chars-forward " \t") | 2431 (progn (skip-chars-forward " \t") |
2429 (point))) | 2432 (point))) |
2430 (if soft (insert-and-inherit ?\n) (newline 1)) | 2433 (if soft (insert-and-inherit ?\n) (newline 1)) |
2431 (if (not comment-multi-line) | 2434 (if fill-prefix |
2432 (save-excursion | 2435 (progn |
2433 (if (and comment-start-skip | 2436 (indent-to-left-margin) |
2434 (let ((opoint (point))) | 2437 (insert-and-inherit fill-prefix)) |
2435 (forward-line -1) | 2438 (if (not comment-multi-line) |
2436 (re-search-forward comment-start-skip opoint t))) | |
2437 ;; The old line is a comment. | |
2438 ;; Set WIN to the pos of the comment-start. | |
2439 ;; But if the comment is empty, look at preceding lines | |
2440 ;; to find one that has a nonempty comment. | |
2441 | |
2442 ;; If comment-start-skip contains a \(...\) pair, | |
2443 ;; the real comment delimiter starts at the end of that pair. | |
2444 (let ((win (or (match-end 1) (match-beginning 0)))) | |
2445 (while (and (eolp) (not (bobp)) | |
2446 (let (opoint) | |
2447 (beginning-of-line) | |
2448 (setq opoint (point)) | |
2449 (forward-line -1) | |
2450 (re-search-forward comment-start-skip opoint t))) | |
2451 (setq win (or (match-end 1) (match-beginning 0)))) | |
2452 ;; Indent this line like what we found. | |
2453 (goto-char win) | |
2454 (setq comcol (current-column)) | |
2455 (setq comstart | |
2456 (buffer-substring (point) (match-end 0))))))) | |
2457 (if comcol | |
2458 (let ((comment-column comcol) | |
2459 (comment-start comstart) | |
2460 (comment-end comment-end)) | |
2461 (and comment-end (not (equal comment-end "")) | |
2462 ; (if (not comment-multi-line) | |
2463 (progn | |
2464 (forward-char -1) | |
2465 (insert comment-end) | |
2466 (forward-char 1)) | |
2467 ; (setq comment-column (+ comment-column (length comment-start)) | |
2468 ; comment-start "") | |
2469 ; ) | |
2470 ) | |
2471 (if (not (eolp)) | |
2472 (setq comment-end "")) | |
2473 (insert-and-inherit ?\n) | |
2474 (forward-char -1) | |
2475 (indent-for-comment) | |
2476 (save-excursion | 2439 (save-excursion |
2477 ;; Make sure we delete the newline inserted above. | 2440 (if (and comment-start-skip |
2478 (end-of-line) | 2441 (let ((opoint (point))) |
2479 (delete-char 1))) | 2442 (forward-line -1) |
2480 (if (null fill-prefix) | 2443 (re-search-forward comment-start-skip opoint t))) |
2481 (indent-according-to-mode) | 2444 ;; The old line is a comment. |
2482 (indent-to-left-margin) | 2445 ;; Set WIN to the pos of the comment-start. |
2483 (insert-and-inherit fill-prefix))))) | 2446 ;; But if the comment is empty, look at preceding lines |
2447 ;; to find one that has a nonempty comment. | |
2448 | |
2449 ;; If comment-start-skip contains a \(...\) pair, | |
2450 ;; the real comment delimiter starts at the end of that pair. | |
2451 (let ((win (or (match-end 1) (match-beginning 0)))) | |
2452 (while (and (eolp) (not (bobp)) | |
2453 (let (opoint) | |
2454 (beginning-of-line) | |
2455 (setq opoint (point)) | |
2456 (forward-line -1) | |
2457 (re-search-forward comment-start-skip opoint t))) | |
2458 (setq win (or (match-end 1) (match-beginning 0)))) | |
2459 ;; Indent this line like what we found. | |
2460 (goto-char win) | |
2461 (setq comcol (current-column)) | |
2462 (setq comstart | |
2463 (buffer-substring (point) (match-end 0))))))) | |
2464 (if comcol | |
2465 (let ((comment-column comcol) | |
2466 (comment-start comstart) | |
2467 (comment-end comment-end)) | |
2468 (and comment-end (not (equal comment-end "")) | |
2469 ; (if (not comment-multi-line) | |
2470 (progn | |
2471 (forward-char -1) | |
2472 (insert comment-end) | |
2473 (forward-char 1)) | |
2474 ; (setq comment-column (+ comment-column (length comment-start)) | |
2475 ; comment-start "") | |
2476 ; ) | |
2477 ) | |
2478 (if (not (eolp)) | |
2479 (setq comment-end "")) | |
2480 (insert-and-inherit ?\n) | |
2481 (forward-char -1) | |
2482 (indent-for-comment) | |
2483 (save-excursion | |
2484 ;; Make sure we delete the newline inserted above. | |
2485 (end-of-line) | |
2486 (delete-char 1))) | |
2487 (indent-according-to-mode))))) | |
2484 | 2488 |
2485 (defun set-selective-display (arg) | 2489 (defun set-selective-display (arg) |
2486 "Set `selective-display' to ARG; clear it if no arg. | 2490 "Set `selective-display' to ARG; clear it if no arg. |
2487 When the value of `selective-display' is a number > 0, | 2491 When the value of `selective-display' is a number > 0, |
2488 lines whose indentation is >= that value are not displayed. | 2492 lines whose indentation is >= that value are not displayed. |