From: Eli Zaretskii <eliz@gnu.org>
To: kobarity <kobarity@gmail.com>
Cc: 62142@debbugs.gnu.org, monnier@iro.umontreal.ca, joaotavora@gmail.com
Subject: bug#62142: 30.0.50; python-fill-paragraph problems on filling strings
Date: Thu, 16 Mar 2023 09:20:04 +0200 [thread overview]
Message-ID: <83bkktqi1n.fsf@gnu.org> (raw)
In-Reply-To: <eke7pm9egy7q.wl-kobarity@gmail.com> (message from kobarity on Sun, 12 Mar 2023 17:39:37 +0900)
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
> João Távora <joaotavora@gmail.com>
> Date: Sun, 12 Mar 2023 17:39:37 +0900
> From: kobarity <kobarity@gmail.com>
>
> The cause of the first problem is similar to Bug#58780. In
> `python-fill-string', the string is searched for with the following
> code:
>
> (or (python-syntax-context 'string)
> (and (equal (string-to-syntax "|")
> (syntax-after (point)))
> (point)))))
>
> and the end of the string is searched for with the following code:
>
> (or (re-search-forward (rx (syntax string-delimiter)) nil t)
> (goto-char (point-max)))
>
> These codes used to be appropriate, but it is not correct after the
> following commit which is included in Emacs 27 and later:
>
> commit 4b39b741f1949ebad1dfccc5032dfce521bedc2a
> Author: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Tue Apr 9 15:08:21 2019 -0400
>
> python.el: don't syntax-propertize single/double quoted strings
>
> * lisp/progmodes/python.el (python-syntax-propertize-function):
> Only mark triple-quoted strings, let the normal syntax-table handle
> the rest.
> (python-syntax-stringify): Adjust accordingly.
>
> From this commit, single quoted strings can not be identified by
> string-delimiter and can only be identified by string-quote.
>
> In the fix of Bug#58780, I added `forward-sexp' to search for the end
> of single quoted string. However, considering the third problem, I
> would prefer to have `python-fill-paragraph' and `python-fill-string'
> search only for triple quoted strings in this case.
>
>
> The second problem occurs after the following commit included in Emacs
> 28 and later:
>
> commit 0646c6817139aa905a2f6079fdc82eb4be944de0
> Author: João Távora <joaotavora@gmail.com>
> Date: Sun Sep 19 11:42:20 2021 +0100
>
> Make syntax-ppss more accurate for Python triple quotes (bug#49518)
>
> By putting delimiter syntax on the last character of Python
> triple-quoted strings, this makes syntax-ppss be more accurate.
>
> This commit narrows the range of string-delimiter from outermost
> quotes to innermost quotes, and results in `python-fill-paragraph' not
> recognizing the string when point is at some quotes.
>
>
> Attached is a patch to fix these problems. Main changes are:
>
> 1. single-quoted-string and triple-quoted-string are added as a TYPE
> argument of `python-syntax-context'.
> 2. New helper function `python-info-triple-quoted-string-p' is added
> to detect triple quoted strings including quotes.
> 3. `python-fill-paragraph' and `python-fill-string' use
> `python-info-triple-quoted-string-p' to detect triple quoted
> strings only.
>
> I look forward to your comments.
Stefan and João, any comments? If not, I'd like to install this on
emacs-29 soon.
next prev parent reply other threads:[~2023-03-16 7:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-12 8:39 bug#62142: 30.0.50; python-fill-paragraph problems on filling strings kobarity
2023-03-12 18:05 ` João Távora
2023-03-13 14:17 ` kobarity
2023-03-16 7:20 ` Eli Zaretskii [this message]
2023-03-16 8:55 ` João Távora
2023-03-16 13:27 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-16 15:00 ` Eli Zaretskii
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83bkktqi1n.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=62142@debbugs.gnu.org \
--cc=joaotavora@gmail.com \
--cc=kobarity@gmail.com \
--cc=monnier@iro.umontreal.ca \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.