aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/simple.el
diff options
context:
space:
mode:
authorBoris Goldowsky1995-03-01 15:09:58 +0000
committerBoris Goldowsky1995-03-01 15:09:58 +0000
commit30bb975477e40dcccd2da582cbf37f894e727fd1 (patch)
treeec91105b48625217abc89184d5ebaf584d942003 /lisp/simple.el
parent46cd263f61b019c02411795eaff6dde79316aca1 (diff)
downloademacs-30bb975477e40dcccd2da582cbf37f894e727fd1.tar.gz
emacs-30bb975477e40dcccd2da582cbf37f894e727fd1.zip
(newline): Moved from cmds.c. Indents last
inserted line to left-margin.
Diffstat (limited to 'lisp/simple.el')
-rw-r--r--lisp/simple.el34
1 files changed, 34 insertions, 0 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 01bc284d18a..b8a0e629cbd 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -25,6 +25,40 @@
25 25
26;;; Code: 26;;; Code:
27 27
28(defun newline (&optional arg)
29 "Insert a newline and move to left margin of the new line.
30The newline is marked with the text-property `hard'.
31With arg, insert that many newlines.
32In Auto Fill mode, if no numeric arg, break the preceding line if it's long."
33 (interactive "*P")
34 ;; Inserting a newline at the end of a line produces better redisplay in
35 ;; try_window_id than inserting at the beginning of a line, and the textual
36 ;; result is the same. So, if we're at beginning of line, pretend to be at
37 ;; the end of the previous line.
38 (let ((flag (and (not (bobp))
39 (bolp)
40 (< (or (previous-property-change (point)) -2)
41 (- (point) 2)))))
42 (if flag (backward-char 1))
43 ;; Call self-insert so that auto-fill, abbrev expansion etc. happens.
44 ;; Set last-command-char to tell self-insert what to insert.
45 (let ((last-command-char ?\n)
46 ;; Don't auto-fill if we have a numeric argument.
47 (auto-fill-function (if arg nil auto-fill-function)))
48 (self-insert-command (prefix-numeric-value arg)))
49 ;; Mark the newline(s) `hard'.
50 (if use-hard-newlines
51 (let* ((from (- (point) (if arg (prefix-numeric-value arg) 1)))
52 (sticky (get-text-property from 'rear-nonsticky)))
53 (put-text-property from (point) 'hard 't)
54 ;; If rear-nonsticky is not "t", add 'hard to rear-nonsticky list
55 (if (and (listp sticky) (not (memq 'hard sticky)))
56 (put-text-property from (point) 'rear-nonsticky
57 (cons 'hard sticky)))))
58 (if flag (forward-char 1)))
59 (move-to-left-margin nil t)
60 nil)
61
28(defun open-line (arg) 62(defun open-line (arg)
29 "Insert a newline and leave point before it. 63 "Insert a newline and leave point before it.
30If there is a fill prefix and/or a left-margin, insert them on the new line 64If there is a fill prefix and/or a left-margin, insert them on the new line