Mercurial > emacs
comparison lisp/progmodes/python.el @ 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 | e126e09e6ac7 |
children | e5a68f18fcb9 35e3789db058 |
comparison
equal
deleted
inserted
replaced
82223:c6692abac164 | 82224:bda0322e3767 |
---|---|
1003 (defun python-which-func () | 1003 (defun python-which-func () |
1004 (let ((function-name (python-current-defun python-which-func-length-limit))) | 1004 (let ((function-name (python-current-defun python-which-func-length-limit))) |
1005 (set-text-properties 0 (length function-name) nil function-name) | 1005 (set-text-properties 0 (length function-name) nil function-name) |
1006 function-name)) | 1006 function-name)) |
1007 | 1007 |
1008 | 1008 |
1009 ;;;; Imenu. | 1009 ;;;; Imenu. |
1010 | 1010 |
1011 (defvar python-recursing) | 1011 (defvar python-recursing) |
1012 (defun python-imenu-create-index () | 1012 (defun python-imenu-create-index () |
1013 "`imenu-create-index-function' for Python. | 1013 "`imenu-create-index-function' for Python. |
1826 (defun python-current-defun (&optional length-limit) | 1826 (defun python-current-defun (&optional length-limit) |
1827 "`add-log-current-defun-function' for Python." | 1827 "`add-log-current-defun-function' for Python." |
1828 (save-excursion | 1828 (save-excursion |
1829 ;; Move up the tree of nested `class' and `def' blocks until we | 1829 ;; Move up the tree of nested `class' and `def' blocks until we |
1830 ;; get to zero indentation, accumulating the defined names. | 1830 ;; get to zero indentation, accumulating the defined names. |
1831 (let ((start t) | 1831 (let ((accum) |
1832 (accum) | |
1833 (length -1)) | 1832 (length -1)) |
1834 (while (and (or start (> (current-indentation) 0)) | 1833 (catch 'done |
1835 (or (null length-limit) | 1834 (while (or (null length-limit) |
1836 (null (cdr accum)) | 1835 (null (cdr accum)) |
1837 (< length length-limit))) | 1836 (< length length-limit)) |
1838 (setq start nil) | 1837 (setq start nil) |
1839 (python-beginning-of-block) | 1838 (let ((started-from (point))) |
1840 (end-of-line) | 1839 (python-beginning-of-block) |
1841 (beginning-of-defun) | 1840 (end-of-line) |
1842 (when (looking-at (rx (0+ space) (or "def" "class") (1+ space) | 1841 (beginning-of-defun) |
1843 (group (1+ (or word (syntax symbol)))))) | 1842 (when (= (point) started-from) |
1844 (push (match-string 1) accum) | 1843 (throw 'done nil))) |
1845 (setq length (+ length 1 (length (car accum)))))) | 1844 (when (looking-at (rx (0+ space) (or "def" "class") (1+ space) |
1845 (group (1+ (or word (syntax symbol)))))) | |
1846 (push (match-string 1) accum) | |
1847 (setq length (+ length 1 (length (car accum))))) | |
1848 (when (= (current-indentation) 0) | |
1849 (throw 'done nil)))) | |
1846 (when accum | 1850 (when accum |
1847 (when (and length-limit (> length length-limit)) | 1851 (when (and length-limit (> length length-limit)) |
1848 (setcar accum "..")) | 1852 (setcar accum "..")) |
1849 (mapconcat 'identity accum "."))))) | 1853 (mapconcat 'identity accum "."))))) |
1850 | 1854 |