From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.help Subject: Re: Can emacs open a new line below or above the current line? Date: Thu, 21 Dec 2006 14:06:52 +0100 Message-ID: <458A86EC.6070008@gmx.at> NNTP-Posting-Host: dough.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1166707318 2188 80.91.229.10 (21 Dec 2006 13:21:58 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 21 Dec 2006 13:21:58 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 21 14:21:56 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by dough.gmane.org with esmtp (Exim 4.50) id 1GxNrs-0003Lo-8v for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Dec 2006 14:21:52 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GxNrr-0003XU-KK for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Dec 2006 08:21:51 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GxNrH-0003HR-Ae for help-gnu-emacs@gnu.org; Thu, 21 Dec 2006 08:21:15 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GxNrE-0003G9-Ig for help-gnu-emacs@gnu.org; Thu, 21 Dec 2006 08:21:14 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GxNrE-0003Fz-BK for help-gnu-emacs@gnu.org; Thu, 21 Dec 2006 08:21:12 -0500 Original-Received: from [213.165.64.20] (helo=mail.gmx.net) by monty-python.gnu.org with smtp (Exim 4.52) id 1GxNrD-0004Yf-SF for help-gnu-emacs@gnu.org; Thu, 21 Dec 2006 08:21:12 -0500 Original-Received: (qmail invoked by alias); 21 Dec 2006 13:21:09 -0000 Original-Received: from N720P030.adsl.highway.telekom.at (EHLO [62.47.33.254]) [62.47.33.254] by mail.gmx.net (mp044) with SMTP; 21 Dec 2006 14:21:09 +0100 X-Authenticated: #14592706 User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en Original-To: help-gnu-emacs@gnu.org X-Y-GMX-Trusted: 0 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:39805 Archived-At: 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)