From: martin rudalics <rudalics@gmx.at>
Subject: Re: Can emacs open a new line below or above the current line?
Date: Thu, 21 Dec 2006 14:06:52 +0100 [thread overview]
Message-ID: <458A86EC.6070008@gmx.at> (raw)
I'm using the following:
(defun newline-and-indent-maybe ()
"Insert newline and re-indent lines if necessary.
On an empty line insert a newline before current line. At the beginning
of a non-empty line, do `newline-and-indent', move to the beginning of
the line just inserted, and indent that line. Otherwise, do
`newline-and-indent'. Fixes up any whitespace at end of old line."
(interactive)
(let ((go-back
(save-excursion
(delete-horizontal-space)
(and (bolp) (not (eolp))))))
(when (and (boundp 'show-paren-overlay-1)
(overlayp show-paren-overlay-1))
;; Remove `show-paren-overlay-1' to avoid flickering.
(delete-overlay show-paren-overlay-1))
(newline-and-indent)
(when go-back
(forward-line -1)
(indent-according-to-mode))))
(global-set-key [?\r] 'newline-and-indent-maybe)
next reply other threads:[~2006-12-21 13:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-21 13:06 martin rudalics [this message]
-- strict thread matches above, loose matches on Subject: below --
2006-12-21 7:45 Can emacs open a new line below or above the current line? Ronald
2006-12-21 9:06 ` Mathias Dahl
2006-12-21 9:24 ` Ronald
2006-12-21 9:15 ` David Hansen
[not found] ` <mailman.2176.1166693025.2155.help-gnu-emacs@gnu.org>
2006-12-21 9:47 ` Ronald
2006-12-21 13:34 ` Dieter Wilhelm
[not found] ` <mailman.2179.1166708079.2155.help-gnu-emacs@gnu.org>
2006-12-21 22:24 ` Ronald
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=458A86EC.6070008@gmx.at \
--to=rudalics@gmx.at \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).