aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorkobarity2025-04-20 21:14:46 +0900
committerEli Zaretskii2025-04-26 14:19:17 +0300
commitd753c884948499c0c557d01fefe5914f7d57573c (patch)
tree64d99402478d77391a6d40e55545571e5ed3946e /lisp/progmodes/python.el
parent55cf15e163b407878921b4428e5436f01cf1fd90 (diff)
downloademacs-d753c884948499c0c557d01fefe5914f7d57573c.tar.gz
emacs-d753c884948499c0c557d01fefe5914f7d57573c.zip
Performance optimization of 'python-info-statement-ends-block-p'
* lisp/progmodes/python.el (python-info-statement-ends-block-p): Add a comparison of the indentation of the next statement with the indentation of the current statement. (Bug#77620)
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el27
1 files changed, 19 insertions, 8 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index b03e4f9efdf..81440cfcfc9 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -6156,14 +6156,25 @@ parent defun name."
6156 6156
6157(defun python-info-statement-ends-block-p () 6157(defun python-info-statement-ends-block-p ()
6158 "Return non-nil if point is at end of block." 6158 "Return non-nil if point is at end of block."
6159 (let ((end-of-block-pos (save-excursion 6159 (let* (current-statement
6160 (python-nav-end-of-block))) 6160 (current-indentation (save-excursion
6161 (end-of-statement-pos (save-excursion 6161 (setq current-statement
6162 (python-nav-end-of-statement) 6162 (python-nav-beginning-of-statement))
6163 (python-util-forward-comment -1) 6163 (current-indentation)))
6164 (point)))) 6164 next-statement
6165 (and end-of-block-pos end-of-statement-pos 6165 (next-indentation (save-excursion
6166 (= end-of-block-pos end-of-statement-pos)))) 6166 (python-nav-forward-statement)
6167 (setq next-statement (point))
6168 (current-indentation))))
6169 (unless (and (< current-statement next-statement)
6170 (<= current-indentation next-indentation))
6171 (and-let* ((end-of-statement-pos (save-excursion
6172 (python-nav-end-of-statement)
6173 (python-util-forward-comment -1)
6174 (point)))
6175 (end-of-block-pos (save-excursion
6176 (python-nav-end-of-block))))
6177 (= end-of-block-pos end-of-statement-pos)))))
6167 6178
6168(defun python-info-beginning-of-statement-p () 6179(defun python-info-beginning-of-statement-p ()
6169 "Return non-nil if point is at beginning of statement." 6180 "Return non-nil if point is at beginning of statement."