emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: infloop in python code


From: Chong Yidong
Subject: Re: infloop in python code
Date: Mon, 09 Apr 2007 22:45:47 -0400

> Ah yes, now I can replicate it.  The trouble was that your test
> program had long lines that were automatically snipped by Gnus.
>
> Here is a simpler test case:
>
> #!/usr/bin/env python
> def foo(bar):
>     foo = foo("""foo""").bar("
>     cmd = """foo"""
>     bar
>
> emacs -q foo.py
> M-: (python-imenu-create-index) RET

This seems to be traceable to the naughty while loop in
python-end-of-block.

  (catch 'done
    (while (zerop (python-next-statement))
      (when (or (and open (<= (current-indentation) ci))
                (< (current-indentation) ci))
        (python-skip-comments/blanks t)
        (beginning-of-line 2)
        (throw 'done t))))

I think something like the following fixes it (someone more
knowledgeable about this code should probably take a look).

*** emacs/lisp/progmodes/python.el.~1.57.~      2007-04-04 13:05:27.000000000 
-0400
--- emacs/lisp/progmodes/python.el      2007-04-09 22:42:45.000000000 -0400
***************
*** 981,991 ****
                       (_ (if (python-comment-line-p)
                              (python-skip-comments/blanks t)))
                       (ci (current-indentation))
!                      (open (python-open-block-statement-p)))
                  (if (and (zerop ci) (not open))
                      (not (goto-char point))
                    (catch 'done
!                     (while (zerop (python-next-statement))
                        (when (or (and open (<= (current-indentation) ci))
                                  (< (current-indentation) ci))
                          (python-skip-comments/blanks t)
--- 981,995 ----
                       (_ (if (python-comment-line-p)
                              (python-skip-comments/blanks t)))
                       (ci (current-indentation))
!                      (open (python-open-block-statement-p))
!                      opoint)
                  (if (and (zerop ci) (not open))
                      (not (goto-char point))
                    (catch 'done
!                     (setq opoint (point))
!                     (while (and (zerop (python-next-statement))
!                                 (not (= opoint (point))))
!                       (setq opoint (point))
                        (when (or (and open (<= (current-indentation) ci))
                                  (< (current-indentation) ci))
                          (python-skip-comments/blanks t)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]