aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorkobarity2022-08-15 16:30:23 +0200
committerLars Ingebrigtsen2022-08-15 16:30:23 +0200
commit0d3aebec0141ab57362477c50065222a03d57c08 (patch)
tree4d55d885963c668ccb58fa4084ba326e22721574 /lisp/progmodes/python.el
parent5025b2566e72ba37b62c2a00feef46268fc9f468 (diff)
downloademacs-0d3aebec0141ab57362477c50065222a03d57c08.tar.gz
emacs-0d3aebec0141ab57362477c50065222a03d57c08.zip
Fix `python-nav-forward-block' moving backward under certain conditions
* lisp/progmodes/python.el (python-nav-forward-block): Add check for not moving backward (bug#57223).
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el6
1 files changed, 4 insertions, 2 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 96f9d14832d..44df3186b27 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1822,7 +1822,8 @@ backward to previous block."
1822 (or arg (setq arg 1)) 1822 (or arg (setq arg 1))
1823 (let ((block-start-regexp 1823 (let ((block-start-regexp
1824 (python-rx line-start (* whitespace) block-start)) 1824 (python-rx line-start (* whitespace) block-start))
1825 (starting-pos (point))) 1825 (starting-pos (point))
1826 (orig-arg arg))
1826 (while (> arg 0) 1827 (while (> arg 0)
1827 (python-nav-end-of-statement) 1828 (python-nav-end-of-statement)
1828 (while (and 1829 (while (and
@@ -1836,7 +1837,8 @@ backward to previous block."
1836 (python-syntax-context-type))) 1837 (python-syntax-context-type)))
1837 (setq arg (1+ arg))) 1838 (setq arg (1+ arg)))
1838 (python-nav-beginning-of-statement) 1839 (python-nav-beginning-of-statement)
1839 (if (not (looking-at (python-rx block-start))) 1840 (if (or (and (> orig-arg 0) (< (point) starting-pos))
1841 (not (looking-at (python-rx block-start))))
1840 (and (goto-char starting-pos) nil) 1842 (and (goto-char starting-pos) nil)
1841 (and (not (= (point) starting-pos)) (point-marker))))) 1843 (and (not (= (point) starting-pos)) (point-marker)))))
1842 1844