From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#62142: 30.0.50; python-fill-paragraph problems on filling strings Date: Thu, 16 Mar 2023 09:20:04 +0200 Message-ID: <83bkktqi1n.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11257"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 62142@debbugs.gnu.org, monnier@iro.umontreal.ca, joaotavora@gmail.com To: kobarity Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Mar 16 08:21:09 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pchvB-0002fl-5X for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 16 Mar 2023 08:21:09 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pchv5-0005zr-UA; Thu, 16 Mar 2023 03:21:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pchv4-0005zZ-RS for bug-gnu-emacs@gnu.org; Thu, 16 Mar 2023 03:21:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pchv4-0007S9-5k for bug-gnu-emacs@gnu.org; Thu, 16 Mar 2023 03:21:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pchv3-0001m5-L1 for bug-gnu-emacs@gnu.org; Thu, 16 Mar 2023 03:21:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 16 Mar 2023 07:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62142 X-GNU-PR-Package: emacs Original-Received: via spool by 62142-submit@debbugs.gnu.org id=B62142.16789512146739 (code B ref 62142); Thu, 16 Mar 2023 07:21:01 +0000 Original-Received: (at 62142) by debbugs.gnu.org; 16 Mar 2023 07:20:14 +0000 Original-Received: from localhost ([127.0.0.1]:41098 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pchuH-0001ka-Lr for submit@debbugs.gnu.org; Thu, 16 Mar 2023 03:20:14 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:37090) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pchuF-0001kJ-H0 for 62142@debbugs.gnu.org; Thu, 16 Mar 2023 03:20:11 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pchuA-0006gd-9A; Thu, 16 Mar 2023 03:20:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=Qk5OIL4cDF8zug8/t9Lfu7DDoHFcXehXmPA69moUoB4=; b=Y//YYb4uVr+x94pZlGBV JCEY0SiHmY0Wx3BdenVgAD97Ug4KpPsurWnttBgVxfmSNwYJ1XlVORpQoPz2pH5Ul6t4vCo6ZZQNe 40grfROqy8catNE7QphKozJZemeXvfpm5flclYLa8ZHXEYYgRSZCMKRPl5+CiarEh8Jf10G6xvcKt t517wTjJNOdrUr4cpHkQjlTQ6G1eQEkjkfXhdpwBpdi4bGcZXlA6cI8ef/l9yrghdcBW8DUNbvPh6 8zm+ZiV87mll955Ss+Kr6Ug74USaerY9FZALHMbCAv6JZ2euTP4OR039ULdPC8ww14GWZBqqtGiel kfIm8s5zF4tceg==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pchu9-0007nP-LC; Thu, 16 Mar 2023 03:20:05 -0400 In-Reply-To: (message from kobarity on Sun, 12 Mar 2023 17:39:37 +0900) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:258007 Archived-At: > Cc: Stefan Monnier , > João Távora > Date: Sun, 12 Mar 2023 17:39:37 +0900 > From: kobarity > > 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 > 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 > 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.