From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.bugs Subject: bug#13810: 24.3.50; Docstring of `newline' is confusing Date: Mon, 25 Feb 2013 13:23:14 +0100 Message-ID: <87y5ecshu5.fsf@rosalinde.fritz.box> References: <20130225180309.53675e52a9cffc46b2478578@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1361795203 25230 80.91.229.3 (25 Feb 2013 12:26:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 25 Feb 2013 12:26:43 +0000 (UTC) Cc: 13810@debbugs.gnu.org To: Xue Fuqiao Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Feb 25 13:27:05 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1U9x96-0001I5-J3 for geb-bug-gnu-emacs@m.gmane.org; Mon, 25 Feb 2013 13:27:04 +0100 Original-Received: from localhost ([::1]:44900 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9x8l-0000qc-RW for geb-bug-gnu-emacs@m.gmane.org; Mon, 25 Feb 2013 07:26:43 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:51625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9x8Z-0000Ps-If for bug-gnu-emacs@gnu.org; Mon, 25 Feb 2013 07:26:34 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U9x8R-0001Li-DV for bug-gnu-emacs@gnu.org; Mon, 25 Feb 2013 07:26:31 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:43572) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9x8R-0001LU-9t for bug-gnu-emacs@gnu.org; Mon, 25 Feb 2013 07:26:23 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1U9xA1-000604-V0 for bug-gnu-emacs@gnu.org; Mon, 25 Feb 2013 07:28:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stephen Berman Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 25 Feb 2013 12:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13810 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 13810-submit@debbugs.gnu.org id=B13810.136179523022996 (code B ref 13810); Mon, 25 Feb 2013 12:28:01 +0000 Original-Received: (at 13810) by debbugs.gnu.org; 25 Feb 2013 12:27:10 +0000 Original-Received: from localhost ([127.0.0.1]:49035 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U9x9C-0005yr-7K for submit@debbugs.gnu.org; Mon, 25 Feb 2013 07:27:10 -0500 Original-Received: from mout.gmx.net ([212.227.15.19]:50086) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U9x98-0005yh-Gi for 13810@debbugs.gnu.org; Mon, 25 Feb 2013 07:27:08 -0500 Original-Received: from mailout-de.gmx.net ([10.1.76.32]) by mrigmx.server.lan (mrigmx002) with ESMTP (Nemesis) id 0Ld330-1UaWOa3eL2-00iA02 for <13810@debbugs.gnu.org>; Mon, 25 Feb 2013 13:23:16 +0100 Original-Received: (qmail invoked by alias); 25 Feb 2013 12:23:16 -0000 Original-Received: from i59F56285.versanet.de (EHLO rosalinde.fritz.box) [89.245.98.133] by mail.gmx.net (mp032) with SMTP; 25 Feb 2013 13:23:16 +0100 X-Authenticated: #20778731 X-Provags-ID: V01U2FsdGVkX1/1NVVWI1r1sboTgPUe3AEh+PrcLwl/XTRwaxfHyK j8i2CQGjDC9mAE In-Reply-To: <20130225180309.53675e52a9cffc46b2478578@gmail.com> (Xue Fuqiao's message of "Mon, 25 Feb 2013 18:03:09 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-Y-GMX-Trusted: 0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:71776 Archived-At: On Mon, 25 Feb 2013 18:03:09 +0800 Xue Fuqiao wrote: > In the doc string of the function `newline': > > Insert a newline, and move to left margin of the new line if it's > blank. > > To reproduce this bug: > > emacs -Q > M-< > M-: (newline) RET > > A new line appears, but the point doesn't move to left margin of the > first line. I think you misread the doc string: point should -- and does -- move to the left margin of the *new* line. > Maybe the doc string of this function should be improved. However, unless I'm misreading it, there is indeed room for improvement, since point moves to the left margin of the new line whether or not it is blank, so "if it's blank" is misleading and should be deleted. Your report prompted me to check the code of newline and I think I found a bug: a comment says, "If the newline leaves the previous line blank, and we have a left margin, delete that from the blank line", but the code only checks whether the previous line consists of a *single* space or tab, so if there's more than one space or tab and the line is otherwise blank, these won't be deleted. I doubt this asymmetry is intended, so at least the following patch should be made: === modified file 'lisp/simple.el' *** lisp/simple.el 2013-02-15 23:47:50 +0000 --- lisp/simple.el 2013-02-25 12:20:47 +0000 *************** *** 400,406 **** "Propertized string representing a hard newline character.") (defun newline (&optional arg) ! "Insert a newline, and move to left margin of the new line if it's blank. If option `use-hard-newlines' is non-nil, the newline is marked with the text-property `hard'. With ARG, insert that many newlines. --- 400,406 ---- "Propertized string representing a hard newline character.") (defun newline (&optional arg) ! "Insert a newline, and move to left margin of the new line. If option `use-hard-newlines' is non-nil, the newline is marked with the text-property `hard'. With ARG, insert that many newlines. *************** *** 428,434 **** (save-excursion (goto-char beforepos) (beginning-of-line) ! (and (looking-at "[ \t]$") (> (current-left-margin) 0) (delete-region (point) (line-end-position)))) --- 428,434 ---- (save-excursion (goto-char beforepos) (beginning-of-line) ! (and (looking-at "[ \t]+$") (> (current-left-margin) 0) (delete-region (point) (line-end-position)))) Actually, if we take the comment literally, the code should check that the space left on the previous line has the length of left-margin, and only in that case delete it. But I think the comment doesn't really intend that, but rather to delete any whitespace left on an otherwise blank line, which the above patch does. Steve Berman