aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el34
1 files changed, 19 insertions, 15 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index c3caa7e397c..9bef41a0878 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1005,7 +1005,7 @@ don't move and return nil. Otherwise return t."
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)
@@ -1828,21 +1828,25 @@ of current line."
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 ".."))