diff options
author | Kim F. Storm <[email protected]> | 2003-01-03 22:46:06 +0000 |
---|---|---|
committer | Kim F. Storm <[email protected]> | 2003-01-03 22:46:06 +0000 |
commit | da7d231b345244fd25ac63ab614339b5e86a7264 (patch) | |
tree | 8b6ae7eb12dbf62f7ef23d4c37c7e65bee678f57 /lisp | |
parent | 7b1824c287f633ab547d85ecf2b0fff4f03e3596 (diff) |
(split-line): If present, copy fill-prefix from
current line to new line. Don't copy if prefix arg.
From Lisp, arg may be an alternative prefix string to copy.
Inspired by Ehud Karni <[email protected]>.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/simple.el | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index 6331be1876..d6583c8f96 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1,6 +1,7 @@ ;;; 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 @@ -180,13 +181,26 @@ With arg N, insert N newlines." (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))) |