From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: nuxdoors@cegetel.net Newsgroups: gmane.emacs.bugs Subject: Re: reindent-then-newline-and-indent doesn't indent properly in emacs 22.1 Date: Sun, 14 Oct 2007 14:46:41 +0200 Message-ID: <47120FB1.4000007@cegetel.net> References: <470FFCF1.5050201@cegetel.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7BIT X-Trace: ger.gmane.org 1192366067 9864 80.91.229.12 (14 Oct 2007 12:47:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 14 Oct 2007 12:47:47 +0000 (UTC) To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 14 14:47:37 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 1Ih2sW-0004Tq-Va for geb-bug-gnu-emacs@m.gmane.org; Sun, 14 Oct 2007 14:47:33 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ih2sQ-0007az-1m for geb-bug-gnu-emacs@m.gmane.org; Sun, 14 Oct 2007 08:47:26 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ih2sN-0007Yp-59 for bug-gnu-emacs@gnu.org; Sun, 14 Oct 2007 08:47:23 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ih2sL-0007Ww-Dk for bug-gnu-emacs@gnu.org; Sun, 14 Oct 2007 08:47:22 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ih2sL-0007Wj-5o for bug-gnu-emacs@gnu.org; Sun, 14 Oct 2007 08:47:21 -0400 Original-Received: from sp604003mt.neufgp.fr ([84.96.92.56] helo=smTp.neuf.fr) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ih2sK-0000Tf-Rc for bug-gnu-emacs@gnu.org; Sun, 14 Oct 2007 08:47:21 -0400 Original-Received: from [84.98.229.112] by sp604003mt.gpm.neuf.ld (Sun Java System Messaging Server 6.2-5.05 (built Feb 16 2006)) with ESMTP id <0JPW00F7RJI64U51@sp604003mt.gpm.neuf.ld> for bug-gnu-emacs@gnu.org; Sun, 14 Oct 2007 14:46:55 +0200 (CEST) In-reply-to: <470FFCF1.5050201@cegetel.net> User-Agent: Icedove 1.5.0.12 (X11/20070607) X-detected-kernel: by monty-python.gnu.org: Windows 98 (3 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:16746 Archived-At: > 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. I take care of this in this new function by deleting spaces after indenting the line around the point of initial breakage. I expect it has now the same behaviour as before except for the minor bug. Please test. I completed the doc string with a note one the automatic trailing space deleting. Shouldn't that be stated or is it too obvious ? (defun reindent-then-newline-and-indent () "Reindent current line, insert newline deleting trailing spaces or tabs, 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) ;; Beware of indentation functions which move point. (save-excursion (indent-according-to-mode)) ;; Delete all trailing spaces or tabs introduced by the newline command ;; or the new indentation. 0 is for no space. (just-one-space 0)) (indent-according-to-mode))) ----------------------------------------- --- lisp/simple.el.orig 2007-05-27 16:35:51.000000000 +0200 +++ lisp/simple.el 2007-10-14 14:38:20.000000000 +0200 @@ -618,7 +618,8 @@ (indent-according-to-mode)) (defun reindent-then-newline-and-indent () - "Reindent current line, insert newline, then indent the new line. + "Reindent current line, insert newline deleting trailing spaces or tabs, +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. @@ -631,8 +632,12 @@ (newline) (save-excursion (goto-char pos) - (indent-according-to-mode) - (delete-horizontal-space t)) + ;; Beware of indentation functions which move point. + (save-excursion + (indent-according-to-mode)) + ;; Delete all trailing spaces or tabs introduced by the newline command + ;; or the new indentation. + (just-one-space 0)) (indent-according-to-mode))) (defun quoted-insert (arg)