diff options
| author | Richard M. Stallman | 1995-01-13 08:43:40 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-01-13 08:43:40 +0000 |
| commit | 28191e20b40f815347504ef92c4ca1a535d5ca80 (patch) | |
| tree | 612eaa4be175df2ac84480dd45244dce5fe2991b | |
| parent | e24af5f5291aab476433338892f837e0d5717bd8 (diff) | |
| download | emacs-28191e20b40f815347504ef92c4ca1a535d5ca80.tar.gz emacs-28191e20b40f815347504ef92c4ca1a535d5ca80.zip | |
(open-line, split-line, next-line): Use `newline'
function to insert newline so it will be marked hard if appropriate.
(indent-new-comment-line): Use `newline' function, unless called
with (new) argument.
(do-auto-fill): Call indent-new-comment-line with argument to
make newline soft.
| -rw-r--r-- | lisp/simple.el | 45 |
1 files changed, 18 insertions, 27 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index a9b8b0018d8..6beae8b9464 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -32,25 +32,13 @@ if the line would have been empty. | |||
| 32 | With arg N, insert N newlines." | 32 | With arg N, insert N newlines." |
| 33 | (interactive "*p") | 33 | (interactive "*p") |
| 34 | (let* ((do-fill-prefix (and fill-prefix (bolp))) | 34 | (let* ((do-fill-prefix (and fill-prefix (bolp))) |
| 35 | (flag (and (null do-fill-prefix) (bolp) (not (bobp))))) | 35 | (loc (point))) |
| 36 | ;; If this is a simple case, and we are at the beginning of a line, | 36 | (while (> arg 0) |
| 37 | ;; actually insert the newline *before* the preceding newline | 37 | (if do-fill-prefix (insert fill-prefix)) |
| 38 | ;; instead of after. That makes better display behavior. | 38 | (newline 1) |
| 39 | (if flag | 39 | (setq arg (1- arg))) |
| 40 | (progn | 40 | (goto-char loc)) |
| 41 | ;; If undo is enabled, don't let this hack be visible: | 41 | (end-of-line)) |
| 42 | ;; record the real value of point as the place to move back to | ||
| 43 | ;; if we undo this insert. | ||
| 44 | (if (not (eq buffer-undo-list t)) | ||
| 45 | (setq buffer-undo-list (cons (point) buffer-undo-list))) | ||
| 46 | (forward-char -1))) | ||
| 47 | (save-excursion | ||
| 48 | (while (> arg 0) | ||
| 49 | (if do-fill-prefix (insert fill-prefix)) | ||
| 50 | (insert ?\n) | ||
| 51 | (setq arg (1- arg)))) | ||
| 52 | (end-of-line) | ||
| 53 | (if flag (forward-char 1)))) | ||
| 54 | 42 | ||
| 55 | (defun split-line () | 43 | (defun split-line () |
| 56 | "Split current line, moving portion beyond point vertically down." | 44 | "Split current line, moving portion beyond point vertically down." |
| @@ -58,7 +46,7 @@ With arg N, insert N newlines." | |||
| 58 | (skip-chars-forward " \t") | 46 | (skip-chars-forward " \t") |
| 59 | (let ((col (current-column)) | 47 | (let ((col (current-column)) |
| 60 | (pos (point))) | 48 | (pos (point))) |
| 61 | (insert ?\n) | 49 | (newline 1) |
| 62 | (indent-to col 0) | 50 | (indent-to col 0) |
| 63 | (goto-char pos))) | 51 | (goto-char pos))) |
| 64 | 52 | ||
| @@ -1554,7 +1542,7 @@ and more reliable (no dependence on goal column, etc.)." | |||
| 1554 | (let ((opoint (point))) | 1542 | (let ((opoint (point))) |
| 1555 | (end-of-line) | 1543 | (end-of-line) |
| 1556 | (if (eobp) | 1544 | (if (eobp) |
| 1557 | (insert ?\n) | 1545 | (newline 1) |
| 1558 | (goto-char opoint) | 1546 | (goto-char opoint) |
| 1559 | (line-move arg))) | 1547 | (line-move arg))) |
| 1560 | (if (interactive-p) | 1548 | (if (interactive-p) |
| @@ -2222,10 +2210,10 @@ Setting this variable automatically makes it local to the current buffer.") | |||
| 2222 | (if (save-excursion | 2210 | (if (save-excursion |
| 2223 | (skip-chars-backward " \t") | 2211 | (skip-chars-backward " \t") |
| 2224 | (= (point) fill-point)) | 2212 | (= (point) fill-point)) |
| 2225 | (indent-new-comment-line) | 2213 | (indent-new-comment-line t) |
| 2226 | (save-excursion | 2214 | (save-excursion |
| 2227 | (goto-char fill-point) | 2215 | (goto-char fill-point) |
| 2228 | (indent-new-comment-line))) | 2216 | (indent-new-comment-line t))) |
| 2229 | ;; If making the new line didn't reduce the hpos of | 2217 | ;; If making the new line didn't reduce the hpos of |
| 2230 | ;; the end of the line, then give up now; | 2218 | ;; the end of the line, then give up now; |
| 2231 | ;; trying again will not help. | 2219 | ;; trying again will not help. |
| @@ -2270,21 +2258,24 @@ The variable `fill-column' has a separate value for each buffer." | |||
| 2270 | on new line, with no new terminator or starter. | 2258 | on new line, with no new terminator or starter. |
| 2271 | This is obsolete because you might as well use \\[newline-and-indent].") | 2259 | This is obsolete because you might as well use \\[newline-and-indent].") |
| 2272 | 2260 | ||
| 2273 | (defun indent-new-comment-line () | 2261 | (defun indent-new-comment-line (&optional soft) |
| 2274 | "Break line at point and indent, continuing comment if within one. | 2262 | "Break line at point and indent, continuing comment if within one. |
| 2275 | This indents the body of the continued comment | 2263 | This indents the body of the continued comment |
| 2276 | under the previous comment line. | 2264 | under the previous comment line. |
| 2277 | 2265 | ||
| 2278 | This command is intended for styles where you write a comment per line, | 2266 | This command is intended for styles where you write a comment per line, |
| 2279 | starting a new comment (and terminating it if necessary) on each line. | 2267 | starting a new comment (and terminating it if necessary) on each line. |
| 2280 | If you want to continue one comment across several lines, use \\[newline-and-indent]." | 2268 | If you want to continue one comment across several lines, use \\[newline-and-indent]. |
| 2281 | (interactive "*") | 2269 | |
| 2270 | The inserted newline is marked hard if `use-hard-newlines' is true, | ||
| 2271 | unless optional argument SOFT is non-nil." | ||
| 2272 | (interactive) | ||
| 2282 | (let (comcol comstart) | 2273 | (let (comcol comstart) |
| 2283 | (skip-chars-backward " \t") | 2274 | (skip-chars-backward " \t") |
| 2284 | (delete-region (point) | 2275 | (delete-region (point) |
| 2285 | (progn (skip-chars-forward " \t") | 2276 | (progn (skip-chars-forward " \t") |
| 2286 | (point))) | 2277 | (point))) |
| 2287 | (insert ?\n) | 2278 | (if soft (insert ?\n) (newline 1)) |
| 2288 | (if (not comment-multi-line) | 2279 | (if (not comment-multi-line) |
| 2289 | (save-excursion | 2280 | (save-excursion |
| 2290 | (if (and comment-start-skip | 2281 | (if (and comment-start-skip |