;;; simple.el --- basic editing commands for Emacs
-;; Copyright (C) 1985, 86, 87, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002
+;; Copyright (C) 1985, 86, 87, 93, 94, 95, 96, 97, 98, 99,
+;; 2000, 2001, 2002, 2003
;; Free Software Foundation, Inc.
;; Maintainer: FSF
(goto-char loc)
(end-of-line)))
-(defun split-line ()
- "Split current line, moving portion beyond point vertically down."
- (interactive "*")
+
+(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
+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)))
+ (pos (point))
+ (beg (line-beginning-position))
+ (prefix (cond ((stringp arg) arg)
+ (arg nil)
+ (t fill-prefix))))
(newline 1)
+ (if (and (stringp prefix)
+ (string-equal prefix
+ (buffer-substring beg (+ beg (length prefix)))))
+ (insert-and-inherit prefix))
(indent-to col 0)
(goto-char pos)))