all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* A few questions about open-line
@ 2015-10-24 21:02 Artur Malabarba
  2015-10-24 21:07 ` bruce.connor.am
  2015-10-24 22:34 ` Artur Malabarba
  0 siblings, 2 replies; 3+ messages in thread
From: Artur Malabarba @ 2015-10-24 21:02 UTC (permalink / raw)
  To: emacs-devel

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?



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: A few questions about open-line
  2015-10-24 21:02 A few questions about open-line Artur Malabarba
@ 2015-10-24 21:07 ` bruce.connor.am
  2015-10-24 22:34 ` Artur Malabarba
  1 sibling, 0 replies; 3+ messages in thread
From: bruce.connor.am @ 2015-10-24 21:07 UTC (permalink / raw)
  To: emacs-devel

> 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?

Actually, it looks it's the docstring that is off here. I think it
should say "insert them on the new line.  If the old line would be
left empty, insert them on the old line too.".



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: A few questions about open-line
  2015-10-24 21:02 A few questions about open-line Artur Malabarba
  2015-10-24 21:07 ` bruce.connor.am
@ 2015-10-24 22:34 ` Artur Malabarba
  1 sibling, 0 replies; 3+ messages in thread
From: Artur Malabarba @ 2015-10-24 22:34 UTC (permalink / raw)
  To: emacs-devel

> 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?

After a lot of testing, I see it's necessary in case a left-margin was inserted.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-24 22:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-24 21:02 A few questions about open-line Artur Malabarba
2015-10-24 21:07 ` bruce.connor.am
2015-10-24 22:34 ` Artur Malabarba

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.