changeset 82224:bda0322e3767

Fix infinite loop in python.el
author Vinicius Jose Latorre <viniciusjl@ig.com.br>
date Wed, 01 Aug 2007 00:47:25 +0000
parents c6692abac164
children cdb30692dab7
files lisp/ChangeLog lisp/progmodes/python.el
diffstat 2 files changed, 24 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue Jul 31 16:28:24 2007 +0000
+++ b/lisp/ChangeLog	Wed Aug 01 00:47:25 2007 +0000
@@ -1,3 +1,8 @@
+2007-07-31  Paul Pogonyshev  <pogonyshev@gmx.net>
+
+	* progmodes/python.el (python-current-defun): Adjust to never fall
+	into infinite loop.
+
 2007-07-31  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* pcvs.el (cvs-vc-command-advice): Handle the new fileset case.
--- a/lisp/progmodes/python.el	Tue Jul 31 16:28:24 2007 +0000
+++ b/lisp/progmodes/python.el	Wed Aug 01 00:47:25 2007 +0000
@@ -1005,7 +1005,7 @@
     (set-text-properties 0 (length function-name) nil function-name)
     function-name))
 
- 
+
 ;;;; Imenu.
 
 (defvar python-recursing)
@@ -1828,21 +1828,25 @@
   (save-excursion
     ;; Move up the tree of nested `class' and `def' blocks until we
     ;; get to zero indentation, accumulating the defined names.
-    (let ((start t)
-	  (accum)
+    (let ((accum)
 	  (length -1))
-      (while (and (or start (> (current-indentation) 0))
-		  (or (null length-limit)
-		      (null (cdr accum))
-		      (< length length-limit)))
-	(setq start nil)
-	(python-beginning-of-block)
-	(end-of-line)
-	(beginning-of-defun)
-	(when (looking-at (rx (0+ space) (or "def" "class") (1+ space)
-			      (group (1+ (or word (syntax symbol))))))
-	  (push (match-string 1) accum)
-	  (setq length (+ length 1 (length (car accum))))))
+      (catch 'done
+	(while (or (null length-limit)
+		   (null (cdr accum))
+		   (< length length-limit))
+	  (setq start nil)
+	  (let ((started-from (point)))
+	    (python-beginning-of-block)
+	    (end-of-line)
+	    (beginning-of-defun)
+	    (when (= (point) started-from)
+	      (throw 'done nil)))
+	  (when (looking-at (rx (0+ space) (or "def" "class") (1+ space)
+				(group (1+ (or word (syntax symbol))))))
+	    (push (match-string 1) accum)
+	    (setq length (+ length 1 (length (car accum)))))
+	  (when (= (current-indentation) 0)
+	    (throw 'done nil))))
       (when accum
 	(when (and length-limit (> length length-limit))
 	  (setcar accum ".."))