From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nathan Trapuzzano Newsgroups: gmane.emacs.bugs Subject: bug#15812: 24.3.50; docstring starting with "return" confuses python-mode indentation Date: Wed, 06 Nov 2013 09:23:23 -0500 Message-ID: <87r4atpq1w.fsf@nbtrap.com> References: <20131105152130.GA32322@dudelab.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1383747854 9344 80.91.229.3 (6 Nov 2013 14:24:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 6 Nov 2013 14:24:14 +0000 (UTC) Cc: 15812@debbugs.gnu.org To: Friedrich Delgado Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 06 15:24:18 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 1Ve41p-0000eP-FQ for geb-bug-gnu-emacs@m.gmane.org; Wed, 06 Nov 2013 15:24:17 +0100 Original-Received: from localhost ([::1]:34235 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve41p-0002by-1Q for geb-bug-gnu-emacs@m.gmane.org; Wed, 06 Nov 2013 09:24:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44458) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve41g-0002M9-9M for bug-gnu-emacs@gnu.org; Wed, 06 Nov 2013 09:24:13 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ve41b-00045b-3Y for bug-gnu-emacs@gnu.org; Wed, 06 Nov 2013 09:24:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:51148) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve41a-00045V-UY for bug-gnu-emacs@gnu.org; Wed, 06 Nov 2013 09:24:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Ve41a-0000HD-IL for bug-gnu-emacs@gnu.org; Wed, 06 Nov 2013 09:24:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Nathan Trapuzzano Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 06 Nov 2013 14:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15812 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 15812-submit@debbugs.gnu.org id=B15812.13837478131025 (code B ref 15812); Wed, 06 Nov 2013 14:24:02 +0000 Original-Received: (at 15812) by debbugs.gnu.org; 6 Nov 2013 14:23:33 +0000 Original-Received: from localhost ([127.0.0.1]:36934 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ve416-0000GS-Gx for submit@debbugs.gnu.org; Wed, 06 Nov 2013 09:23:33 -0500 Original-Received: from oproxy13-pub.mail.unifiedlayer.com ([69.89.16.30]:48331) by debbugs.gnu.org with smtp (Exim 4.80) (envelope-from ) id 1Ve413-0000GH-3c for 15812@debbugs.gnu.org; Wed, 06 Nov 2013 09:23:30 -0500 Original-Received: (qmail 17450 invoked by uid 0); 6 Nov 2013 14:23:25 -0000 Original-Received: from unknown (HELO host393.hostmonster.com) (66.147.240.193) by oproxy13.mail.unifiedlayer.com with SMTP; 6 Nov 2013 14:23:25 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbtrap.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:References:Subject:Cc:To:From; bh=HTLrcL9ZqIwDics8DDdxGbjLTtZVUYuQx+8XJVrQZgA=; b=wIUMEcWq/VnnbBlmGQFblYUW+CRVqa7yrW3VvST73133Kt/fB2lDRNpNyv8PZ1y4YqBgEwkEvaVjU1Ic3cjvyYbXMpV1tLVD15EMKiRIFoLyyukKK9/aDrac1ZYttgbK; Original-Received: from [50.90.253.209] (port=48704 helo=Nathan-GNU) by host393.hostmonster.com with esmtpsa (TLSv1:CAMELLIA128-SHA:128) (Exim 4.80) (envelope-from ) id 1Ve40y-0000w5-Mx; Wed, 06 Nov 2013 07:23:25 -0700 In-Reply-To: <20131105152130.GA32322@dudelab.org> (Friedrich Delgado's message of "Tue, 5 Nov 2013 16:21:30 +0100") User-Agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3.50 (gnu/linux) X-Identified-User: {1585:host393.hostmonster.com:nbtrapco:nbtrap.com} {sentby:smtp auth 50.90.253.209 authed with nbtrap@nbtrap.com} X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.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:80079 Archived-At: --=-=-= Content-Type: text/plain Friedrich Delgado writes: > emacs -Q > M-x python-mode > M-x erase-bufferyy > def foo(): > "return stuff" > > > Expected behaviour: The cursor is placed under the first quotation > mark (4 spaces indent) > > Actual behaviour: The cursor is placed at the beginning of the line. Patch attached with regression test. `python-nav-begining-of-statement' puts point on the first non-whitespace character of the statement, so it's safe to use `looking-at' here. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=python-mode.el.patch >From 49df44bf51b0a3b2a8c90180764aa37d5f3e95de Mon Sep 17 00:00:00 2001 From: Nathan Trapuzzano Date: Wed, 6 Nov 2013 08:11:43 -0500 Subject: [PATCH] Fix python-mode indentation bug #15812, and add regression test. * progmodes/python.el (python-indent-calculate-indentation): When determining indentation, don't treat "return", "pass", etc., as operators when they are just string constituents. (Bug#15812) * automated/python-test.el (python-indent-block-enders) (python-indent-block-enders-1, python-indent-block-enders-2): Rename one test, add another. --- lisp/ChangeLog | 6 ++++++ lisp/progmodes/python.el | 2 +- test/ChangeLog | 6 ++++++ test/automated/python-tests.el | 23 ++++++++++++++++++++++- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d69ea7c..847a335 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2013-11-06 Nathan Trapuzzano + + * progmodes/python.el (python-indent-calculate-indentation): When + determining indentation, don't treat "return", "pass", etc., as + operators when they are just string constituents. (Bug#15812) + 2013-11-06 Eli Zaretskii * menu-bar.el (popup-menu, menu-bar-open): When displaying TTY diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 7a90f0b..4d4c504 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -775,7 +775,7 @@ START is the buffer position where the sexp starts." (save-excursion (python-util-forward-comment -1) (python-nav-beginning-of-statement) - (member (current-word) python-indent-block-enders))) + (looking-at (regexp-opt python-indent-block-enders)))) python-indent-offset 0))) ;; When inside of a string, do nothing. just use the current diff --git a/test/ChangeLog b/test/ChangeLog index e032af4..a0ad888 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,9 @@ +2013-11-06 Nathan Trapuzzano + + * automated/python-test.el (python-indent-block-enders) + (python-indent-block-enders-1, python-indent-block-enders-2): + Rename one test, add another. + 2013-11-06 Michael Albinus * automated/tramp-tests.el (tramp-test07-file-exists-p): diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index ef1c015..798e21f 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el @@ -447,7 +447,7 @@ objects = Thing.objects.all() \\\\ (should (eq (car (python-indent-context)) 'after-line)) (should (= (python-indent-calculate-indentation) 0)))) -(ert-deftest python-indent-block-enders () +(ert-deftest python-indent-block-enders-1 () "Test `python-indent-block-enders' value honoring." (python-tests-with-temp-buffer " @@ -469,6 +469,27 @@ Class foo(object): (forward-line 1) (should (= (python-indent-calculate-indentation) 8)))) +(ert-deftest python-indent-block-enders-2 () + "Test `python-indent-block-enders' value honoring." + (python-tests-with-temp-buffer + " +Class foo(object): + '''raise lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do + + eiusmod tempor incididunt ut labore et dolore magna aliqua. + ''' + def bar(self): + \"return (1, 2, 3).\" + if self.baz: + return (1, + 2, + 3) +" + (python-tests-look-at "def") + (should (= (python-indent-calculate-indentation) 4)) + (python-tests-look-at "if") + (should (= (python-indent-calculate-indentation) 8)))) + ;;; Navigation -- 1.8.4.2 --=-=-=--