From: npostavs@users.sourceforge.net
To: "Clément Pit--Claudel" <clement.pit@gmail.com>
Cc: 24856@debbugs.gnu.org
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 [thread overview]
Message-ID: <87ins5paj0.fsf@users.sourceforge.net> (raw)
In-Reply-To: <f76622e1-e2d0-9e78-cc26-464939d27911@gmail.com> ("Clément Pit--Claudel"'s message of "Wed, 2 Nov 2016 02:59:29 -0400")
[-- Attachment #1: Type: text/plain, Size: 636 bytes --]
merge 24856 24839
tags 24856 patch
quit
Clément Pit--Claudel <clement.pit@gmail.com> 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:
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 2218 bytes --]
From 5da4f196fc3c8b411936551568477d70a9046421 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
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
next prev parent reply other threads:[~2016-11-03 2:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-02 2:39 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 raynewang
2016-11-02 6:59 ` Clément Pit--Claudel
2016-11-03 2:22 ` npostavs [this message]
2016-11-03 5:47 ` Clément Pit--Claudel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ins5paj0.fsf@users.sourceforge.net \
--to=npostavs@users.sourceforge.net \
--cc=24856@debbugs.gnu.org \
--cc=clement.pit@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.