[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Can emacs open a new line below or above the current line?
From: |
martin rudalics |
Subject: |
Re: Can emacs open a new line below or above the current line? |
Date: |
Thu, 21 Dec 2006 14:06:52 +0100 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
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)
- Re: Can emacs open a new line below or above the current line?,
martin rudalics <=