Mercurial > emacs
changeset 49066:d00c13d69d31
(split-line): Clean up implementation.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 06 Jan 2003 01:17:19 +0000 |
parents | 265dc22fb2c0 |
children | c0e98fdf377f |
files | lisp/simple.el |
diffstat | 1 files changed, 12 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/simple.el Mon Jan 06 01:10:25 2003 +0000 +++ b/lisp/simple.el Mon Jan 06 01:17:19 2003 +0000 @@ -181,7 +181,6 @@ (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 @@ 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)))