Subject: Re: bug#21671: [PATCH] fix python.el hanging up during fontification #21657

From: immerrr again <[email-masked]>
Date: Tue, 23 Feb 2016 12:00:54 +0200

On Tue, Feb 23, 2016 at 11:49 AM, Lars Ingebrigtsen <[email-masked]> wrote:
> immerrr again <[email-masked]> writes:
>
> Could you repost the second patch?
>

Sure, attaching it.

Cheers,
immerrr
From 149066dbfc7f11c40f6dbed70a3279153bf3ab7a Mon Sep 17 00:00:00 2001
From: immerrr <[email-masked]>
Date: Mon, 12 Oct 2015 14:17:16 +0300
Subject: [PATCH 2/2] Prevent infinite loop in python-info-docstring-p

python-info-docstring-p did not expect that
python-nav-beginning-of-statement could leave point intact not at the
beginning of buffer which happened if the first statement in the file
was indented (it is a Python syntax error).

* python.el (python-nav--forward-sexp): if backward-sexp brought point
to the beginning of the buffer, leave it there
---
 lisp/progmodes/python.el | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 6ff12b5..7ccd204 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1712,7 +1712,11 @@ expressions when looking at them in either direction."
                    (python-nav-beginning-of-block))
                   ((memq context '(statement-start block-start))
                    (goto-char next-sexp-pos)
-                   (python-nav-beginning-of-statement))
+                   (unless (bobp)
+                     ;; If backward-sexp brought the point to
+                     ;; beginning-of-buffer, beginning-of-statement
+                     ;; will only bring it back.
+                     (python-nav-beginning-of-statement)))
                   (t (goto-char next-sexp-pos))))))))))
 
 (defun python-nav-forward-sexp (&optional arg safe skip-parens-p)
-- 
2.6.1