aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-04-09 06:47:22 +0000
committerRichard M. Stallman1995-04-09 06:47:22 +0000
commitd133d8353a50d817e7a52678f446b6a23d0b89ea (patch)
treebabb8b8a84f3c61350096caba0de2ef3eef1d909
parent144b26379606157e4ff43e1505acb2552605feb9 (diff)
downloademacs-d133d8353a50d817e7a52678f446b6a23d0b89ea.tar.gz
emacs-d133d8353a50d817e7a52678f446b6a23d0b89ea.zip
(newline): Don't indent afterward if at page sep line.
Delete whitespace on blank line before the inserted newlines. (open-line): Add all the left margins and fill prefixes after inserting all the newlines.
-rw-r--r--lisp/simple.el39
1 files changed, 29 insertions, 10 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 0b2d2d248fc..b7515e2015e 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -26,7 +26,7 @@
26;;; Code: 26;;; Code:
27 27
28(defun newline (&optional arg) 28(defun newline (&optional arg)
29 "Insert a newline and move to left margin of the new line. 29 "Insert a newline, and move to left margin of the new line if it's blank.
30The newline is marked with the text-property `hard'. 30The newline is marked with the text-property `hard'.
31With arg, insert that many newlines. 31With arg, insert that many newlines.
32In Auto Fill mode, if no numeric arg, break the preceding line if it's long." 32In Auto Fill mode, if no numeric arg, break the preceding line if it's long."
@@ -38,7 +38,10 @@ In Auto Fill mode, if no numeric arg, break the preceding line if it's long."
38 (let ((flag (and (not (bobp)) 38 (let ((flag (and (not (bobp))
39 (bolp) 39 (bolp)
40 (< (or (previous-property-change (point)) -2) 40 (< (or (previous-property-change (point)) -2)
41 (- (point) 2))))) 41 (- (point) 2))))
42 (was-page-start (and (bolp)
43 (looking-at page-delimiter)))
44 (beforepos (point)))
42 (if flag (backward-char 1)) 45 (if flag (backward-char 1))
43 ;; Call self-insert so that auto-fill, abbrev expansion etc. happens. 46 ;; Call self-insert so that auto-fill, abbrev expansion etc. happens.
44 ;; Set last-command-char to tell self-insert what to insert. 47 ;; Set last-command-char to tell self-insert what to insert.
@@ -55,26 +58,42 @@ In Auto Fill mode, if no numeric arg, break the preceding line if it's long."
55 (if (and (listp sticky) (not (memq 'hard sticky))) 58 (if (and (listp sticky) (not (memq 'hard sticky)))
56 (put-text-property from (point) 'rear-nonsticky 59 (put-text-property from (point) 'rear-nonsticky
57 (cons 'hard sticky))))) 60 (cons 'hard sticky)))))
58 (if flag (forward-char 1))) 61 ;; If the newline leaves the previous line blank,
59 (move-to-left-margin nil t) 62 ;; and we have a left margin, delete that from the blank line.
63 (or flag
64 (save-excursion
65 (goto-char beforepos)
66 (beginning-of-line)
67 (and (looking-at "[ \t]$")
68 (> (current-left-margin) 0)
69 (delete-region (point) (progn (end-of-line) (point))))))
70 (if flag (forward-char 1))
71 ;; Indent the line after the newline, except in one case:
72 ;; when we added the newline at the beginning of a line
73 ;; which starts a page.
74 (or was-page-start
75 (move-to-left-margin nil t)))
60 nil) 76 nil)
61 77
62(defun open-line (arg) 78(defun open-line (arg)
63 "Insert a newline and leave point before it. 79 "Insert a newline and leave point before it.
64If there is a fill prefix and/or a left-margin, insert them on the new line 80If there is a fill prefix and/or a left-margin, insert them on the new line
65if the line would have been empty. 81if the line would have been blank.
66With arg N, insert N newlines." 82With arg N, insert N newlines."
67 (interactive "*p") 83 (interactive "*p")
68 (let* ((do-fill-prefix (and fill-prefix (bolp))) 84 (let* ((do-fill-prefix (and fill-prefix (bolp)))
69 (do-left-margin (and (bolp) (> (current-left-margin) 0))) 85 (do-left-margin (and (bolp) (> (current-left-margin) 0)))
70 (loc (point))) 86 (loc (point)))
87 (newline arg)
88 (goto-char loc)
71 (while (> arg 0) 89 (while (> arg 0)
72 (if do-left-margin (indent-to (current-left-margin))) 90 (cond ((bolp)
73 (if do-fill-prefix (insert-and-inherit fill-prefix)) 91 (if do-left-margin (indent-to (current-left-margin)))
74 (newline 1) 92 (if do-fill-prefix (insert-and-inherit fill-prefix))))
93 (forward-line 1)
75 (setq arg (1- arg))) 94 (setq arg (1- arg)))
76 (goto-char loc)) 95 (goto-char loc)
77 (end-of-line)) 96 (end-of-line)))
78 97
79(defun split-line () 98(defun split-line ()
80 "Split current line, moving portion beyond point vertically down." 99 "Split current line, moving portion beyond point vertically down."