bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#55702: 29.0.50; python-mark-defun does not handle backslash escaped


From: kobarity
Subject: bug#55702: 29.0.50; python-mark-defun does not handle backslash escaped newline
Date: Sun, 3 Jul 2022 17:56:56 +0900

Hello,

I wrote:
> When the following steps are performed, the first line "def \" will
> not be included in the region.
>
> 1. emacs -Q
> 2. Load the following Python file using M-x find-file
>
> #+begin_src python
> def \
>         foo(x):
>     return x
> #+end_src
>
> 3. M-x forward-line (Move point to the line "foo(x):".)
> 4. M-x python-mark-defun

In fact, this is not only the issue in python-mark-defun, but also the
issue in python-nav-beginning-of-defun. In the example above,
python-nav-beginning-of-defun does not move the point if the point is
located at the beginning of the line "foo(x):". My previous patch was
not sufficient to solve the issue in python-nav-beginning-of-defun. So
I attach the revised patch.

On the other hand, I'm wondering if it is worth supporting such rarely
used forms, as there seems to be some more issues regarding the line
continuation using backslash. Is it better to leave such rarely used
forms unsupported and keep the code simple?

Below is the explanation of my patch:

> Sorry, it may not be good to change the behavior of
> python-info-looking-at-beginning-of-defun.  I will reconsider the fix.

Instead of changing the default behavior of
python-info-looking-at-beginning-of-defun, I added an argument to
change the behavior. When CHECK-STATEMENT is non-nil, the current
statement is checked instead of the current physical line.

This argument is used in python-nav--beginning-of-defun to be able
to recognize the defun with line continuation using backslash. When
ARG is positive, the point is moved to the end of the statement if the
point is located at the continuation line. This is necessary for
re-search-backward to find the defun regexp.

If the defun is found when ARG is negative, it is necessary to move
point to the beginning of the statement, because the point is at the
end of the defun regexp which may be in the different line from the
beginning of the statement.

Best Regards,

Attachment: fix-55702.patch
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]