aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim F. Storm2003-01-03 22:46:06 +0000
committerKim F. Storm2003-01-03 22:46:06 +0000
commitda7d231b345244fd25ac63ab614339b5e86a7264 (patch)
tree8b6ae7eb12dbf62f7ef23d4c37c7e65bee678f57
parent7b1824c287f633ab547d85ecf2b0fff4f03e3596 (diff)
downloademacs-da7d231b345244fd25ac63ab614339b5e86a7264.tar.gz
emacs-da7d231b345244fd25ac63ab614339b5e86a7264.zip
(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 <ehud@unix.mvs.co.il>.
-rw-r--r--lisp/simple.el24
1 files changed, 19 insertions, 5 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 6331be18766..d6583c8f963 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1,6 +1,7 @@
1;;; simple.el --- basic editing commands for Emacs 1;;; simple.el --- basic editing commands for Emacs
2 2
3;; Copyright (C) 1985, 86, 87, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002 3;; Copyright (C) 1985, 86, 87, 93, 94, 95, 96, 97, 98, 99,
4;; 2000, 2001, 2002, 2003
4;; Free Software Foundation, Inc. 5;; Free Software Foundation, Inc.
5 6
6;; Maintainer: FSF 7;; Maintainer: FSF
@@ -180,13 +181,26 @@ With arg N, insert N newlines."
180 (goto-char loc) 181 (goto-char loc)
181 (end-of-line))) 182 (end-of-line)))
182 183
183(defun split-line () 184
184 "Split current line, moving portion beyond point vertically down." 185(defun split-line (&optional arg)
185 (interactive "*") 186 "Split current line, moving portion beyond point vertically down.
187If the current line starts with `fill-prefix', insert it on the new
188line as well. With prefix arg, don't insert fill-prefix on new line.
189
190When called from Lisp code, the arg may be a prefix string to copy."
191 (interactive "*P")
186 (skip-chars-forward " \t") 192 (skip-chars-forward " \t")
187 (let ((col (current-column)) 193 (let ((col (current-column))
188 (pos (point))) 194 (pos (point))
195 (beg (line-beginning-position))
196 (prefix (cond ((stringp arg) arg)
197 (arg nil)
198 (t fill-prefix))))
189 (newline 1) 199 (newline 1)
200 (if (and (stringp prefix)
201 (string-equal prefix
202 (buffer-substring beg (+ beg (length prefix)))))
203 (insert-and-inherit prefix))
190 (indent-to col 0) 204 (indent-to col 0)
191 (goto-char pos))) 205 (goto-char pos)))
192 206