[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 09e433ec7f: Fix Python navigation problem with a line continuatio
From: |
Lars Ingebrigtsen |
Subject: |
master 09e433ec7f: Fix Python navigation problem with a line continuation using backslash |
Date: |
Sat, 23 Jul 2022 04:27:09 -0400 (EDT) |
branch: master
commit 09e433ec7f8b2c25d5be2cdb5aac5e089a6e4cea
Author: kobarity <kobarity@gmail.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Fix Python navigation problem with a line continuation using backslash
* lisp/progmodes/python.el (python-nav--beginning-of-defun): Fix
line continuation using backslash in nested defun (bug#56615).
---
lisp/progmodes/python.el | 7 +++++--
test/lisp/progmodes/python-tests.el | 26 ++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index f31832fec9..ec7d657220 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1459,8 +1459,11 @@ With positive ARG search backwards, else search
forwards."
(current-indentation)))
(body-indentation
(and (> arg 0)
- (or (and (python-info-looking-at-beginning-of-defun)
- (+ (current-indentation) python-indent-offset))
+ (or (and (python-info-looking-at-beginning-of-defun nil t)
+ (+ (save-excursion
+ (python-nav-beginning-of-statement)
+ (current-indentation))
+ python-indent-offset))
(save-excursion
(while
(and
diff --git a/test/lisp/progmodes/python-tests.el
b/test/lisp/progmodes/python-tests.el
index b2cccdd956..3b10bde23b 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -1995,6 +1995,32 @@ def c():
(beginning-of-line)
(point))))))
+(ert-deftest python-nav-beginning-of-defun-5 ()
+ (python-tests-with-temp-buffer
+ "
+class C:
+
+ def \\
+ m(self):
+ pass
+"
+ (python-tests-look-at "m(self):")
+ (should (= (save-excursion
+ (python-nav-beginning-of-defun)
+ (point))
+ (save-excursion
+ (python-tests-look-at "def \\" -1)
+ (beginning-of-line)
+ (point))))
+ (python-tests-look-at "class C:" -1)
+ (should (= (save-excursion
+ (python-nav-beginning-of-defun -1)
+ (point))
+ (save-excursion
+ (python-tests-look-at "def \\")
+ (beginning-of-line)
+ (point))))))
+
(ert-deftest python-nav-end-of-defun-1 ()
(python-tests-with-temp-buffer
"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 09e433ec7f: Fix Python navigation problem with a line continuation using backslash,
Lars Ingebrigtsen <=