aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-07-21 01:43:21 +0000
committerRichard M. Stallman1995-07-21 01:43:21 +0000
commit3a0c47555c3aa253cceca709812fccf48a6ed77c (patch)
tree72b5542b212567900e761dc44b292a1601f01cf6
parent9db1775aa6b915a8c2c77e605f3b9a8683bc035f (diff)
downloademacs-3a0c47555c3aa253cceca709812fccf48a6ed77c.tar.gz
emacs-3a0c47555c3aa253cceca709812fccf48a6ed77c.zip
(indent-new-comment-line): fill-prefix overrides comment indentation.
-rw-r--r--lisp/simple.el108
1 files changed, 56 insertions, 52 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 0b69cf6ed68..eae4cb1b482 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2419,6 +2419,9 @@ This command is intended for styles where you write a comment per line,
2419starting a new comment (and terminating it if necessary) on each line. 2419starting a new comment (and terminating it if necessary) on each line.
2420If you want to continue one comment across several lines, use \\[newline-and-indent]. 2420If you want to continue one comment across several lines, use \\[newline-and-indent].
2421 2421
2422If a fill column is specified, it overrides the use of the comment column
2423or comment indentation.
2424
2422The inserted newline is marked hard if `use-hard-newlines' is true, 2425The inserted newline is marked hard if `use-hard-newlines' is true,
2423unless optional argument SOFT is non-nil." 2426unless optional argument SOFT is non-nil."
2424 (interactive) 2427 (interactive)
@@ -2428,59 +2431,60 @@ unless optional argument SOFT is non-nil."
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.