[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 29228e24f20: python-info-dedenter-opening-block-positions: Fix
From: |
Dmitry Gutov |
Subject: |
emacs-29 29228e24f20: python-info-dedenter-opening-block-positions: Fix to support "bare" match |
Date: |
Thu, 9 Mar 2023 10:38:49 -0500 (EST) |
branch: emacs-29
commit 29228e24f20954b93dccef4ac5d704ca31daa80c
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
python-info-dedenter-opening-block-positions: Fix to support "bare" match
* lisp/progmodes/python.el
(python-info-dedenter-opening-block-positions): Make the check
stricter. Require that block starts only at indentation.
* test/lisp/progmodes/python-tests.el
(python-indent-after-bare-match): Another test (bug#62031).
---
lisp/progmodes/python.el | 4 +++-
test/lisp/progmodes/python-tests.el | 14 ++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 5b11d204de1..1980815bae9 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -5792,7 +5792,9 @@ likely an invalid python file."
(while (python-nav--syntactically
(lambda ()
(cl-loop while (re-search-backward (python-rx
block-start) nil t)
- if (memq (char-before) '(nil ?\s ?\t ?\n))
+ if (save-match-data
+ (looking-back (rx line-start (*
whitespace))
+ (line-beginning-position)))
return t))
#'<)
(let ((indentation (current-indentation)))
diff --git a/test/lisp/progmodes/python-tests.el
b/test/lisp/progmodes/python-tests.el
index 7e2f66e9095..2568299bb66 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -1994,6 +1994,20 @@ def test_re(string):
(python-tests-look-at "else:")
(should (= (python-indent-calculate-indentation) 4))))
+(ert-deftest python-indent-after-bare-match ()
+ "Test BUG 62031 regression."
+ (python-tests-with-temp-buffer
+ "
+from re import match
+
+def test_re(string):
+ if match('^[a-c]+$', string):
+ print('yes')
+ else:
+ "
+ (python-tests-look-at "else:")
+ (should (= (python-indent-calculate-indentation) 4))))
+
;;; Filling
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-29 29228e24f20: python-info-dedenter-opening-block-positions: Fix to support "bare" match,
Dmitry Gutov <=