]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix infinite loop in python.el
authorVinicius Jose Latorre <viniciusjl@ig.com.br>
Wed, 1 Aug 2007 00:47:25 +0000 (00:47 +0000)
committerVinicius Jose Latorre <viniciusjl@ig.com.br>
Wed, 1 Aug 2007 00:47:25 +0000 (00:47 +0000)
lisp/ChangeLog
lisp/progmodes/python.el

index c295150db711a618ccbbaf2a8d94788d24088f52..fceef2353de4f2c264c7b932f1794531b9928478 100644 (file)
@@ -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.
index c3caa7e397c1f9975c398011cd8cfbe2f6e1aa29..9bef41a0878e7ba838fa6c45073e9202056792f2 100644 (file)
@@ -1005,7 +1005,7 @@ don't move and return nil.  Otherwise return t."
     (set-text-properties 0 (length function-name) nil function-name)
     function-name))
 
+
 ;;;; Imenu.
 
 (defvar python-recursing)
@@ -1828,21 +1828,25 @@ of current line."
   (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 ".."))