From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#60856: 29.0.60; C-M-f in python-ts-mode does not work properly with docstrings Date: Sun, 22 Jan 2023 11:30:17 +0100 Message-ID: <87ilgy7tfq.fsf@thornhill.no> References: <87sfgardb4.fsf@galileo.mail-host-address-is-not-set> Reply-To: Theodor Thornhill Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32441"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 60856@debbugs.gnu.org To: Apostolis Bessas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 22 11:31:07 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 1pJXcw-0008HL-Mj for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 22 Jan 2023 11:31:06 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pJXct-0005jm-1V; Sun, 22 Jan 2023 05:31:03 -0500 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 1pJXcs-0005je-33 for bug-gnu-emacs@gnu.org; Sun, 22 Jan 2023 05:31:02 -0500 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 1pJXcr-00065E-RX for bug-gnu-emacs@gnu.org; Sun, 22 Jan 2023 05:31:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pJXcr-0007B2-Nx for bug-gnu-emacs@gnu.org; Sun, 22 Jan 2023 05:31:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 22 Jan 2023 10:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60856 X-GNU-PR-Package: emacs Original-Received: via spool by 60856-submit@debbugs.gnu.org id=B60856.167438342127542 (code B ref 60856); Sun, 22 Jan 2023 10:31:01 +0000 Original-Received: (at 60856) by debbugs.gnu.org; 22 Jan 2023 10:30:21 +0000 Original-Received: from localhost ([127.0.0.1]:50753 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pJXcD-0007A9-8v for submit@debbugs.gnu.org; Sun, 22 Jan 2023 05:30:21 -0500 Original-Received: from out2.migadu.com ([188.165.223.204]:63055) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pJXcB-0007A2-GB for 60856@debbugs.gnu.org; Sun, 22 Jan 2023 05:30:20 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1674383418; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=aC4jqMmlQqEYIfREflKhiUw8hZGyaFld74hW6cxKmbA=; b=hlnYkCEZ01LOI6ZzzqvFGupRTWvyC35opKm2ylLsHijha4GvCPhJM57ci5z7u7CK1dNoFq z8oqsBfRsVpunCDaeAlDfB/vrvXK0AQgAu0bO1GD2QCy/pMzfglgmZvnWGV/I+65pwGUCd Sn1q9V49OWT8CTni5DYPHrPeFkNDSrrbzBJQnGka6D0Y25O8j/cSlrNntiiGYQJ9Vo2NeU JNgX33nU1iozlrbHB2jXxTdpUSG9vFuKoVk7HmGk/vGiyEUimbkbiid5FsekcydiToQ1PE 05U5MWOVMeJ48nn6ntLdLlDiBjulY6NT4kku3Lue/Km90oGjIFPiJe0OVb2w8Q== In-Reply-To: <87sfgardb4.fsf@galileo.mail-host-address-is-not-set> (Apostolis Bessas's message of "Mon, 16 Jan 2023 12:20:15 +0200") X-Migadu-Flow: FLOW_OUT 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:253922 Archived-At: --=-=-= Content-Type: text/plain Apostolis Bessas writes: > In python-ts-mode executing C-M-f (forward-sexp) when at the beginning > of a docstring does not go to the end of the docstring (as happens in > python-mode), but at the end of the file. > > However, if I switch to python-mode and then back to python-ts-mode, > C-M-f works correctly. See the following example: > > - Start emacs -Q > - Execute: > > (add-to-list 'auto-mode-alist '("\\.py\\'" . python-ts-mode)) > > - Create the file test.py with the contents: > > """Some docstring. > > The docstring has multiple lines. > """ > > x = 1 > Can you test this patch? More nodes are needed, but this is a start, I think. Must be applied to the master branch :) Theo --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-sentence-and-sexp-movement-to-python-ts-mode.patch >From bec1839da51e1fe6c399e636d1cf476fe76682c9 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Sun, 22 Jan 2023 11:27:37 +0100 Subject: [PATCH] Add sentence and sexp movement to python-ts-mode * lisp/progmodes/python.el (python-ts-mode): Add relevant node types. --- lisp/progmodes/python.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 21d16db287..2a8fb5fcf5 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -6710,6 +6710,20 @@ python-ts-mode "_definition")) (setq-local treesit-defun-name-function #'python--treesit-defun-name) + + (setq-local treesit-sentence-type-regexp + (regexp-opt '("statement" + "clause"))) + + (setq-local treesit-sexp-type-regexp + (regexp-opt '("expression" + "string" + "call" + "operator" + "identifier" + "integer" + "float"))) + (treesit-major-mode-setup) (when python-indent-guess-indent-offset -- 2.34.1 --=-=-=--