From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: Re: reindent-then-newline-and-indent doesn't indent properly in emacs 22.1 Date: Sat, 13 Oct 2007 10:40:59 +0200 Message-ID: <4710849B.30104@gmx.at> References: <470FFCF1.5050201@cegetel.net> NNTP-Posting-Host: lo.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 1192266262 9366 80.91.229.12 (13 Oct 2007 09:04:22 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 13 Oct 2007 09:04:22 +0000 (UTC) Cc: bug-gnu-emacs@gnu.org To: nuxdoors@cegetel.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Oct 13 11:04:11 2007 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Igcun-0005x1-Bd for geb-bug-gnu-emacs@m.gmane.org; Sat, 13 Oct 2007 11:04:09 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Igcug-0000Hl-TR for geb-bug-gnu-emacs@m.gmane.org; Sat, 13 Oct 2007 05:04:02 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Igcuf-0000Gc-7D for bug-gnu-emacs@gnu.org; Sat, 13 Oct 2007 05:04:01 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Igcuc-0000Dd-J5 for bug-gnu-emacs@gnu.org; Sat, 13 Oct 2007 05:03:59 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Igcuc-0000DI-EB for bug-gnu-emacs@gnu.org; Sat, 13 Oct 2007 05:03:58 -0400 Original-Received: from mail.gmx.net ([213.165.64.20]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1Igcub-0002av-Q6 for bug-gnu-emacs@gnu.org; Sat, 13 Oct 2007 05:03:58 -0400 Original-Received: (qmail invoked by alias); 13 Oct 2007 09:03:54 -0000 Original-Received: from N857P017.adsl.highway.telekom.at (EHLO [62.47.51.17]) [62.47.51.17] by mail.gmx.net (mp002) with SMTP; 13 Oct 2007 11:03:54 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX18bZhNXoU0bavAosljuETK1pZlS91EB6nUggnhbZ8 ugSLHfthdGWMiv User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en In-Reply-To: <470FFCF1.5050201@cegetel.net> X-Y-GMX-Trusted: 0 X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:16740 Archived-At: > reindent-then-newline-and-indent doesn't indent properly. > > The command currently calls delete-horizontal-space after indenting the > line, which in effect deletes the re-indentation since at that very > moment the point is at the beginning of the text. If you swap the order > of the delete-horizontal-space and indent-according-to-mode functions it > then works as intended, like this : `delete-horizontal-space' is needed to get rid of whitespace at the _end_ of the old line, that is, after the position of `point' when you invoked that command. If `reindent-then-newline-and-indent' really deletes whitespace inserted by `indent-according-to-mode' before text on the old line there is a bug. Can you give us a practical example where this happens? > (defun reindent-then-newline-and-indent () > "Reindent current line, insert newline, then indent the new line. > Indentation of both lines is done according to the current major mode, > which means calling the current value of `indent-line-function'. > In programming language modes, this is the same as TAB. > In some text modes, where TAB inserts a tab, this indents to the > column specified by the function `current-left-margin'." > (interactive "*") > (let ((pos (point))) > ;; Be careful to insert the newline before indenting the line. > ;; Otherwise, the indentation might be wrong. > (newline) > (save-excursion > (goto-char pos) > (delete-horizontal-space t) > (indent-according-to-mode)) > (indent-according-to-mode))) The problem with this is that the first `indent-according-to-mode' may insert whitespace at the end of an otherwise empty line. Try to invoke your function at the beginning of a non-empty line.