From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#24856: 25.1.50; Emacs stucks when using C-k to kill lines in python-mode if the next line is a beginning of a docstring Date: Wed, 02 Nov 2016 22:22:43 -0400 Message-ID: <87ins5paj0.fsf@users.sourceforge.net> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1478139816 1473 195.159.176.226 (3 Nov 2016 02:23:36 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 3 Nov 2016 02:23:36 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) Cc: 24856@debbugs.gnu.org To: =?UTF-8?Q?Cl=C3=A9ment?= Pit--Claudel Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Nov 03 03:23:29 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c27gM-0005h4-N9 for geb-bug-gnu-emacs@m.gmane.org; Thu, 03 Nov 2016 03:23:10 +0100 Original-Received: from localhost ([::1]:58585 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c27gP-0001Tv-DJ for geb-bug-gnu-emacs@m.gmane.org; Wed, 02 Nov 2016 22:23:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50103) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c27gI-0001Sm-V5 for bug-gnu-emacs@gnu.org; Wed, 02 Nov 2016 22:23:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c27gD-0004NA-WE for bug-gnu-emacs@gnu.org; Wed, 02 Nov 2016 22:23:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:53896) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c27gD-0004Mt-RE for bug-gnu-emacs@gnu.org; Wed, 02 Nov 2016 22:23:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1c27gD-0001AU-Ln for bug-gnu-emacs@gnu.org; Wed, 02 Nov 2016 22:23:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 03 Nov 2016 02:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24856 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24856-submit@debbugs.gnu.org id=B24856.14781397274412 (code B ref 24856); Thu, 03 Nov 2016 02:23:01 +0000 Original-Received: (at 24856) by debbugs.gnu.org; 3 Nov 2016 02:22:07 +0000 Original-Received: from localhost ([127.0.0.1]:41062 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c27fL-000191-4C for submit@debbugs.gnu.org; Wed, 02 Nov 2016 22:22:07 -0400 Original-Received: from mail-oi0-f49.google.com ([209.85.218.49]:34100) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c27fJ-00018S-6O; Wed, 02 Nov 2016 22:22:05 -0400 Original-Received: by mail-oi0-f49.google.com with SMTP id 62so55249046oif.1; Wed, 02 Nov 2016 19:22:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=oFGQu9lrVIXYzY5nrnCDGtQ36rZgNugUiGP3jfwvjLU=; b=H6SOh47qOPXK+7o/Ix7X1OklKZEoG+zSqaobKOww/enBgVvYqtZnIiKAOFHjHwNwR2 3zHMXw1yYmyW3r3HoUmP1gRFwqbnhwMNa0+2vu36jqrWyJfhj7YE7XtaemZqG9B4v761 CY0HwW3jtNf68TaotRl2YlFTaODhwraucazNCMAoAmDcEemuiUNk4PBK6NJa8Sjd2/U8 Qs273jGm2z9+lyx3iM5+EKErN/vI7zizs1e8OfrV7ST6DJt36if29p6OJgH/zUXtrBj2 DRIG42GsrolP1JkhBc3tmaL26JvZpz3/r4FAY5BXiqMbgoN4R3Zusvu5tLVPrxunw7L/ ir8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=oFGQu9lrVIXYzY5nrnCDGtQ36rZgNugUiGP3jfwvjLU=; b=gK0bAZRQWNuADQ7TQ+bj0/Fjojj/GDsq7S2j5NSXgJD3GYTU3qHAHn8m4XWlCXG1+1 3Vg+/Lh+7vXhANqSPZyQ8wDLQvTNtewZtezf6ZOfRes2R4UwL4uvInnJiz1SQmOTaLW1 cz9DdPm4mutoSxMfCnqqVFmXjTs0eIvLg4HrOWYpnkgjf5uwEcWbJJlixHLiwokkigP9 6xuqRP0mryrXD81xiafH5tLK5RCjKznlUY2eYtVfFHoLJt9WRxaXPmsr+D77mCNnl14J +7W1Va7v5ULhY45rjckRqEnI8NhU7Wz0P2JS4G75yUAXZ9dV3w6IQJnkOR3Lce8mzYls irpQ== X-Gm-Message-State: ABUngvf4SqqSG2JdXav64g8dbTHvp+H8FWe5xrokYaMjR1M8GKg9W8EHcTcDyUGy+OGGHw== X-Received: by 10.107.135.219 with SMTP id r88mr6752518ioi.224.1478139719474; Wed, 02 Nov 2016 19:21:59 -0700 (PDT) Original-Received: from zony ([45.2.7.130]) by smtp.googlemail.com with ESMTPSA id 7sm1551173ioh.2.2016.11.02.19.21.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 02 Nov 2016 19:21:58 -0700 (PDT) In-Reply-To: ("=?UTF-8?Q?Cl=C3=A9ment?= Pit--Claudel"'s message of "Wed, 2 Nov 2016 02:59:29 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:125290 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable merge 24856 24839 tags 24856 patch quit Cl=C3=A9ment Pit--Claudel writes: > emacs -Q test.py --eval '(insert " \"")' > > In other words, a mis-indented string on the first line is enough to > reproduce the bug. > Yes, seems to be the same as 24839. > It seems to be an infinite loop in fontification: > > Debugger entered--Lisp error: (quit) > python-info-beginning-of-statement-p() > python-nav--forward-sexp(-1 nil nil) > python-nav-forward-sexp(-1 nil nil) > python-nav-backward-sexp() > python-info-docstring-p((0 nil nil t nil nil 0 nil 5 nil nil)) Here is a patch: --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=v1-0001-Fix-infloop-in-python-docstring-detection.patch Content-Description: patch >From 5da4f196fc3c8b411936551568477d70a9046421 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Wed, 2 Nov 2016 21:59:10 -0400 Subject: [PATCH v1] Fix infloop in python docstring detection The function `python-info-docstring-p' (introduced in 2015-04-05 "python.el: Enhance docstring detection following PEP-257[...]") could get stuck when called with point before the first expression in the buffer. The attempted fix in 2015-04-06 "Fix previous commit to prevent infloop" did not handle the case where there is only whitespace between the first expression and the beginning of buffer (Bug#24856, Bug#24839). * lisp/progmodes/python.el (python-info-docstring-p): Stop looping when `python-nav-backward-sexp' fails to move point. --- lisp/progmodes/python.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index e5efc2b..de06efb 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -4867,13 +4867,14 @@ python-info-docstring-p 2 (progn (while (save-excursion - (python-nav-backward-sexp) - (setq backward-sexp-point (point)) - (and (= indentation (current-indentation)) - (not (bobp)) ; Prevent infloop. - (looking-at-p - (concat "[uU]?[rR]?" - (python-rx string-delimiter))))) + (let ((cur-point (point))) + (python-nav-backward-sexp) + (setq backward-sexp-point (point)) + (and (= indentation (current-indentation)) + (/= cur-point (point)) ; Prevent infloop. + (looking-at-p + (concat "[uU]?[rR]?" + (python-rx string-delimiter)))))) ;; Previous sexp was a string, restore point. (goto-char backward-sexp-point) (cl-incf counter)) -- 2.9.3 --=-=-=--