[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
A few questions about open-line
From: |
Artur Malabarba |
Subject: |
A few questions about open-line |
Date: |
Sat, 24 Oct 2015 22:02:25 +0100 |
For reference, the function:
(defun open-line (n)
"Insert a newline and leave point before it.
If there is a fill prefix and/or a `left-margin', insert them
on the new line if the line would have been blank.
With arg N, insert N newlines."
(interactive "*p")
(let* ((do-fill-prefix (and fill-prefix (bolp)))
(do-left-margin (and (bolp) (> (current-left-margin) 0)))
(loc (point-marker))
;; Don't expand an abbrev before point.
(abbrev-mode nil))
(newline n)
(goto-char loc)
(while (> n 0)
(cond ((bolp)
(if do-left-margin (indent-to (current-left-margin)))
(if do-fill-prefix (insert-and-inherit fill-prefix))))
(forward-line 1)
(setq n (1- n)))
(goto-char loc)
(end-of-line)))
1. The docstring claims that "If there is a fill prefix and/or a
`left-margin', insert them
on the new line". However, the code actually applies the prefix and
left-margin on the old line, not the new one. Should I fix that or did
I miss something?
2. After the last (goto-char loc), is there any situation where the
point isn't already at the end of the line? Why is that end-of-line
necessary?
3. I think, when electric-indent-mode is on, open-line should indent
the line that was created below if it isn't empty. May I go ahead?
- A few questions about open-line,
Artur Malabarba <=