aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2003-01-06 01:17:19 +0000
committerRichard M. Stallman2003-01-06 01:17:19 +0000
commitd77bbdc98d25c66a078e21d9bf785b59e9eabc2b (patch)
tree34c9656ac2f7f9b4e713491e823a16861c22b490
parentceabd2726c4170795dbe21778d223fdb1855667f (diff)
downloademacs-d77bbdc98d25c66a078e21d9bf785b59e9eabc2b.tar.gz
emacs-d77bbdc98d25c66a078e21d9bf785b59e9eabc2b.zip
(split-line): Clean up implementation.
-rw-r--r--lisp/simple.el23
1 files changed, 12 insertions, 11 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index d6583c8f963..f93b819e351 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -181,7 +181,6 @@ With arg N, insert N newlines."
181 (goto-char loc) 181 (goto-char loc)
182 (end-of-line))) 182 (end-of-line)))
183 183
184
185(defun split-line (&optional arg) 184(defun split-line (&optional arg)
186 "Split current line, moving portion beyond point vertically down. 185 "Split current line, moving portion beyond point vertically down.
187If the current line starts with `fill-prefix', insert it on the new 186If the current line starts with `fill-prefix', insert it on the new
@@ -190,17 +189,19 @@ line as well. With prefix arg, don't insert fill-prefix on new line.
190When called from Lisp code, the arg may be a prefix string to copy." 189When called from Lisp code, the arg may be a prefix string to copy."
191 (interactive "*P") 190 (interactive "*P")
192 (skip-chars-forward " \t") 191 (skip-chars-forward " \t")
193 (let ((col (current-column)) 192 (let* ((col (current-column))
194 (pos (point)) 193 (pos (point))
195 (beg (line-beginning-position)) 194 ;; What prefix should we check for (nil means don't).
196 (prefix (cond ((stringp arg) arg) 195 (prefix (cond ((stringp arg) arg)
197 (arg nil) 196 (arg nil)
198 (t fill-prefix)))) 197 (t fill-prefix)))
198 ;; Does this line start with it?
199 (have-prfx (and prefix
200 (save-excursion
201 (beginning-of-line)
202 (looking-at (regexp-quote prefix))))))
199 (newline 1) 203 (newline 1)
200 (if (and (stringp prefix) 204 (if have-prfx (insert-and-inherit prefix))
201 (string-equal prefix
202 (buffer-substring beg (+ beg (length prefix)))))
203 (insert-and-inherit prefix))
204 (indent-to col 0) 205 (indent-to col 0)
205 (goto-char pos))) 206 (goto-char pos)))
206 207