all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Artur Malabarba <bruce.connor.am@gmail.com>
To: emacs-devel <emacs-devel@gnu.org>
Subject: A few questions about open-line
Date: Sat, 24 Oct 2015 22:02:25 +0100	[thread overview]
Message-ID: <CAAdUY-+nzbm1v0zMQ6QKPfWWWxN+ManAvAUjwDLRhjnewFy7Jw@mail.gmail.com> (raw)

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?



             reply	other threads:[~2015-10-24 21:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-24 21:02 Artur Malabarba [this message]
2015-10-24 21:07 ` A few questions about open-line bruce.connor.am
2015-10-24 22:34 ` Artur Malabarba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAAdUY-+nzbm1v0zMQ6QKPfWWWxN+ManAvAUjwDLRhjnewFy7Jw@mail.gmail.com \
    --to=bruce.connor.am@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.