summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>2003-01-06 01:17:19 +0000
committerRichard M. Stallman <rms@gnu.org>2003-01-06 01:17:19 +0000
commitd77bbdc98d25c66a078e21d9bf785b59e9eabc2b (patch)
tree34c9656ac2f7f9b4e713491e823a16861c22b490
parentceabd2726c4170795dbe21778d223fdb1855667f (diff)
downloademacs-d77bbdc98d25c66a078e21d9bf785b59e9eabc2b.tar.gz
(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."
(goto-char loc)
(end-of-line)))
-
(defun split-line (&optional arg)
"Split current line, moving portion beyond point vertically down.
If 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.
When called from Lisp code, the arg may be a prefix string to copy."
(interactive "*P")
(skip-chars-forward " \t")
- (let ((col (current-column))
- (pos (point))
- (beg (line-beginning-position))
- (prefix (cond ((stringp arg) arg)
- (arg nil)
- (t fill-prefix))))
+ (let* ((col (current-column))
+ (pos (point))
+ ;; What prefix should we check for (nil means don't).
+ (prefix (cond ((stringp arg) arg)
+ (arg nil)
+ (t fill-prefix)))
+ ;; Does this line start with it?
+ (have-prfx (and prefix
+ (save-excursion
+ (beginning-of-line)
+ (looking-at (regexp-quote prefix))))))
(newline 1)
- (if (and (stringp prefix)
- (string-equal prefix
- (buffer-substring beg (+ beg (length prefix)))))
- (insert-and-inherit prefix))
+ (if have-prfx (insert-and-inherit prefix))
(indent-to col 0)
(goto-char pos)))