From: kobarity <kobarity@gmail.com>
To: 55702@debbugs.gnu.org
Subject: bug#55702: 29.0.50; python-mark-defun does not handle backslash escaped newline
Date: Sun, 29 May 2022 21:27:47 +0900 [thread overview]
Message-ID: <CAMQkrSp3f+2BsYcF2jtmLLt7dQ9D2h+eDFwsAn5NAV4QgTabYA@mail.gmail.com> (raw)
In-Reply-To: <CAMQkrSpKpZ_+0NFD_=7t5GJAygGUyq8+=EWHyS-9_UwQ1BrcNg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 172 bytes --]
python-mark-defun and python-info-looking-at-beginning-of-defun do not
consider the presence of backslash escaped newline in defuns.
Attached is a patch to fix this issue.
[-- Attachment #2: fix-55702.patch --]
[-- Type: application/octet-stream, Size: 2529 bytes --]
commit 28aeb41bc05ecf2d887a8d9290f860e52ee4e73e
Author: kobarity <kobarity@gmail.com>
Date: Sun May 29 21:23:35 2022 +0900
Make `python-mark-defun' handle backslash escaped newline
* lisp/progmodes/python.el (python-mark-defun)
(python-info-looking-at-beginning-of-defun): Allow backslash
escaped newline in defuns (bug#55702).
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index c2483436fe..7ab063daa9 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1426,7 +1426,7 @@ python-mark-defun
marks the next defun after the ones already marked."
(interactive "p")
(when (python-info-looking-at-beginning-of-defun)
- (end-of-line 1))
+ (python-nav-end-of-statement))
(mark-defun allow-extend))
\f
@@ -5290,6 +5290,7 @@ python-info-looking-at-beginning-of-defun
"Check if point is at `beginning-of-defun' using SYNTAX-PPSS."
(and (not (python-syntax-context-type (or syntax-ppss (syntax-ppss))))
(save-excursion
+ (python-nav-beginning-of-statement)
(beginning-of-line 1)
(looking-at python-nav-beginning-of-defun-regexp))))
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index 8db0a07170..c1b71d15fd 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -1736,6 +1736,36 @@ python-mark-defun-3
(should (= (marker-position (mark-marker))
expected-mark-end-position)))))
+(ert-deftest python-mark-defun-4 ()
+ "Test `python-mark-defun' with point inside backslash escaped defun."
+ (python-tests-with-temp-buffer
+ "
+def \\
+ foo(x):
+ return x
+"
+ (let ((transient-mark-mode t)
+ (expected-mark-beginning-position
+ (progn
+ (python-tests-look-at "def ")
+ (1- (line-beginning-position))))
+ (expected-mark-end-position
+ (save-excursion
+ (python-tests-look-at "return x")
+ (forward-line)
+ (point))))
+ (python-tests-look-at "def ")
+ (python-mark-defun 1)
+ (should (= (point) expected-mark-beginning-position))
+ (should (= (marker-position (mark-marker))
+ expected-mark-end-position))
+ (deactivate-mark)
+ (python-tests-look-at "foo(x)")
+ (python-mark-defun 1)
+ (should (= (point) expected-mark-beginning-position))
+ (should (= (marker-position (mark-marker))
+ expected-mark-end-position)))))
+
\f
;;; Navigation
next prev parent reply other threads:[~2022-05-29 12:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-29 12:22 bug#55702: 29.0.50; python-mark-defun does not handle backslash escaped newline kobarity
2022-05-29 12:27 ` kobarity [this message]
2022-05-29 13:11 ` kobarity
2022-07-03 8:56 ` kobarity
2022-07-03 12:23 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAMQkrSp3f+2BsYcF2jtmLLt7dQ9D2h+eDFwsAn5NAV4QgTabYA@mail.gmail.com \
--to=kobarity@gmail.com \
--cc=55702@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).