From unknown Sun Jul 13 03:51:05 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#59662 <59662@debbugs.gnu.org> To: bug#59662 <59662@debbugs.gnu.org> Subject: Status: 29.0.50; [PATCH] Add treesit--indent-defun Reply-To: bug#59662 <59662@debbugs.gnu.org> Date: Sun, 13 Jul 2025 10:51:05 +0000 retitle 59662 29.0.50; [PATCH] Add treesit--indent-defun reassign 59662 emacs submitter 59662 Theodor Thornhill severity 59662 wishlist tag 59662 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 28 14:32:25 2022 Received: (at submit) by debbugs.gnu.org; 28 Nov 2022 19:32:25 +0000 Received: from localhost ([127.0.0.1]:50467 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozjrc-0001Vm-ML for submit@debbugs.gnu.org; Mon, 28 Nov 2022 14:32:25 -0500 Received: from lists.gnu.org ([209.51.188.17]:41730) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozjrb-0001Vg-N7 for submit@debbugs.gnu.org; Mon, 28 Nov 2022 14:32:24 -0500 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 1ozjrU-00053h-7Y for bug-gnu-emacs@gnu.org; Mon, 28 Nov 2022 14:32:23 -0500 Received: from out-32.mta0.migadu.com ([91.218.175.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ozjrR-0001Zy-97 for bug-gnu-emacs@gnu.org; Mon, 28 Nov 2022 14:32:15 -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=1669663928; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=TyTHYPrsIk2rsa9W42wYAy08bqH3nrEqsjmkd1M0xUU=; b=EMFaa2tcpVHiZmxSlpddfh7XoAIQDKLOVqNGLEOmHYjes28Pxfru3qEDLicZKO95hnkqrm yxIgDZ/W9HOkvtsyN42fCbZGn4bWTtEL6cvNQGSQhQmq1LvvfkdyW0UdBRGJ0/nvoWrtUq zPRJ4XOjPTpa4aff7tRdxhMKHrAZ59MD53PyJ+gZclVwcESCxItySZl9ubYKmpCt8j+zuz TuqozQDP/rcINuHHcmmqYsZwCqQTbJtGSmJVobXETLd7skgz6DphDv7UtfHkY84ymB45u3 fgkmwGwFFcTOVf6LELG6n6djxun9IXTDNL0ciCaQ/jGfhz0R9fgIv//+uubl2Q== From: Theodor Thornhill To: bug-gnu-emacs@gnu.org Subject: 29.0.50; [PATCH] Add treesit--indent-defun X-Debbugs-CC: eliz@gnu.org, casouri@gmail.org Date: Mon, 28 Nov 2022 20:32:01 +0100 Message-ID: <874juig9ji.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=91.218.175.32; envelope-from=theo@thornhill.no; helo=out-32.mta0.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) --=-=-= Content-Type: text/plain Hi Eli and Yuan! I've added a function to treesit.el, for use in treesit-major-mode-setup. Because the treesit-defun-type-regexp gives us "defuns" for free, we can set fill-paragraph-function to this new function, thus enabling quick formatting, and some sensible default for fill-paragraph. It aims to mirror c-indent-defun. I think this is a nice way to get this functionality for free, but I'm not 100% whether this is considered ok or not. An alternative could be to add a 'treesit-mode-map' where we can auto-enable such constructs. Feel free to apply if it looks ok. Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-treesit-indent-defun.patch >From aed3f136d530c0eaa83c385cac7388c853b4f99a Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Mon, 28 Nov 2022 20:19:20 +0100 Subject: [PATCH] Add treesit--indent-defun We can piggyback on the already existing 'treesit-defun-type-regexp' to decide a scope to reindent/reformat. By setting fill-paragraph-function major modes that implement 'treesit-defun-type-regexp' will get this functionality for free, by default bound to M-q. * lisp/treesit.el (treesit--indent-defun): New function. (treesit-major-mode-setup): Enable this functionality when prereqs are fulfilled. --- lisp/treesit.el | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lisp/treesit.el b/lisp/treesit.el index 8f092f475d..685c59aedb 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1451,6 +1451,21 @@ treesit-simple-indent (message "No matched rule")) (cons nil nil)))))) +(defun treesit--indent-defun (&optional _arg) + "Indent the current defun. + +Uses `treesit-defun-type-regexp' to determine which nodes to +reindent." + (interactive) + (when-let ((defun-node + (save-excursion + (treesit-search-forward-goto + (treesit-node-at (point)) + treesit-defun-type-regexp t t)))) + (treesit-indent-region + (treesit-node-start defun-node) + (treesit-node-end defun-node)))) + (defun treesit-check-indent (mode) "Check current buffer's indentation against a major mode MODE. @@ -1698,7 +1713,10 @@ treesit-major-mode-setup ;; Navigation. (when treesit-defun-type-regexp (setq-local beginning-of-defun-function #'treesit-beginning-of-defun) - (setq-local end-of-defun-function #'treesit-end-of-defun))) + (setq-local end-of-defun-function #'treesit-end-of-defun)) + ;; Filling + (when (and treesit-defun-type-regexp treesit-simple-indent-rules) + (setq-local fill-paragraph-function #'treesit--indent-defun))) ;;; Debugging -- 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 29 01:10:34 2022 Received: (at 59662) by debbugs.gnu.org; 29 Nov 2022 06:10:34 +0000 Received: from localhost ([127.0.0.1]:53375 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oztpC-00044A-4N for submit@debbugs.gnu.org; Tue, 29 Nov 2022 01:10:34 -0500 Received: from out2.migadu.com ([188.165.223.204]:36066) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oztp9-000444-5B for 59662@debbugs.gnu.org; Tue, 29 Nov 2022 01:10:32 -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=1669702229; 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=yNiU0ngKyt40G+5Nx8lfiYM3volYv+cCGH5HkAza9c8=; b=YC6/snX1uPABpy0q90iEXd/Xnpp747oDk3Gm7gKGZagFm6K5nUs3ix+BpG3obYnIC2UMgK csaQKvpKHLAMEStGxp7rXjfuFn07N3g6lLXQCstz/U7euhXAQ6pdYN+ikgIewbPgOYLsK5 FEKglmKEiAnolydD97XTdqgGDeWi+yXVZ6GX98gEA4w1XR5L7htzqIGu4UB5y/+0nWQChX o4vgjLnEw/2segrOfYgL8yzwdeSZurzzBdWGoH2GJjf4nSt4tSewZ87hLOHqf4r9QJWpXM E+BmA+FdHGpKpf3PHbcTjygnmfYqnd9tTQ+Y8Mdu/b30oluhMy277wGgKgQG1w== From: Theodor Thornhill To: 59662@debbugs.gnu.org Subject: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: References: <874juig9ji.fsf@thornhill.no> Date: Tue, 29 Nov 2022 07:10:23 +0100 Message-ID: <87sfi2jnow.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: casuri@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Rebased on newest emacs-29 and added bug number in commit. Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-treesit-indent-defun.patch >From 0a39367e16849ca10775ffbe08c2929f95df1470 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Mon, 28 Nov 2022 20:19:20 +0100 Subject: [PATCH] Add treesit--indent-defun We can piggyback on the already existing 'treesit-defun-type-regexp' to decide a scope to reindent/reformat. By setting fill-paragraph-function major modes that implement 'treesit-defun-type-regexp' will get this functionality for free, by default bound to M-q. * lisp/treesit.el (treesit--indent-defun): New function. (treesit-major-mode-setup): Enable this functionality when prereqs are fulfilled. (bug#59662) --- lisp/treesit.el | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lisp/treesit.el b/lisp/treesit.el index 8f092f475d..685c59aedb 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1451,6 +1451,21 @@ treesit-simple-indent (message "No matched rule")) (cons nil nil)))))) +(defun treesit--indent-defun (&optional _arg) + "Indent the current defun. + +Uses `treesit-defun-type-regexp' to determine which nodes to +reindent." + (interactive) + (when-let ((defun-node + (save-excursion + (treesit-search-forward-goto + (treesit-node-at (point)) + treesit-defun-type-regexp t t)))) + (treesit-indent-region + (treesit-node-start defun-node) + (treesit-node-end defun-node)))) + (defun treesit-check-indent (mode) "Check current buffer's indentation against a major mode MODE. @@ -1698,7 +1713,10 @@ treesit-major-mode-setup ;; Navigation. (when treesit-defun-type-regexp (setq-local beginning-of-defun-function #'treesit-beginning-of-defun) - (setq-local end-of-defun-function #'treesit-end-of-defun))) + (setq-local end-of-defun-function #'treesit-end-of-defun)) + ;; Filling + (when (and treesit-defun-type-regexp treesit-simple-indent-rules) + (setq-local fill-paragraph-function #'treesit--indent-defun))) ;;; Debugging -- 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 29 07:01:32 2022 Received: (at 59662) by debbugs.gnu.org; 29 Nov 2022 12:01:32 +0000 Received: from localhost ([127.0.0.1]:54316 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozzIq-0007nh-42 for submit@debbugs.gnu.org; Tue, 29 Nov 2022 07:01:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46856) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozzIo-0007nb-4L for 59662@debbugs.gnu.org; Tue, 29 Nov 2022 07:01:30 -0500 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 1ozzIh-0001Y4-B2; Tue, 29 Nov 2022 07:01:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=UoYRsqvRZJWOpktISJswaoHwMX4x1yvVPBYScpnOICA=; b=HiMlQmg5mM7G N+SKGCJq/sBNt1lsQP6TYaywOysFLAWpQwRhYoMCvvB81wkTJjkBj4CmHwcYjub7yuLUjBIWUxq2X Jq/HGId+PeZisj0iv2Z5E6DrNx58wBTK2PXacmkrqyd9H5l/6lmzGVXgP6LH6UGu5AF7pG1HT64Jr ql/d0mh7NTVwwxQDIAGU2/DSwVKjlLCT+cXuMlj/8UOWnTp/Jdh8Ua41rzuKIdyPCkTGorMkullSl QRwAF6BGCYSiuaZUoW3MHQcYEH7+n9cyE8Lc5fSxpSyqHrxL0GFzIHrFKM2AF937u1qFdNUuteA80 dja9TH07/9osssZeUd0tcw==; 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 1ozzIf-0005L1-KH; Tue, 29 Nov 2022 07:01:23 -0500 Date: Tue, 29 Nov 2022 14:01:54 +0200 Message-Id: <83lenum0jx.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: <874juig9ji.fsf@thornhill.no> (message from Theodor Thornhill on Mon, 28 Nov 2022 20:32:01 +0100) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <874juig9ji.fsf@thornhill.no> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: 59662@debbugs.gnu.org, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Cc: eliz@gnu.org, casouri@gmail.org > From: Theodor Thornhill > Date: Mon, 28 Nov 2022 20:32:01 +0100 > > I've added a function to treesit.el, for use in > treesit-major-mode-setup. Because the treesit-defun-type-regexp gives > us "defuns" for free, we can set fill-paragraph-function to this new > function, thus enabling quick formatting, and some sensible default for > fill-paragraph. It aims to mirror c-indent-defun. > > I think this is a nice way to get this functionality for free, but I'm > not 100% whether this is considered ok or not. Sounds good, but why did you think it wouldn't be OK? Anything here that doesn't meet the eye? > An alternative could be to add a 'treesit-mode-map' where we can > auto-enable such constructs. I think this is less desirable. Yuan, WDYT? > @@ -1698,7 +1713,10 @@ treesit-major-mode-setup > ;; Navigation. > (when treesit-defun-type-regexp > (setq-local beginning-of-defun-function #'treesit-beginning-of-defun) > - (setq-local end-of-defun-function #'treesit-end-of-defun))) > + (setq-local end-of-defun-function #'treesit-end-of-defun)) > + ;; Filling > + (when (and treesit-defun-type-regexp treesit-simple-indent-rules) > + (setq-local fill-paragraph-function #'treesit--indent-defun))) I'm a bit confused: if the function's name is treesit--indent-defun, and it uses treesit-indent-region to do its job, why do we assign it to fill-paragraph-function, which is supposed to _fill_, not to _indent_? From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 29 07:14:34 2022 Received: (at 59662) by debbugs.gnu.org; 29 Nov 2022 12:14:34 +0000 Received: from localhost ([127.0.0.1]:54365 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozzVR-0007wF-JG for submit@debbugs.gnu.org; Tue, 29 Nov 2022 07:14:33 -0500 Received: from out2.migadu.com ([188.165.223.204]:29597) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozzVI-0007vq-Og for 59662@debbugs.gnu.org; Tue, 29 Nov 2022 07:14:26 -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=1669724063; 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=lwRTTQh3Ax4BGDUzXp4rLuJm8vyFii4NIOR6OSOPPfc=; b=G4UbUwM7rDrnZ5JpgE+Oi9E3yX8XwNsDG3xadYwksnJV7MKu8XGU7PiZb4jVPrlXx6y1tn JxLP2u6MgPKsAlwOcYH/Jc9QC8lvZAgXpxJQxfwxZv1Xo5XKLjlI5lyJkZNRb/pgkXqudz sjSaEVIqFTZtRVHBVpKqDJ7QMZy8HPc828E9r93TeqK/cDvehPvOTaZQECnYzHnSyNU9RT vw3umACmrUac1YpnTQg0pPpK55t0Qrw/A/MbKNNKyIVKG2RDEhgzx8ZDfsFRoa8eX+I9cV ivvyXzqO9xpzqHZ420VjUmDNMFFNWh2wiayNC9cI1nYVsd4vex/E1zA1SgRtUw== From: Theodor Thornhill To: Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <83lenum0jx.fsf@gnu.org> References: <874juig9ji.fsf@thornhill.no> <83lenum0jx.fsf@gnu.org> Date: Tue, 29 Nov 2022 13:14:21 +0100 Message-ID: <87bkoqj6ua.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: 59662@debbugs.gnu.org, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> Cc: eliz@gnu.org, casouri@gmail.org >> From: Theodor Thornhill >> Date: Mon, 28 Nov 2022 20:32:01 +0100 >> >> I've added a function to treesit.el, for use in >> treesit-major-mode-setup. Because the treesit-defun-type-regexp gives >> us "defuns" for free, we can set fill-paragraph-function to this new >> function, thus enabling quick formatting, and some sensible default for >> fill-paragraph. It aims to mirror c-indent-defun. >> >> I think this is a nice way to get this functionality for free, but I'm >> not 100% whether this is considered ok or not. > > Sounds good, but why did you think it wouldn't be OK? Anything here that > doesn't meet the eye? > Not really, but see below answer. >> An alternative could be to add a 'treesit-mode-map' where we can >> auto-enable such constructs. > > I think this is less desirable. > > Yuan, WDYT? > >> @@ -1698,7 +1713,10 @@ treesit-major-mode-setup >> ;; Navigation. >> (when treesit-defun-type-regexp >> (setq-local beginning-of-defun-function #'treesit-beginning-of-defun) >> - (setq-local end-of-defun-function #'treesit-end-of-defun))) >> + (setq-local end-of-defun-function #'treesit-end-of-defun)) >> + ;; Filling >> + (when (and treesit-defun-type-regexp treesit-simple-indent-rules) >> + (setq-local fill-paragraph-function #'treesit--indent-defun))) > > I'm a bit confused: if the function's name is treesit--indent-defun, and it > uses treesit-indent-region to do its job, why do we assign it to > fill-paragraph-function, which is supposed to _fill_, not to _indent_? This is why I was thinking it would maybe be better to put it into a treesit-mode-map that major-modes can inherit from, thus binding it to things such as C-c C-q. The reason I put it in filling was because that is a common key to press in everything _but_ prog-modes. And prog-modes seem to mostly just turn it off if not inside of comments etc. This would behave just like that, except we would reformat/reindent/refill code. In a way filling _is_ formatting/reindenting, at least that's how I look at it. Theo From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 29 09:15:01 2022 Received: (at 59662) by debbugs.gnu.org; 29 Nov 2022 14:15:01 +0000 Received: from localhost ([127.0.0.1]:54527 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p01O0-0002vt-VI for submit@debbugs.gnu.org; Tue, 29 Nov 2022 09:15:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46730) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p01Nv-0002vl-Ub for 59662@debbugs.gnu.org; Tue, 29 Nov 2022 09:14:59 -0500 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 1p01No-0004bL-Ln; Tue, 29 Nov 2022 09:14:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=ssQEoXqiNbJha8kLprHd9cmQtI3K2wV2nFBH5DEbgF4=; b=ouuSYPpQIufF p8i8Ul4FWUpu17+kVCucuxID+pwK06in6VEqkTGL2fhuEDa5o3F+6sbum4Eil38iJ4BzsLiuUOSZg VhK+ZVkECryEFuVKKat/j3Pj96vWuA+804hVZFoWJ7JvyFCV7c9v/Uto9WuKl/kO0OWUUrefa10Rw Qc3b7ZvicZ+J/+ablDyctUKN73Db/PFbr7cbM1zbwVuAq/ZQj5QLsgUIUhCBnZSqP4r4tjYEtMgVG yWb4b7NJOTmGsbh4Rey+xerLERBj5SSPSfXvFYxRkbbRJorm7fom7KjV4HXlb0F8z9AeGgCBNqXuy BXPKLnSv6hjt9ShC7mNAcg==; 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 1p01Nm-0006zO-RB; Tue, 29 Nov 2022 09:14:47 -0500 Date: Tue, 29 Nov 2022 16:15:19 +0200 Message-Id: <837czdn8y0.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: <87bkoqj6ua.fsf@thornhill.no> (message from Theodor Thornhill on Tue, 29 Nov 2022 13:14:21 +0100) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <874juig9ji.fsf@thornhill.no> <83lenum0jx.fsf@gnu.org> <87bkoqj6ua.fsf@thornhill.no> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: casouri@gmail.com, 59662@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Resending with correct address of Yuan. > From: Theodor Thornhill > Cc: 59662@debbugs.gnu.org, casouri@gmail.org > Date: Tue, 29 Nov 2022 13:14:21 +0100 > > Eli Zaretskii writes: > > >> Cc: eliz@gnu.org, casouri@gmail.org > >> From: Theodor Thornhill > >> Date: Mon, 28 Nov 2022 20:32:01 +0100 > >> > >> I've added a function to treesit.el, for use in > >> treesit-major-mode-setup. Because the treesit-defun-type-regexp gives > >> us "defuns" for free, we can set fill-paragraph-function to this new > >> function, thus enabling quick formatting, and some sensible default for > >> fill-paragraph. It aims to mirror c-indent-defun. > >> > >> I think this is a nice way to get this functionality for free, but I'm > >> not 100% whether this is considered ok or not. > > > > Sounds good, but why did you think it wouldn't be OK? Anything here that > > doesn't meet the eye? > > > > Not really, but see below answer. > > >> An alternative could be to add a 'treesit-mode-map' where we can > >> auto-enable such constructs. > > > > I think this is less desirable. > > > > Yuan, WDYT? > > > >> @@ -1698,7 +1713,10 @@ treesit-major-mode-setup > >> ;; Navigation. > >> (when treesit-defun-type-regexp > >> (setq-local beginning-of-defun-function #'treesit-beginning-of-defun) > >> - (setq-local end-of-defun-function #'treesit-end-of-defun))) > >> + (setq-local end-of-defun-function #'treesit-end-of-defun)) > >> + ;; Filling > >> + (when (and treesit-defun-type-regexp treesit-simple-indent-rules) > >> + (setq-local fill-paragraph-function #'treesit--indent-defun))) > > > > I'm a bit confused: if the function's name is treesit--indent-defun, and it > > uses treesit-indent-region to do its job, why do we assign it to > > fill-paragraph-function, which is supposed to _fill_, not to _indent_? > > This is why I was thinking it would maybe be better to put it into a > treesit-mode-map that major-modes can inherit from, thus binding it to > things such as C-c C-q. The reason I put it in filling was because that > is a common key to press in everything _but_ prog-modes. And prog-modes > seem to mostly just turn it off if not inside of comments etc. This > would behave just like that, except we would reformat/reindent/refill > code. > > In a way filling _is_ formatting/reindenting, at least that's how I look > at it. > > Theo > From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 30 05:33:45 2022 Received: (at 59662) by debbugs.gnu.org; 30 Nov 2022 10:33:45 +0000 Received: from localhost ([127.0.0.1]:60127 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0KPR-00079y-1T for submit@debbugs.gnu.org; Wed, 30 Nov 2022 05:33:45 -0500 Received: from mail-pj1-f43.google.com ([209.85.216.43]:38702) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0KPN-00079q-Us for 59662@debbugs.gnu.org; Wed, 30 Nov 2022 05:33:43 -0500 Received: by mail-pj1-f43.google.com with SMTP id l22-20020a17090a3f1600b00212fbbcfb78so1502401pjc.3 for <59662@debbugs.gnu.org>; Wed, 30 Nov 2022 02:33:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=1Rz0uQAsTLzsUS1EenXt/C+eLodx9v/dNRSXeqQy6Rg=; b=JvzQvEnqzZWGkA7crFyzSdTzFbfMGYoIRyNMEHsRkg7JK3FsNOGvLQtIzPpTNVMGmQ lB7JcYlxC7LbgI2iuFzfn5ypiaiWzsing70kL/J0NAij/M1wlr0msj9rv6Fv8xsp6Vfi t2edixYYxedL05HYwarZneiz+6OGtcGKm+3a0MoHZCA9QjpL1DvEfMHl964RZDq2icTm WSPnZc/RiR7Q1Xl4YdyKIpgm237OdO3mf2dyLKKQU22u6MRJIWkHDL4j42uJTLvHQLpQ 8zTIB32FL6cBIuRS9n3qkqcagezQEs86zpGnT+8AA9tHIKC+hsSbJIrKjGbU+huluhdx CoZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1Rz0uQAsTLzsUS1EenXt/C+eLodx9v/dNRSXeqQy6Rg=; b=4Z7lziHY84LA814QR96YsfugX5Qb/dqaCm3E9H2vl+w7kTVTHATOu8QtPPhFlVgBz8 DLKRb2P0gXhv/UaSy2eIhCwq9HfcAoll7Xm/bkIRUJVWZZgcoUiSk8oemU20zKnRjquv chLpFzyr++/eg35djr53jhfhY8SrCy7JyrAybKQS2UhA+I2ugVLkdo3SkiLetlP5E/25 LGvXZlYjPUe39Ewyar3JbKOkhkfVkiX+cmyOSRpUb8r8lo73LLjD+7LuLb1+SPWaeQh6 HR92fkaz/J+q/PTWrsGVBvTOX0kN+itG/NlNb0JmnWwrMuvu2zR6rg0jNxSoZ0wjFJoz r9mA== X-Gm-Message-State: ANoB5pnAKHD5im0mNmb7LkoTCaPD0LcwaXiJc0jAtQ6AoSSECK7WWqXA dm8n7BhBS7UsJ3zz0vGWsYw= X-Google-Smtp-Source: AA0mqf4hq4vNQViFsS0zfsajRbyjGtgs/C2KUI8olygf8tuIM1p/HDqWTVShb85LyRyKWjebPDtL7w== X-Received: by 2002:a17:90a:fa03:b0:219:813:bcb3 with SMTP id cm3-20020a17090afa0300b002190813bcb3mr28348329pjb.82.1669804416121; Wed, 30 Nov 2022 02:33:36 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id 16-20020a630f50000000b004767bc37e03sm744824pgp.39.2022.11.30.02.33.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Nov 2022 02:33:35 -0800 (PST) From: Yuan Fu Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Message-Id: <14C14797-987C-43D2-9A45-F8DB6AD898DE@gmail.com> Date: Wed, 30 Nov 2022 02:33:34 -0800 To: Eli Zaretskii X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: 59662@debbugs.gnu.org, theo@thornhill.no X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: > Resending with correct address of Yuan. > >> From: Theodor Thornhill >> Cc: 59662@debbugs.gnu.org, casouri@gmail.org >> Date: Tue, 29 Nov 2022 13:14:21 +0100 >>=20 >> Eli Zaretskii writes: >>=20 >> >> Cc: eliz@gnu.org, casouri@gmail.org >> >> From: Theodor Thornhill >> >> Date: Mon, 28 Nov 2022 20:32:01 +0100 >> >>=20 >> >> I've added a function to treesit.el, for use in >> >> treesit-major-mode-setup. Because the treesit-defun-type-regexp = gives >> >> us "defuns" for free, we can set fill-paragraph-function to this = new >> >> function, thus enabling quick formatting, and some sensible = default for >> >> fill-paragraph. It aims to mirror c-indent-defun. >> >>=20 >> >> I think this is a nice way to get this functionality for free, but = I'm >> >> not 100% whether this is considered ok or not. >> > >> > Sounds good, but why did you think it wouldn't be OK? Anything = here that >> > doesn't meet the eye? >> > >>=20 >> Not really, but see below answer. >>=20 >> >> An alternative could be to add a 'treesit-mode-map' where we can >> >> auto-enable such constructs. >> > >> > I think this is less desirable. >> > >> > Yuan, WDYT? >> > >> >> @@ -1698,7 +1713,10 @@ treesit-major-mode-setup >> >> ;; Navigation. >> >> (when treesit-defun-type-regexp >> >> (setq-local beginning-of-defun-function = #'treesit-beginning-of-defun) >> >> - (setq-local end-of-defun-function #'treesit-end-of-defun))) >> >> + (setq-local end-of-defun-function #'treesit-end-of-defun)) >> >> + ;; Filling >> >> + (when (and treesit-defun-type-regexp = treesit-simple-indent-rules) >> >> + (setq-local fill-paragraph-function = #'treesit--indent-defun))) >> > >> > I'm a bit confused: if the function's name is = treesit--indent-defun, and it >> > uses treesit-indent-region to do its job, why do we assign it to >> > fill-paragraph-function, which is supposed to _fill_, not to = _indent_? >>=20 >> This is why I was thinking it would maybe be better to put it into a >> treesit-mode-map that major-modes can inherit from, thus binding it = to >> things such as C-c C-q. The reason I put it in filling was because = that >> is a common key to press in everything _but_ prog-modes. And = prog-modes >> seem to mostly just turn it off if not inside of comments etc. This >> would behave just like that, except we would reformat/reindent/refill >> code. >>=20 >> In a way filling _is_ formatting/reindenting, at least that's how I = look >> at it. >>=20 >> Theo >>=20 I was caught up in some stuff the past two days, sorry about that :-) I=E2=80=99ll have a look tomorrow! Yuan From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 30 18:23:29 2022 Received: (at 59662) by debbugs.gnu.org; 30 Nov 2022 23:23:29 +0000 Received: from localhost ([127.0.0.1]:35725 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0WQL-0005GR-62 for submit@debbugs.gnu.org; Wed, 30 Nov 2022 18:23:29 -0500 Received: from mail-pg1-f176.google.com ([209.85.215.176]:39724) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0WQI-0005GK-6f for 59662@debbugs.gnu.org; Wed, 30 Nov 2022 18:23:28 -0500 Received: by mail-pg1-f176.google.com with SMTP id 6so110896pgm.6 for <59662@debbugs.gnu.org>; Wed, 30 Nov 2022 15:23:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=LKt7ohb0/EJWQ49g43BzSuGaCcxuG3KwSVQVGIsSU0w=; b=Vl6AnHK6zYDk6/bBfw1JuqrsIHXAGJM4DIIeIuogG7TKizFtDMaEaT1uuNNhzQugKM GRRpVfV0120xmCn4lT36ZxtR8fA/4FOA7ScwBkL2Lj68Yq2HFTuI6RdXLScmryMMaYHn DnZKDwP43Ql7+WoS8Xp9mIUwylVPNZ6n89yyl/5XmeMgy2yqWsIJzuBhR2FMk6VSEeq4 1jmzpCyG+O3foYuS+9NFol7aT+zBlYr1tbjU8YTgyJPXCBosibsiUYyYSm5x0BpX1hA/ ttlKoLx0F1Wzv4+s2f3R10f7tSE1ZXmBBNrM0Xi11ffVFR/VY6cthwqRoalOyaZXIjwd kU4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LKt7ohb0/EJWQ49g43BzSuGaCcxuG3KwSVQVGIsSU0w=; b=Ay3QsE9cKIg55Yuqf2lUvaSxrRPIUo8t9d3ESa+OoT3yie9OHzolX9wJnl28AEV/mN SvbQFWYWh/pefgESKFLT8D/a7yinsCRGwIduVx7/wbPw3yRCKOaD+Dr/jhyBbcMDy7A7 ZdF4e8qPTSCMLysonpWuQg5EQoX6SY+SByeUDAzL+Yy+BN63KKzMGMRxttkxMPxTXjLZ U1UYDSRa1RVWk0LTOiRSfXAcZAiHSqIFE8EN0IBhTcMwu57Np1FC+0Ik0+BdKQHQN+Yu Ld0iD/5iWk+WEhy2jGHsCJvB96/NIe+iW7zAlcaXWS502tXY8ls7XcFFMnswoWVfXSDX IiPQ== X-Gm-Message-State: ANoB5plWiX0L5y4UHOk0q8u8PN2WPiEN4V2fuC4yCwiypcE1w0LUZ4B/ /icgZiF5VwCARP6M17x+cWI= X-Google-Smtp-Source: AA0mqf4kUtOmPYHSK2c/wcs6nwFzOjNoN7OSbPyXTL11iw6x0tMt9pRyg4WvUF34BQRmEDvFnHqdoQ== X-Received: by 2002:a63:4f48:0:b0:477:4451:cf5 with SMTP id p8-20020a634f48000000b0047744510cf5mr37976848pgl.391.1669850598822; Wed, 30 Nov 2022 15:23:18 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id c13-20020a631c0d000000b00476db6fe510sm1417254pgc.75.2022.11.30.15.23.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Nov 2022 15:23:18 -0800 (PST) From: Yuan Fu Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Message-Id: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> Date: Wed, 30 Nov 2022 15:23:17 -0800 To: Theodor Thornhill X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: Eli Zaretskii , 59662@debbugs.gnu.org, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Theodor Thornhill writes: > Eli Zaretskii writes: > >>> Cc: eliz@gnu.org, casouri@gmail.org >>> From: Theodor Thornhill >>> Date: Mon, 28 Nov 2022 20:32:01 +0100 >>>=20 >>> I've added a function to treesit.el, for use in >>> treesit-major-mode-setup. Because the treesit-defun-type-regexp = gives >>> us "defuns" for free, we can set fill-paragraph-function to this new >>> function, thus enabling quick formatting, and some sensible default = for >>> fill-paragraph. It aims to mirror c-indent-defun. >>>=20 >>> I think this is a nice way to get this functionality for free, but = I'm >>> not 100% whether this is considered ok or not. >> >> Sounds good, but why did you think it wouldn't be OK? Anything here = that >> doesn't meet the eye? >> > > Not really, but see below answer. > >>> An alternative could be to add a 'treesit-mode-map' where we can >>> auto-enable such constructs. >> >> I think this is less desirable. >> >> Yuan, WDYT? >> >>> @@ -1698,7 +1713,10 @@ treesit-major-mode-setup >>> ;; Navigation. >>> (when treesit-defun-type-regexp >>> (setq-local beginning-of-defun-function = #'treesit-beginning-of-defun) >>> - (setq-local end-of-defun-function #'treesit-end-of-defun))) >>> + (setq-local end-of-defun-function #'treesit-end-of-defun)) >>> + ;; Filling >>> + (when (and treesit-defun-type-regexp treesit-simple-indent-rules) >>> + (setq-local fill-paragraph-function #'treesit--indent-defun))) >> >> I'm a bit confused: if the function's name is treesit--indent-defun, = and it >> uses treesit-indent-region to do its job, why do we assign it to >> fill-paragraph-function, which is supposed to _fill_, not to = _indent_? > > This is why I was thinking it would maybe be better to put it into a > treesit-mode-map that major-modes can inherit from, thus binding it to > things such as C-c C-q. The reason I put it in filling was because = that > is a common key to press in everything _but_ prog-modes. And = prog-modes > seem to mostly just turn it off if not inside of comments etc. This > would behave just like that, except we would reformat/reindent/refill > code. > > In a way filling _is_ formatting/reindenting, at least that's how I = look > at it. I see, so you want to implement C-c C-q in c-mode. But why don=E2=80=99t = we make treesit--indent-defun a command and bind it in C-c C-q in major = modes?=20 Filling is not indent IMO. If you fill a list in elisp code it wraps = long lines=20 instead of indent (IIRC). Also, this is really not tree-sitter specific, it doesn=E2=80=99t = require any tree-sitter feature to accomplish: indent-defun only needs mark-defun and indent-region, both are supported by practically any major mode. Normally this kind of thing goes into lisp.el, alongside commands like fill-paragraph, indent-region, beginning-of-defun, etc, and claim a global keybinding. But maybe we only want it to live under C-c prefix, in that case I guess we can bind it in prog-mode-map, under C-c C-q? I=E2=80=99m thinking something like (defun prog-mode-indent-defun () (interactive) (mark-defun) (indent-region (region-beginning) (region-end))) (defvar prog-mode-map (... (define-key map (kbd "C-c C-q") #'prog-mode-indent-defun))) Yuan From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 30 20:08:01 2022 Received: (at 59662) by debbugs.gnu.org; 1 Dec 2022 01:08:01 +0000 Received: from localhost ([127.0.0.1]:36206 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0Y3U-0006AK-K8 for submit@debbugs.gnu.org; Wed, 30 Nov 2022 20:08:01 -0500 Received: from mail-pf1-f178.google.com ([209.85.210.178]:35772) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0Y3Q-0006A7-DA for 59662@debbugs.gnu.org; Wed, 30 Nov 2022 20:07:59 -0500 Received: by mail-pf1-f178.google.com with SMTP id w79so437931pfc.2 for <59662@debbugs.gnu.org>; Wed, 30 Nov 2022 17:07:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=e+xu5oFil4jpsEgi54bFrumSI63Wxo9UqfNyL3UKWlw=; b=k5DvKomjLftOeVdOFnJHlSxIlfDAtKkzqO+oHV+8sI5Q0OeA7by8iptOrocpq6RmZ0 y6gheM9kenmD2tnMCBi17GS58JAMuj8OG7LBThdcsjEUYkTdfHF845VqhQYct3wYr5f6 LpJ3ijDsPTUd16nKkc67TM9wBeSwUiRD99fSRENKuFBE7HdLQNk3bjkqaL3S8Y+rHmdx GiScTU0pd5sm7FaskmQUkXpaB+KpQB/0AXLoIlKuRQCX5IQdBE1irYtsrfAO0glIiu+q gVPxCrIgzFQH3y2FNNea/HoU8kqQXe2UMjudphNfC8ScA/o2hpOEfsmUsgb50uGRlbhd c1IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e+xu5oFil4jpsEgi54bFrumSI63Wxo9UqfNyL3UKWlw=; b=v7ga2gGxhMDnMhOprnXyaH97m1uQy1SVutA5/EKOWAexEqssQwC0/IcZGiZgfsvxkn ILMzYNAv+wNSBqoKpM2Zbmk4AB0yYDOKSB5LpG5Ju1EcSo8WcNlLNC6SEHFX8mHwPonK ATbNj2T87snuS0Clc0gGuOeSOyN2YFrCMmC73hwLnWM0dCkzxtf8/sIDr5mJE8onASkq 8Vc45iGBLlamHo4+ycI7SonpIvjxZ5zl376IfqJtLgQ9M9eX0EI1bJj9K/ATQFKjvJpW Hgsh0phdyJdVZm/4ReGav+C/IYlfSVnWNUIKQ5hcjys5ShDS+MGTNxCArFhRasOFw7/N Gz6A== X-Gm-Message-State: ANoB5pnn3gHkvyO8IhHCZL914ZJRwHk0SlMlxlnD9GEbW89g16zKyOIo pRoYWw38wES7mlaxA3gla+8= X-Google-Smtp-Source: AA0mqf6wi7yqOqXWEd3rZHXa/T+WsKa4MapBak8fAXaGygYHitKaGxJ81dNLlUGhT3t6rRanGB6Hfw== X-Received: by 2002:a05:6a00:1c8f:b0:574:6880:e76f with SMTP id y15-20020a056a001c8f00b005746880e76fmr36451076pfw.35.1669856869989; Wed, 30 Nov 2022 17:07:49 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id v30-20020aa799de000000b0056b3c863950sm1983888pfi.8.2022.11.30.17.07.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Nov 2022 17:07:49 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun From: Yuan Fu In-Reply-To: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> Date: Wed, 30 Nov 2022 17:07:48 -0800 Content-Transfer-Encoding: quoted-printable Message-Id: <0EC6C5BE-321E-43E9-92F9-D829DBBD36A7@gmail.com> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> To: Theodor Thornhill X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: Eli Zaretskii , 59662@debbugs.gnu.org, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > On Nov 30, 2022, at 3:23 PM, Yuan Fu wrote: >=20 >=20 > Theodor Thornhill writes: >=20 >> Eli Zaretskii writes: >>=20 >>>> Cc: eliz@gnu.org, casouri@gmail.org >>>> From: Theodor Thornhill >>>> Date: Mon, 28 Nov 2022 20:32:01 +0100 >>>>=20 >>>> I've added a function to treesit.el, for use in >>>> treesit-major-mode-setup. Because the treesit-defun-type-regexp = gives >>>> us "defuns" for free, we can set fill-paragraph-function to this = new >>>> function, thus enabling quick formatting, and some sensible default = for >>>> fill-paragraph. It aims to mirror c-indent-defun. >>>>=20 >>>> I think this is a nice way to get this functionality for free, but = I'm >>>> not 100% whether this is considered ok or not. >>>=20 >>> Sounds good, but why did you think it wouldn't be OK? Anything here = that >>> doesn't meet the eye? >>>=20 >>=20 >> Not really, but see below answer. >>=20 >>>> An alternative could be to add a 'treesit-mode-map' where we can >>>> auto-enable such constructs. >>>=20 >>> I think this is less desirable. >>>=20 >>> Yuan, WDYT? >>>=20 >>>> @@ -1698,7 +1713,10 @@ treesit-major-mode-setup >>>> ;; Navigation. >>>> (when treesit-defun-type-regexp >>>> (setq-local beginning-of-defun-function = #'treesit-beginning-of-defun) >>>> - (setq-local end-of-defun-function #'treesit-end-of-defun))) >>>> + (setq-local end-of-defun-function #'treesit-end-of-defun)) >>>> + ;; Filling >>>> + (when (and treesit-defun-type-regexp = treesit-simple-indent-rules) >>>> + (setq-local fill-paragraph-function #'treesit--indent-defun))) >>>=20 >>> I'm a bit confused: if the function's name is treesit--indent-defun, = and it >>> uses treesit-indent-region to do its job, why do we assign it to >>> fill-paragraph-function, which is supposed to _fill_, not to = _indent_? >>=20 >> This is why I was thinking it would maybe be better to put it into a >> treesit-mode-map that major-modes can inherit from, thus binding it = to >> things such as C-c C-q. The reason I put it in filling was because = that >> is a common key to press in everything _but_ prog-modes. And = prog-modes >> seem to mostly just turn it off if not inside of comments etc. This >> would behave just like that, except we would reformat/reindent/refill >> code. >>=20 >> In a way filling _is_ formatting/reindenting, at least that's how I = look >> at it. >=20 > I see, so you want to implement C-c C-q in c-mode. But why don=E2=80=99t= we > make treesit--indent-defun a command and bind it in C-c C-q in major = modes?=20 > Filling is not indent IMO. If you fill a list in elisp code it wraps = long lines=20 > instead of indent (IIRC). >=20 > Also, this is really not tree-sitter specific, it doesn=E2=80=99t = require any > tree-sitter feature to accomplish: indent-defun only needs mark-defun > and indent-region, both are supported by practically any major mode. >=20 > Normally this kind of thing goes into lisp.el, alongside commands like > fill-paragraph, indent-region, beginning-of-defun, etc, and claim a > global keybinding. But maybe we only want it to live under C-c prefix, > in that case I guess we can bind it in prog-mode-map, under C-c C-q? >=20 > I=E2=80=99m thinking something like >=20 > (defun prog-mode-indent-defun () > (interactive) > (mark-defun) > (indent-region (region-beginning) (region-end))) >=20 > (defvar prog-mode-map > (... > (define-key map (kbd "C-c C-q") #'prog-mode-indent-defun))) Tho I=E2=80=99d prefer we bind it in major mode maps first. Adding = anything to prog-mode-map should go through emacs-devel (and I don=E2=80=99= t know if we want to add any bindings to prog-mode-map), of course. Yuan= From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 01 01:10:20 2022 Received: (at 59662) by debbugs.gnu.org; 1 Dec 2022 06:10:20 +0000 Received: from localhost ([127.0.0.1]:37560 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0cm3-0004vu-Oz for submit@debbugs.gnu.org; Thu, 01 Dec 2022 01:10:20 -0500 Received: from out2.migadu.com ([188.165.223.204]:28211) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0cm0-0004vo-OU for 59662@debbugs.gnu.org; Thu, 01 Dec 2022 01:10:17 -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=1669875015; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eLLNHgSsg7TNj3LSmK5WuA+5dUVzArW6HRkJv9zmgrA=; b=NbEVQlF43BV9LP565SxnDo7ta65P6QNrQqMSbfvz/n146Wk/tzTmYonRB1tpOMCMll0wd2 X6YsfG0tF9+/ZrRJurhYHITdUf+yKCUHmCQF5Ty9/XJPp99ZeouT2unvwuRlROfDZFaBrX GzhFTbj25B8I/fLQB7N5WHCEnqPU/4FTweIflJtqsIaVWP5CPvve7OiKsYMIQAfIeZR4ZF f2GwsEUovI1Sn4mX2sbA8pvn6zwEwDght+WKZyRKPIsHSwp2daXmvOr/pqtGqWrpb1n0dA MrCZq3aoFW1PTU6xQlbHYQMUVsQwHSPT0O4x/Bc/Kf4F/4uBt+GoqI1gnqypDQ== From: Theodor Thornhill To: Yuan Fu Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> Date: Thu, 01 Dec 2022 07:10:14 +0100 Message-ID: <87y1rrzmbd.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: Eli Zaretskii , 59662@debbugs.gnu.org, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Yuan Fu writes: > Theodor Thornhill writes: > >> Eli Zaretskii writes: >> >>>> Cc: eliz@gnu.org, casouri@gmail.org >>>> From: Theodor Thornhill >>>> Date: Mon, 28 Nov 2022 20:32:01 +0100 [...] >> >>>> An alternative could be to add a 'treesit-mode-map' where we can >>>> auto-enable such constructs. >>> >>> I think this is less desirable. >>> >>> Yuan, WDYT? >>> > I see, so you want to implement C-c C-q in c-mode. But why don=E2=80=99t = we > make treesit--indent-defun a command and bind it in C-c C-q in major mode= s?=20 > Filling is not indent IMO. If you fill a list in elisp code it wraps long= lines=20 > instead of indent (IIRC). > > Also, this is really not tree-sitter specific, it doesn=E2=80=99t require= any > tree-sitter feature to accomplish: indent-defun only needs mark-defun > and indent-region, both are supported by practically any major mode. > > Normally this kind of thing goes into lisp.el, alongside commands like > fill-paragraph, indent-region, beginning-of-defun, etc, and claim a > global keybinding. But maybe we only want it to live under C-c prefix, > in that case I guess we can bind it in prog-mode-map, under C-c C-q? > Yeah, that's smart - thanks for the tip! Perhaps adding it to prog-mode is a bit premature, but maybe Eli has an opinion here? My guess is that a change in lisp.el is a little too big for the release branch? So we could let this live in treesit.el if it's too big a change? Theo From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 01 02:13:58 2022 Received: (at 59662) by debbugs.gnu.org; 1 Dec 2022 07:13:58 +0000 Received: from localhost ([127.0.0.1]:37859 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0dle-0005ZG-GZ for submit@debbugs.gnu.org; Thu, 01 Dec 2022 02:13:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55846) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0dlc-0005ZA-TV for 59662@debbugs.gnu.org; Thu, 01 Dec 2022 02:13:57 -0500 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 1p0dlX-0006jl-1u; Thu, 01 Dec 2022 02:13:51 -0500 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=6EsMdEAGO98/wTESGSPhY4XeUN9llOe0u4+iJjfS8Pg=; b=gLT5MnUeDI2mjwrb1iMH YHpFBn27nlDIJFOZc8Jvqvn5+LsGjPn+5AUzvTEDjTO7W1aYK8w42v8aQRRVLWnEqpyj3DQ7HM5yI 7CClCsLMdAb0BFj9AKGjybXUCcxtxOL+kMDNd572MY+DrrwKmbZ0RLV6aOtvwsAYOE4kEDHuvvK19 Kocye94otaK3kuO/TP0XAqJVXiVutha8fFRHVvoFOCEDiFgDSVJLT9VIdHKSb8Zj0NOU77ibvjnnO acE6G6880zsfNf5A4CkjiMqahME5ZkAlo8LuqaeOaqnPu3XiUoKCZkhMZYI9LggMni3tZCKkRg3NI VX5kJW2ee5r/KA==; 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 1p0dlV-0005co-Mc; Thu, 01 Dec 2022 02:13:50 -0500 Date: Thu, 01 Dec 2022 09:13:22 +0200 Message-Id: <83o7sniokt.fsf@gnu.org> From: Eli Zaretskii To: Yuan Fu In-Reply-To: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> (message from Yuan Fu on Wed, 30 Nov 2022 15:23:17 -0800) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: 59662@debbugs.gnu.org, theo@thornhill.no, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Yuan Fu > Date: Wed, 30 Nov 2022 15:23:17 -0800 > Cc: Eli Zaretskii , > 59662@debbugs.gnu.org, > casouri@gmail.org > > Also, this is really not tree-sitter specific, it doesn’t require any > tree-sitter feature to accomplish: indent-defun only needs mark-defun > and indent-region, both are supported by practically any major mode. > > Normally this kind of thing goes into lisp.el, alongside commands like > fill-paragraph, indent-region, beginning-of-defun, etc, and claim a > global keybinding. But maybe we only want it to live under C-c prefix, > in that case I guess we can bind it in prog-mode-map, under C-c C-q? > > I’m thinking something like > > (defun prog-mode-indent-defun () > (interactive) > (mark-defun) > (indent-region (region-beginning) (region-end))) > > (defvar prog-mode-map > (... > (define-key map (kbd "C-c C-q") #'prog-mode-indent-defun))) SGTM, but I'd begin by doing this only in c-ts-mode.el (and maybe also in csharp-ts-mode). After all, until now this functionality and the "C-c C-q" binding was only in CC Mode. (My original question about this was due to lack of enthusiasm to add the "C Indent" node of the Emacs manual text that explains this feature is only available in CC Mode, not in the tree-sitter based C/C++ modes.) From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 01 02:20:07 2022 Received: (at 59662) by debbugs.gnu.org; 1 Dec 2022 07:20:08 +0000 Received: from localhost ([127.0.0.1]:37892 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0drb-0005dM-Ks for submit@debbugs.gnu.org; Thu, 01 Dec 2022 02:20:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51450) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0drY-0005cr-S1 for 59662@debbugs.gnu.org; Thu, 01 Dec 2022 02:20:05 -0500 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 1p0drR-0003iF-Vt; Thu, 01 Dec 2022 02:19:58 -0500 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=qApxnwQPIHfS6aZpL2wPkfYY9tcPNTYn6r6CYw033WY=; b=bYnFdMrUUt1pRV7t6reC b5qEDkbNw8xkpi68r/x0yXpXUQmwxqjzB99QG/xkXsuqkgT8wD5ld/2i4L8Na60wI33AZL+ou+Vok 1ckJ0exHXY1is04utZ47LJ9oL35YU8IZPA3k2MyIqXQPKHdmFrvGn26VyiipnnsLUgoeNvaOpjAjq F7x1xJnqa8g7WxpoUMpS78y6tnOoDLDA4TlFQ+WX1ARewmYaFyqr7KABGlwqCVqV3RYfHBUNCaSAK uC5Rgo7ONmvLyDDxRcg0zqXIPuADSeefp9e3r4mzzYyttlHJp4H9zlpD2W+YOjNeHACRC5mpsV/XM V+74kZtQa32CHg==; 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 1p0drQ-000659-FF; Thu, 01 Dec 2022 02:19:56 -0500 Date: Thu, 01 Dec 2022 09:19:28 +0200 Message-Id: <83lenrioan.fsf@gnu.org> From: Eli Zaretskii To: Yuan Fu In-Reply-To: <0EC6C5BE-321E-43E9-92F9-D829DBBD36A7@gmail.com> (message from Yuan Fu on Wed, 30 Nov 2022 17:07:48 -0800) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <0EC6C5BE-321E-43E9-92F9-D829DBBD36A7@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: 59662@debbugs.gnu.org, theo@thornhill.no, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Yuan Fu > Date: Wed, 30 Nov 2022 17:07:48 -0800 > Cc: Eli Zaretskii , > 59662@debbugs.gnu.org, > casouri@gmail.org > > > I’m thinking something like > > > > (defun prog-mode-indent-defun () > > (interactive) > > (mark-defun) > > (indent-region (region-beginning) (region-end))) > > > > (defvar prog-mode-map > > (... > > (define-key map (kbd "C-c C-q") #'prog-mode-indent-defun))) > > Tho I’d prefer we bind it in major mode maps first. Adding anything to prog-mode-map should go through emacs-devel (and I don’t know if we want to add any bindings to prog-mode-map), of course. I agree and think we should first do this only in C and related modes. From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 01 02:23:24 2022 Received: (at 59662) by debbugs.gnu.org; 1 Dec 2022 07:23:24 +0000 Received: from localhost ([127.0.0.1]:37917 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0dul-0005gP-UJ for submit@debbugs.gnu.org; Thu, 01 Dec 2022 02:23:24 -0500 Received: from out2.migadu.com ([188.165.223.204]:45531) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0dui-0005gI-Dd for 59662@debbugs.gnu.org; Thu, 01 Dec 2022 02:23:22 -0500 Date: Thu, 01 Dec 2022 08:22:45 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1669879398; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eLX5E59kd2S6XTQP5BqtoW2hfl/PZRh+eCdvJEe4YIg=; b=EC5BYysd5V7dViBAwdZtdigtFx0HqUm+KVntspwOq7a6LOYSefGYtidDsIRW2yyJyP8tmU EbKYrTPBCQ7dvB4o/+yXni2x0pVrzbjt4L3bmlgJhBmZQzjgOCUXeTPHDLTFZv8RCfxnhy mb4eIZpZrhcesbJl8Cp2cbrz9QqbSH2FMh6yCZpTinmk8EMmLa/IHfbc6EJ6Ia88vgWKuY Zkx0yVx51kOKTKDwLXYzRl1wjUQjKkPYip74fp0R4pGMsep//G2l86oNvnJZRyaDSYkjrp cuUJ/pNrVVxWehPqgg528ko2qaCNTm9FF4K7qvFyLxDyoFXrYdAQw3GYr0z8eA== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Theodor Thornhill To: Eli Zaretskii , Yuan Fu Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <83o7sniokt.fsf@gnu.org> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> Message-ID: <56840149-5EB9-4C22-841F-45F410BFC885@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: 59662@debbugs.gnu.org, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 1 December 2022 08:13:22 CET, Eli Zaretskii wrote: >> From: Yuan Fu >> Date: Wed, 30 Nov 2022 15:23:17 -0800 >> Cc: Eli Zaretskii , >> 59662@debbugs=2Egnu=2Eorg, >> casouri@gmail=2Eorg >>=20 >> Also, this is really not tree-sitter specific, it doesn=E2=80=99t requi= re any >> tree-sitter feature to accomplish: indent-defun only needs mark-defun >> and indent-region, both are supported by practically any major mode=2E >>=20 >> Normally this kind of thing goes into lisp=2Eel, alongside commands lik= e >> fill-paragraph, indent-region, beginning-of-defun, etc, and claim a >> global keybinding=2E But maybe we only want it to live under C-c prefix= , >> in that case I guess we can bind it in prog-mode-map, under C-c C-q? >>=20 >> I=E2=80=99m thinking something like >>=20 >> (defun prog-mode-indent-defun () >> (interactive) >> (mark-defun) >> (indent-region (region-beginning) (region-end))) >>=20 >> (defvar prog-mode-map >> (=2E=2E=2E >> (define-key map (kbd "C-c C-q") #'prog-mode-indent-defun))) > >SGTM, but I'd begin by doing this only in c-ts-mode=2Eel (and maybe also = in >csharp-ts-mode)=2E After all, until now this functionality and the "C-c = C-q" >binding was only in CC Mode=2E (My original question about this was due = to >lack of enthusiasm to add the "C Indent" node of the Emacs manual text th= at >explains this feature is only available in CC Mode, not in the tree-sitte= r >based C/C++ modes=2E) So you'd like the change in lisp=2Eel, but bound only in the modes you men= tion, or have something similar to the original patch in treesit, but still= bound only to the same modes? Theo From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 01 02:48:50 2022 Received: (at 59662) by debbugs.gnu.org; 1 Dec 2022 07:48:50 +0000 Received: from localhost ([127.0.0.1]:38035 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0eJN-0005xc-QQ for submit@debbugs.gnu.org; Thu, 01 Dec 2022 02:48:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51558) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0eJM-0005xW-IL for 59662@debbugs.gnu.org; Thu, 01 Dec 2022 02:48:49 -0500 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 1p0eJH-0006VQ-B9; Thu, 01 Dec 2022 02:48:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=ed9lmLTsg56CcMbhky2aR2KKC49mQuIIrKLR6vlIKa0=; b=SSt6djGg3YSP 3YevTHj3EX37Pg1SNXPBFicsISFob0K5zgGVC05pZQVB1X721NJc33CtGNMlEDJ8UkHyZxy2H9EFo zwbDzM3a/ucXL0IHWH6vAT4EyQtl4mEtXBG9ua2BADHBqxVKZeBx8TKuBxuhkpsVc4v4cmhE9Xmqa JI51eLYLBVgDHWmMvmWscS7fqlMeWasj7lzJIKdzgT4OI+O1uI+mJ0TsUHVVv8loA3q7jkHauWnfU JED6ydwhCtFpjtwqUNAZ0D+S2hqvTztrcQ/BEQAm3SPGT1FJf6TPzccXyCJDhICQquruI+2rxt60r RY0WjFuoYHrQMZEZjzAeOQ==; 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 1p0eJG-0005yn-J2; Thu, 01 Dec 2022 02:48:43 -0500 Date: Thu, 01 Dec 2022 09:48:15 +0200 Message-Id: <83edtjimyo.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: <56840149-5EB9-4C22-841F-45F410BFC885@thornhill.no> (message from Theodor Thornhill on Thu, 01 Dec 2022 08:22:45 +0100) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <56840149-5EB9-4C22-841F-45F410BFC885@thornhill.no> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: casouri@gmail.com, 59662@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Thu, 01 Dec 2022 08:22:45 +0100 > From: Theodor Thornhill > CC: 59662@debbugs.gnu.org, casouri@gmail.org > > >SGTM, but I'd begin by doing this only in c-ts-mode.el (and maybe also in > >csharp-ts-mode). After all, until now this functionality and the "C-c C-q" > >binding was only in CC Mode. (My original question about this was due to > >lack of enthusiasm to add the "C Indent" node of the Emacs manual text that > >explains this feature is only available in CC Mode, not in the tree-sitter > >based C/C++ modes.) > > So you'd like the change in lisp.el, but bound only in the modes you mention, or have something similar to the original patch in treesit, but still bound only to the same modes? Why in lisp.el? we are talking about a feature of C-like languages. The current binding of "C-c C-q" is in cc-cmds.el, so what I had in mind is to have its counterpart in c-ts-mode.el. From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 01 03:14:02 2022 Received: (at 59662) by debbugs.gnu.org; 1 Dec 2022 08:14:02 +0000 Received: from localhost ([127.0.0.1]:38187 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0ehm-0006Dd-AO for submit@debbugs.gnu.org; Thu, 01 Dec 2022 03:14:02 -0500 Received: from out2.migadu.com ([188.165.223.204]:41533) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0ehk-0006DB-Fn for 59662@debbugs.gnu.org; Thu, 01 Dec 2022 03:14:00 -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=1669882439; 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=w5Dm0SWe7AObPnjZoheaOZZ8aKV/GttD1cpWdt3sBvE=; b=2VhMeRkD8/ap1fJpvJmBgsSDVvp0SSjsnH49iZS0ZAaet5acOKufq18IbKy+whSDpdHIXe 5Oy3L+5i0Iz9HMQHdcBWJ5+bL4eoujb+qOHD0JrczquaIEOJ/2sR0XuGhpDTn1FcxI+mZ3 eUfbIYvXGhlMsxJ/SNa9OuRju144GpJEl/iLdy7thOFZMeBSXiHyAUNMZGMpG74qPuEkHI GXjH4AcPNEhuI8cl6yRXpNuBPG6cG1eCcCh4qrL9qx2R857S1HMXLqgyk7g0ngC7qlYRlO xMe7JilazJoC0GVnaXvqZn6lsQHvLkMWBIpz8awz6HYoLJ4d6aA7DaPV2fYtmg== From: Theodor Thornhill To: Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <83edtjimyo.fsf@gnu.org> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <56840149-5EB9-4C22-841F-45F410BFC885@thornhill.no> <83edtjimyo.fsf@gnu.org> Date: Thu, 01 Dec 2022 09:13:58 +0100 Message-ID: <87sfhzzgl5.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: casouri@gmail.com, 59662@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> Date: Thu, 01 Dec 2022 08:22:45 +0100 >> From: Theodor Thornhill >> CC: 59662@debbugs.gnu.org, casouri@gmail.org >> >> >SGTM, but I'd begin by doing this only in c-ts-mode.el (and maybe also in >> >csharp-ts-mode). After all, until now this functionality and the "C-c C-q" >> >binding was only in CC Mode. (My original question about this was due to >> >lack of enthusiasm to add the "C Indent" node of the Emacs manual text that >> >explains this feature is only available in CC Mode, not in the tree-sitter >> >based C/C++ modes.) >> >> So you'd like the change in lisp.el, but bound only in the modes you >> mention, or have something similar to the original patch in treesit, >> but still bound only to the same modes? > > Why in lisp.el? we are talking about a feature of C-like languages. The > current binding of "C-c C-q" is in cc-cmds.el, so what I had in mind is to > have its counterpart in c-ts-mode.el. Only because Yuan mentioned it. I will make that change. Theo From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 01 08:25:29 2022 Received: (at control) by debbugs.gnu.org; 1 Dec 2022 13:25:29 +0000 Received: from localhost ([127.0.0.1]:39693 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0jZA-00030j-PV for submit@debbugs.gnu.org; Thu, 01 Dec 2022 08:25:28 -0500 Received: from mail-oa1-f53.google.com ([209.85.160.53]:33691) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0jZ8-00030Q-Rm for control@debbugs.gnu.org; Thu, 01 Dec 2022 08:25:27 -0500 Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-13bd2aea61bso2184243fac.0 for ; Thu, 01 Dec 2022 05:25:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=QzZv0snGQCpy+UMOnq3kBJ/yWP//HJFRvBPqzisTc+s=; b=oupA+QSyAXyX2kBqOx95Rnt3TEGGC8FAkVSMHkwgrF8zejqAstZ+VThnCsJbMUK2rF 8A2OHVAEzvN9beyyMPrHGzVMyXWeyev7DEWM/8/2CzaWOfoXJfph1AUOzPa2kVNVvMN1 jE6EH8X3qiWgH6tD0NO2guIySM1buUiO3WkuKrhXmw4sPQ5vIGKxrP/YB07mmcxrA9wx ECp+RrIEDNQTWf6vRxcwth4V9TbewMS3Aaj2uxZhmwOEJOv5oqfQ/EOArQfBjhNcTtkm olEWaswbOL+pf1TVsWR+5b/PdT+Yr1n00ZiwAh0+GPVvM7605gac0sKaq/Zn0TWRhYBC v8MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=QzZv0snGQCpy+UMOnq3kBJ/yWP//HJFRvBPqzisTc+s=; b=4uxrssvlUJF7PM95rvANmrg1r3q3dw3BH3uf/KRLiYeO/k8Px7BmKgaxvId2dhoCv2 yV4fEfDIG2xMDk2uyOwaPYRirUa1phzXRvBNaMDivogmvGaGPNATZMunf+ZRMZZQABbX DYmyuRPqWnmxD/AhGiCLIXi5pH2s1yBi6NWSmaA06HN8awpdqZPbx08SyMJFG3fZKP+g BiubOIYthWDiGNP7DHsAfPJj5J+8k27uKjEQ4984n7q/75BSwjH6BKpWvy3cPSjn3Urs F/VFs6ub4v5/uquR86Sil1mpZzKgbWoYPsn87KzpUS5jHsn3CQGKi9Z9WHR4LoLeph+v 49fQ== X-Gm-Message-State: ANoB5pl80KX2w+KUBS5rVtbTMm4teT5rMaZVOfOE0VHS7em7+0agZXQW wGfmwfPqS/aV/WIm5kLBpg5T2gEXz2gh88VQutLq8BIv X-Google-Smtp-Source: AA0mqf7EYBvY+iVrfShpKQZlVoeUp5TP3eIohSW4iuSnFSZWdVQJKdQ8Uov8Eamkc9AARGHelm8SvsH5i5QNeTIr8/I= X-Received: by 2002:a05:6870:9e9a:b0:144:307b:c8d1 with SMTP id pu26-20020a0568709e9a00b00144307bc8d1mr143975oab.92.1669901121460; Thu, 01 Dec 2022 05:25:21 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Thu, 1 Dec 2022 05:25:21 -0800 From: Stefan Kangas X-Hashcash: 1:20:221201:control@debbugs.gnu.org::vBoZcQ6TXizNkkAf:Xsy MIME-Version: 1.0 Date: Thu, 1 Dec 2022 05:25:21 -0800 Message-ID: Subject: control message for bug #59662 To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) severity 59662 wishlist quit From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 02 10:06:53 2022 Received: (at 59662) by debbugs.gnu.org; 2 Dec 2022 15:06:53 +0000 Received: from localhost ([127.0.0.1]:47236 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p17cq-0006RM-RH for submit@debbugs.gnu.org; Fri, 02 Dec 2022 10:06:53 -0500 Received: from out2.migadu.com ([188.165.223.204]:49703) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p17co-0006RG-7O for 59662@debbugs.gnu.org; Fri, 02 Dec 2022 10:06:51 -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=1669993607; 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=YnYuyhIQPEyfAWqw7kLGFmb/MUtCZnrBaQxlhiQWaxI=; b=bKUJT/0bkBqo9a+r6lkNe7H3fQQnXnUSSUGXdXy2mn5S7PqibGlhGoOmN+35d6r3+GSykq V2K34RfVomx0s3JIv7WqgTKPTS33DdCnervA0bgnBhJ/U3kthdQxuQKkadRlmR3mWTzpl3 dscDiIz+IcgexM8m8YwBGbKfUJa0OYGrOwiU84TVsOb8EvgW354ne8tDpkuXWLl1ccQrqY 6x1Svg9+mH1qmmH5UcrOcHXxfy807ojOqk8p2JH5vtnyRVQAyc9JznRpqkXGEzqJ3gUNtp WxsHAH7MqAm6A/SqLZEGEk/Q8bCQMxawHlzzpDbeCem8BmC+wkoCkOkf+/PROw== From: Theodor Thornhill To: Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <83edtjimyo.fsf@gnu.org> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <56840149-5EB9-4C22-841F-45F410BFC885@thornhill.no> <83edtjimyo.fsf@gnu.org> Date: Fri, 02 Dec 2022 16:06:46 +0100 Message-ID: <875yet975l.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: casouri@gmail.com, 59662@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> Date: Thu, 01 Dec 2022 08:22:45 +0100 >> From: Theodor Thornhill >> CC: 59662@debbugs.gnu.org, casouri@gmail.org >> >> >SGTM, but I'd begin by doing this only in c-ts-mode.el (and maybe also in >> >csharp-ts-mode). After all, until now this functionality and the "C-c C-q" >> >binding was only in CC Mode. (My original question about this was due to >> >lack of enthusiasm to add the "C Indent" node of the Emacs manual text that >> >explains this feature is only available in CC Mode, not in the tree-sitter >> >based C/C++ modes.) >> >> So you'd like the change in lisp.el, but bound only in the modes you mention, or have something similar to the original patch in treesit, but still bound only to the same modes? > > Why in lisp.el? we are talking about a feature of C-like languages. The > current binding of "C-c C-q" is in cc-cmds.el, so what I had in mind is to > have its counterpart in c-ts-mode.el. Something like this? Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-c-ts-mode-indent-defun.patch >From 26a8780950017a911bac7290366da05e0e35f13f Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Fri, 2 Dec 2022 16:05:35 +0100 Subject: [PATCH] Add c-ts-mode--indent-defun Add in this function to mimic 'c-indent-defun' * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-defun): New function. (c-ts-mode-map): New mode map that uses said function. --- lisp/progmodes/c-ts-mode.el | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index fcabb5beac..3171600901 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -518,9 +518,25 @@ c-ts-mode--end-of-defun (if (looking-at "\\s<\\|\n") (forward-line 1))))) +(defun c-ts-mode--indent-defun () + "Indent the current top-level declaration syntactically. + +`treesit-defun-type-regexp' defines what constructs to indent." + (interactive) + (save-excursion + (mark-defun) + (indent-region (region-beginning) (region-end)))) + +(defvar-keymap c-ts-mode-map + :doc "Keymap for the C language with tree-sitter" + :parent prog-mode-map + "C-c C-q" #'c-ts-mode--indent-defun) + ;;;###autoload (define-derived-mode c-ts-base-mode prog-mode "C" - "Major mode for editing C, powered by tree-sitter." + "Major mode for editing C, powered by tree-sitter. + +\\{c-ts-mode-map}" :syntax-table c-ts-mode--syntax-table ;; Navigation. -- 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 02 10:45:53 2022 Received: (at 59662) by debbugs.gnu.org; 2 Dec 2022 15:45:53 +0000 Received: from localhost ([127.0.0.1]:47405 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p18Eb-0006ma-Is for submit@debbugs.gnu.org; Fri, 02 Dec 2022 10:45:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41842) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p18EY-0006mU-EJ for 59662@debbugs.gnu.org; Fri, 02 Dec 2022 10:45:52 -0500 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 1p18ES-0006L5-Tw; Fri, 02 Dec 2022 10:45:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=hbzwm+xft4SmbYtjuM7xLDIxxZr2aTWUNMgXmG+Qvl0=; b=NvKOsttYmAMy pwPz0qD772cvhnZXC7osud1BREfZop188up32r1wA5If3zothJ97kvvPJTEMPy6YYAQ4uScnFOEDd VQcogcPydJm5MwQwveEACcXZMreWrLvXd6HJ8opdNIRyRB6uL0Lzb1Kkx7xNkvDg7gSY9SpLIBxeN JA6WGUvhBi5qfAFY4CgpPrgFuxE/kboLmLWWBJQ0aEYbLZXezW4ysJhn7WNLLJ3naSvoFZgo1JqbM 4SHwrVhv01rO1CUlVFVfhrr29f/VwjDBeMc8pR00E4E6cKEKoAL2va92KpSFUzETeMUBS390ddoK5 SQFZPGxU9cBMXkRkGv2hqQ==; 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 1p18ER-0006rR-Ix; Fri, 02 Dec 2022 10:45:44 -0500 Date: Fri, 02 Dec 2022 17:45:17 +0200 Message-Id: <834judg67m.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: <875yet975l.fsf@thornhill.no> (message from Theodor Thornhill on Fri, 02 Dec 2022 16:06:46 +0100) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <56840149-5EB9-4C22-841F-45F410BFC885@thornhill.no> <83edtjimyo.fsf@gnu.org> <875yet975l.fsf@thornhill.no> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: casouri@gmail.com, 59662@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Theodor Thornhill > Cc: casouri@gmail.com, 59662@debbugs.gnu.org > Date: Fri, 02 Dec 2022 16:06:46 +0100 > > > Why in lisp.el? we are talking about a feature of C-like languages. The > > current binding of "C-c C-q" is in cc-cmds.el, so what I had in mind is to > > have its counterpart in c-ts-mode.el. > > Something like this? Yes, thanks. But a command should not have "--" in its name, since every command is by definition a public function, not an internal one. From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 02 13:32:41 2022 Received: (at 59662) by debbugs.gnu.org; 2 Dec 2022 18:32:41 +0000 Received: from localhost ([127.0.0.1]:48158 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1Aq1-0008Kp-0r for submit@debbugs.gnu.org; Fri, 02 Dec 2022 13:32:41 -0500 Received: from out-216.mta0.migadu.com ([91.218.175.216]:65456) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1Apy-0008Kj-1W for 59662@debbugs.gnu.org; Fri, 02 Dec 2022 13:32:39 -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=1670005956; 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=uvotQeaTTen6wnJiWwpVQsl3jPcSWQNOQTsHmg7i4GQ=; b=y7Bc5BiKW451glfTCVeK1G2p9wp7wQ2XtS0LPbLjCBweT1HBp34n+0LRcGoK7Xdyv3QpYK OqFwZKHW4sPCJvAwP+LR/oiO+Hw1GtO5kQzzmWR/799r7JYgntT+xe4AJF0nD1q+AtuVcN s7Mm50DelWCO1SMFyJhgTkrDTK0CLhDfgMHx2YDxrWV5rmr9zYj47UAyyyKGgghQzMrbud 6Yw3vFcvXf48Yv/Tkq8qN+o9x4WnYFyrR8/xpP8wJ9ETeVz5CST7zTJaOJpn5Sy0QtCJXQ 0r7sibZznBfHhZTddvcgfvcU4+QBNxOlV7FGHacbNrfmVsENUUmT35dW7jv+Qg== From: Theodor Thornhill To: Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <834judg67m.fsf@gnu.org> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <56840149-5EB9-4C22-841F-45F410BFC885@thornhill.no> <83edtjimyo.fsf@gnu.org> <875yet975l.fsf@thornhill.no> <834judg67m.fsf@gnu.org> Date: Fri, 02 Dec 2022 19:32:33 +0100 Message-ID: <87359x8xmm.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: casouri@gmail.com, 59662@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Theodor Thornhill >> Cc: casouri@gmail.com, 59662@debbugs.gnu.org >> Date: Fri, 02 Dec 2022 16:06:46 +0100 >> >> > Why in lisp.el? we are talking about a feature of C-like languages. The >> > current binding of "C-c C-q" is in cc-cmds.el, so what I had in mind is to >> > have its counterpart in c-ts-mode.el. >> >> Something like this? > > Yes, thanks. > > But a command should not have "--" in its name, since every command is by > definition a public function, not an internal one. That makes sense. I was in doubt about that, but decided to go the (wrong) direction. Updated in latest patch. However - mark-defun signals an error on some constructs because of number-or-marker error: Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil) treesit-end-of-defun() c-ts-mode--end-of-defun() end-of-defun() mark-defun(1 nil) mark-defun(1 23209) funcall-interactively(mark-defun 1 23209) call-interactively(mark-defun record nil) command-execute(mark-defun record) execute-extended-command(nil "mark-defun" nil) funcall-interactively(execute-extended-command nil "mark-defun" nil) call-interactively(execute-extended-command nil nil) command-execute(execute-extended-command) I'll file a separate bug report for this one, if that's ok? Yuan, are you ok with this patch? Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-c-ts-mode-indent-defun.patch >From b7c82cf11404a68338aa495cbd4424f45e1f8405 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Fri, 2 Dec 2022 16:05:35 +0100 Subject: [PATCH] Add c-ts-mode-indent-defun Add in this function to mimic 'c-indent-defun' * lisp/progmodes/c-ts-mode.el (c-ts-mode-indent-defun): New function. (c-ts-mode-map): New mode map that uses said function. --- lisp/progmodes/c-ts-mode.el | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index fcabb5beac..36d67c5701 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -518,9 +518,25 @@ c-ts-mode--end-of-defun (if (looking-at "\\s<\\|\n") (forward-line 1))))) +(defun c-ts-mode-indent-defun () + "Indent the current top-level declaration syntactically. + +`treesit-defun-type-regexp' defines what constructs to indent." + (interactive) + (save-excursion + (mark-defun) + (indent-region (region-beginning) (region-end)))) + +(defvar-keymap c-ts-mode-map + :doc "Keymap for the C language with tree-sitter" + :parent prog-mode-map + "C-c C-q" #'c-ts-mode-indent-defun) + ;;;###autoload (define-derived-mode c-ts-base-mode prog-mode "C" - "Major mode for editing C, powered by tree-sitter." + "Major mode for editing C, powered by tree-sitter. + +\\{c-ts-mode-map}" :syntax-table c-ts-mode--syntax-table ;; Navigation. -- 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 02 13:52:52 2022 Received: (at 59662) by debbugs.gnu.org; 2 Dec 2022 18:52:52 +0000 Received: from localhost ([127.0.0.1]:48243 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1B9X-0008Tv-Rt for submit@debbugs.gnu.org; Fri, 02 Dec 2022 13:52:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50738) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1B9S-0008Tl-82 for 59662@debbugs.gnu.org; Fri, 02 Dec 2022 13:52:49 -0500 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 1p1B9M-0005Y3-HZ; Fri, 02 Dec 2022 13:52:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=IQomG/UGfFBnG1ZnqvOoA4/149ajcdoXLY0JawAI8Bc=; b=PAseKP89ciy8 05JgzOGU1f6uQinlnPN6vmlHbtZ5XzM9IUlPFxCfZkTMeOxj4zJ4hVsvwbikDEWNlbmizhqUYTYsU vtUd3ITwsb+ofSfRcspR+JcRvwCsZU45kGSj+12akp/uvwxkw2UvbtZtIX4+CP8NVIH7ACbeVAwPb ym66Mn5TMypH85Q/XlYu9dOM+ZQD8saTXY/+zNepH3mJ4xg9fyMdfbPI3X6feYGWQiUkTne5+Rwdg +wmWbzgPHsgD+rSfwn7J6JR3g+s4boY2Q6edF61W8xX6Lg+Qoxfu+161o+LHaeBfVpZjnH05T+ZZd 0DYXZxO02YaaSdfiangFOA==; 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 1p1B9L-0006FB-Tz; Fri, 02 Dec 2022 13:52:40 -0500 Date: Fri, 02 Dec 2022 20:52:17 +0200 Message-Id: <83zgc5eizi.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: <87359x8xmm.fsf@thornhill.no> (message from Theodor Thornhill on Fri, 02 Dec 2022 19:32:33 +0100) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <56840149-5EB9-4C22-841F-45F410BFC885@thornhill.no> <83edtjimyo.fsf@gnu.org> <875yet975l.fsf@thornhill.no> <834judg67m.fsf@gnu.org> <87359x8xmm.fsf@thornhill.no> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: casouri@gmail.com, 59662@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Theodor Thornhill > Cc: casouri@gmail.com, 59662@debbugs.gnu.org > Date: Fri, 02 Dec 2022 19:32:33 +0100 > > However - mark-defun signals an error on some constructs because of > number-or-marker error: > > Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil) > treesit-end-of-defun() > c-ts-mode--end-of-defun() > end-of-defun() > mark-defun(1 nil) > mark-defun(1 23209) > funcall-interactively(mark-defun 1 23209) > call-interactively(mark-defun record nil) > command-execute(mark-defun record) > execute-extended-command(nil "mark-defun" nil) > funcall-interactively(execute-extended-command nil "mark-defun" nil) > call-interactively(execute-extended-command nil nil) > command-execute(execute-extended-command) > > I'll file a separate bug report for this one, if that's ok? Yes, please. From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 02 14:02:53 2022 Received: (at submit) by debbugs.gnu.org; 2 Dec 2022 19:02:53 +0000 Received: from localhost ([127.0.0.1]:48293 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1BJF-000095-HO for submit@debbugs.gnu.org; Fri, 02 Dec 2022 14:02:53 -0500 Received: from lists.gnu.org ([209.51.188.17]:52102) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1BJD-00008z-36 for submit@debbugs.gnu.org; Fri, 02 Dec 2022 14:02:52 -0500 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 1p1BJC-0001Lz-My for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 14:02:50 -0500 Received: from sonic308-18.consmr.mail.ir2.yahoo.com ([77.238.178.146]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p1BJA-0007E8-Gz for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 14:02:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1670007765; bh=lVIy6KSKNfJtN8HfQy4VcFwPa2gPv4H+eye6lryA7LU=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=NUWgMTOX6vJJkUznADmZ5Yk0ZaVCb4jjOJ7xk3X7sF9fNCZCx6qTEiD+2hCCoassdjVVuArfrtvD+7V/gAt2fFg23u09jNBm4LTIXelvrCoeENv+OGZzsehhTYVURqWlamMsFVKhix/hr02JoGlDZBuie1wYg7wSYRGvptDP8Cu2xZtedIrJ4a8MUaSGohsPTEmNGvZd16EkWMHtEAarnF8hFYqJcDRfW6RQq3ZnvatYON/OC8SXu6cbOPu2rjb1zRfP7pgji8pd89OAcI5vaU7JUF/U/R2FjMtJdben6w1Ge/8NNUsVKBHHF5urfuOikB3iBhzaUkd/HpDiJ3INPw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1670007765; bh=/bMZRYEl9pSnBbQalGuSRv0IjrCg6okk4UzAFgM5VAM=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=YlkVEUq6jq4WnGI9j28NT2s5vODEE8cBQRvL7XuYmfnSY5tNGi/sn2aU1wNdYHRQ2Clc46ZzSki6UPQqRQXiAQEiY9T77wpbts/FHS9q9BsYqRge/SPX2mmWZDGH64B1VKy5Xu/CksAVDO9oMfS8dQqe1VIyK+ADorQWU5NWkEnJVJ7UiHT6cexNHXqLNw+J/On1A44wiibgscSbquF6MdcF7YVXJwXJ8UbU1K5F0frzXFSswivtjyfR4TFKlEaC+YUj+PNE8JoaL/0IhW+x5Fmiqpm3p2uLQA5wLnSAALvZGTICEglMnh7D2J8vnGJFB14/n5llaPYQZF9DcfPdmQ== X-YMail-OSG: ItMJ1vgVM1n39PhZ7nQl9TYqwddWTpR0nso.9kDZJ_g3W4ju0nNNimCSbUJj.jO kMQWpXLivRM2jBXlPLSZaDbD5X6h5Z37onItaBjpJClLsFxWLNtCRSDLM5RbThIXCx.3fQzacRSp xKmAR4F8ClKHM2L3eufdjilnrmLQgH5_xj.yysDHJAGcxLNFuxvfMLGVa.OBllmfCgAnIVrY9R3S dw8lFfAhgE81pl3uX84Dk01cVVJs0o3F3444Cb7FZcPtJlVDCREZwneqIOtI16oWNRSluX8.YyAM 2b5oGGMXy4y1m_i8q.vjQ33EKSpEMi_pn7RAFPw.uXGTdzw0ubNvVq3qmaUShTV3KRpNqrlgOmKu h6.W_rxkT8iUmns5K94cUak2vO9J56uEeIpQ_HRJihA_N_F.7udtgP.p5DFBj.pWER9w6YlsMV9x Kao0Do_lBpfRXOcZohe.BTJpi.HcjZd8ppFLi7r9_2NHkeQoylXKzIyUUhIA1jxFIpeIOunTWHKc E1ZflFsh6mdRL7c1DsITIdHkqZe5Hs9CR.tKkZJX4KMdm9CTlcFZxxDaZa51eGekfbnIqqwIcIQh xsuX70G8diCaHSf9Q6psPJmjnI_sUPpX1CZ47YCMjXg9EDP8ctjdIHB5lWlBC4xjzJ64wzSpiQMN OIp3PfLmUnFKlqyWkAJFuG09J2EfNTuuabO3PeogCy0Xt4pnwCyWm5QwdZnhrrHbd5ohTk1TEny6 rwMY7XwsK7EaDDd9vbKrKqWt9zOlSA0Frr1RVexoNWnD5PfFn9ni4QY0k3mmsYbhC10o_p_U4q2V 5Gb_tVR7ZYRiy99mQWEFHgsdFzZqZQzqqa4HDBRhbV5CjsuoKzQWHQCWW7iPfVhShx2se8UnA7BD jkjNj9YW0MjbjrDJhrDLY3SmF9_3_gFOPbpLn6rZS6lugvnpxRFxWY4juC3H1xJGyJQ9lYxbtaNg AhLlMv0wWoR0D7EaWjFfMk4iQjrrqK6LMKUmig255WPuRATB8xRl6o2DsZNa0dYAGHz8bEwuFeu6 bDobv7UHKBXLHlSMZkDyVwPyYujhAkJl2rMB9ZrUf_0fELXuQfMFZVIksb7W.T15rnUftz_fKZqQ _Z9qlNMzuupsX3RZgiO5WiWYEffRC_efq7polrq9HQllLH.bbkjAI_fjVBOLpUrUppPdvLf.N5.Z Hkh2XUaEPlkN4GQWJjwFjCWwNqZAjcTGFj0tvX8d977iet32o8pqJDV5Xmslt3Xj2i5LoTCz4W4K BGBOc8oWu1_8zg0H50G89Wvt7s1EZqnowaHzRgAX_E6a6RbHcAFTIxLTT3VPzfop_9n8WDQIJJfz 2dAWCL3E1.jo.c5qYlouxP_T73oF57ns3e_efsHD7GBX2f2CvW0Cgd9D4NzDghgJBxk5Q04Oe3yW ZTT9d4NvvK30ZDSyabKAg1LOVzh50kp4v9aksTTzFqXi5dO64xaXGXHeI1L.MmFhbs2BScJbe3qZ R_ObG8SWiCnQmnCVvL8BI78qMAfRvGGW5WZL7.ZRwARyxRku1ICLLGXL2qo4sIG3X7rMIIooCb3Z beqDUTL6TgjUbDhD.zq7SLT5H7im0Cb1wA2MvmMkAAgsZDfC9ue2fUWDoOJp3VhTkT104gzPPItJ vwR1zJSntWKIzQMRkeFjT_H9QyhLRVU70iGg9j9kZCYC45jhsww.6.QIa5jtcAKW_iQxZ9W2LLc3 R.7UmDmWuy0uHizPK6UxMFs6fHiV2fxTMIq8W4OubGGXvjPz68PhJ4t_sGEo1cw5fKOKe9AAINL9 z8vgfldfFmvoo9OyDtDM9LzSONbuxnS96Gx0geNsIc_NDSuY7xUI7YeUDD9kbtuO4jQKADHCZVf6 hmrg1ztG8.C.DRXAiazfBGrIOpvEjN6ASPxvOyHyO9kZIRqn5_yqJc54PD_zE7bQ5M1EeAXlRoap 9_DGxzw1VoqmJa2Z0VEZA.QvP_3h5LKyoGcXvxpBnG9f0WTB1Bx6pudpiD5AyZXJshJ7PMRxXL_V xqaR806YbGnxaL2KDZL7GGWOHd3jpWaev0JBlzhn1R9x.YyF2b.ONT16ssLPua10T5zErgZv3XE9 V6HUzqttWHMFagpriF6SRhEgJ8AK8Uwh1sDxsLgG1sls0UBDzWaer7iyaCbtr68TtEBeecVtIAfM 85_N.AdV8YLDiFqsW5RoHFK9YhG4tlejTsGieo4yQgD9x01vhk5yOaoanm5pMX8vDHjw6OaAwvij .XUlvzrDuHHiuOfmH9Wrk3PxFD2cB6Eb23c.T X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.ir2.yahoo.com with HTTP; Fri, 2 Dec 2022 19:02:45 +0000 Received: by hermes--production-ir2-5795fc58c8-hz8w8 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 70aa7b8cf3c5fce4c26be47c3f3d989e; Fri, 02 Dec 2022 19:02:42 +0000 (UTC) From: =?utf-8?Q?Daniel_Mart=C3=ADn?= To: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <56840149-5EB9-4C22-841F-45F410BFC885@thornhill.no> <83edtjimyo.fsf@gnu.org> <875yet975l.fsf@thornhill.no> Date: Fri, 02 Dec 2022 20:02:41 +0100 In-Reply-To: <875yet975l.fsf@thornhill.no> (Theodor Thornhill via's message of "Fri, 02 Dec 2022 16:06:46 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (darwin) MIME-Version: 1.0 Content-Type: text/plain X-Mailer: WebService/1.1.20926 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Content-Length: 1737 Received-SPF: pass client-ip=77.238.178.146; envelope-from=mardani29@yahoo.es; helo=sonic308-18.consmr.mail.ir2.yahoo.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit Cc: Eli Zaretskii , 59662@debbugs.gnu.org, Theodor Thornhill , casouri@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" writes: >> >> Why in lisp.el? we are talking about a feature of C-like languages. The >> current binding of "C-c C-q" is in cc-cmds.el, so what I had in mind is to >> have its counterpart in c-ts-mode.el. > > Something like this? Thanks, some comments below: > > From 26a8780950017a911bac7290366da05e0e35f13f Mon Sep 17 00:00:00 2001 > From: Theodor Thornhill > Date: Fri, 2 Dec 2022 16:05:35 +0100 > Subject: [PATCH] Add c-ts-mode--indent-defun > > Add in this function to mimic 'c-indent-defun' > > * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-defun): New function. > (c-ts-mode-map): New mode map that uses said function. > --- > lisp/progmodes/c-ts-mode.el | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el > index fcabb5beac..3171600901 100644 > --- a/lisp/progmodes/c-ts-mode.el > +++ b/lisp/progmodes/c-ts-mode.el > @@ -518,9 +518,25 @@ c-ts-mode--end-of-defun > (if (looking-at "\\s<\\|\n") > (forward-line 1))))) > > +(defun c-ts-mode--indent-defun () This should be public: c-ts-mode-indent-defun > + "Indent the current top-level declaration syntactically. > + > +`treesit-defun-type-regexp' defines what constructs to indent." > + (interactive) (interactive "*") will handle read-only buffers a bit better. > + (save-excursion > + (mark-defun) > + (indent-region (region-beginning) (region-end)))) Nit: Once you call (mark-defun), you can call (indent-region (point) (mark)) which should be more efficient than calling (region-beginning) or (region-end). From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 02 14:53:24 2022 Received: (at 59662) by debbugs.gnu.org; 2 Dec 2022 19:53:24 +0000 Received: from localhost ([127.0.0.1]:48509 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1C68-0000c6-3J for submit@debbugs.gnu.org; Fri, 02 Dec 2022 14:53:24 -0500 Received: from mail-wm1-f45.google.com ([209.85.128.45]:56193) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1C65-0000bz-S8 for 59662@debbugs.gnu.org; Fri, 02 Dec 2022 14:53:23 -0500 Received: by mail-wm1-f45.google.com with SMTP id m19so4280870wms.5 for <59662@debbugs.gnu.org>; Fri, 02 Dec 2022 11:53:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=VGceqXageNAgDCo3kTR7Jr0wKxvHTnp++gYRAIvrBZM=; b=gZ7TPVcg7piPlSafXwwDW2CFkgvN+Ft5IV0WwzkBxl/+UJ3FmhXWeaOKTTcWsdpYey jZbVaf8uSuxXbeJs5iHfcievJXf2LDlEuVha+Aiixq87/aFu4b5gNmU+BiiOg/+cqdiY qpz7oqXN/xPt7fXmEw+WDoAN5ZQU0h3rttWYiK+L2/EK05ojkiTJeQJlIgzcoWjVt7qd VLJd433+NRxA4q2woNLrrTLpxYaBF1lfAuRFVFnn5zxs8Z9gpbfbKfuF+jltT8Pw+wOc ATF8f34Og6avmIHTBI+cqxaURlfCpPxq0TJX8PHUOPG2xZI0+DHIWOM0f1U1HYu/cczJ qQ8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VGceqXageNAgDCo3kTR7Jr0wKxvHTnp++gYRAIvrBZM=; b=OnuMGPTb625zVh8cZAQT2OVL3PJFH4RmzEHJvstCzJcjoUhE+ZuupMtrvoKRfXMKxT pvHiq4cvnHd/azQyb0g+2HOXqzQmXkx1gtMV6nltEUUPlgKaHuhiLdLz+6CTReGvuXB1 Z+6yT7y0+cQ9JrfCFwBkHTd4dCoM/UoJGTorlyYrlqssvrUv+2G/3sXeiODiEZ7p2xHQ QUbiizy8Qqt0rNW6MVvmCSfBAOK296ZFmPsDemxzTkJX1H7Vh8TmMHrBn7NdX2bAUTZW d++aSCfJxm2XZtTNvfnHROtU/xtoUKxTCfaWq1z1jA0vKNDiEuC6UV2pjhxThvvdcP7s 9rFw== X-Gm-Message-State: ANoB5pmk/toBRV7fbGa87vZfhenGy/hljfML16YddftMuofVU+h3TgWX 0iUc+e873s7Rik/lrxk7wlA= X-Google-Smtp-Source: AA0mqf5nDLhOgeiMNRVmYR2F9iLj7FqwxZ/HRaehL5sKskymxr68cPeTjU53emM7i1cKNwAtzwG8jQ== X-Received: by 2002:a1c:7501:0:b0:3cf:61a3:464e with SMTP id o1-20020a1c7501000000b003cf61a3464emr46493678wmc.111.1670010795634; Fri, 02 Dec 2022 11:53:15 -0800 (PST) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id i1-20020adfaac1000000b002238ea5750csm9645565wrc.72.2022.12.02.11.53.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 02 Dec 2022 11:53:15 -0800 (PST) Message-ID: Date: Fri, 2 Dec 2022 21:53:13 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US To: Eli Zaretskii , Yuan Fu References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> From: Dmitry Gutov In-Reply-To: <83o7sniokt.fsf@gnu.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: 59662@debbugs.gnu.org, theo@thornhill.no, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 01/12/2022 09:13, Eli Zaretskii wrote: > After all, until now this functionality and the "C-c C-q" > binding was only in CC Mode. There is also the 'M-q' binding in the popular paredit-mode. It runs paredit-reindent-defun. From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 02 15:02:07 2022 Received: (at 59662) by debbugs.gnu.org; 2 Dec 2022 20:02:07 +0000 Received: from localhost ([127.0.0.1]:48566 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1CEY-0000jF-PZ for submit@debbugs.gnu.org; Fri, 02 Dec 2022 15:02:06 -0500 Received: from mail-wm1-f47.google.com ([209.85.128.47]:51939) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1CEW-0000ij-TU for 59662@debbugs.gnu.org; Fri, 02 Dec 2022 15:02:06 -0500 Received: by mail-wm1-f47.google.com with SMTP id bg10so4304761wmb.1 for <59662@debbugs.gnu.org>; Fri, 02 Dec 2022 12:02:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=0XgjptlRthAP9tEr/Xh2UrI7vscVdaZuy1KYFgtrfYM=; b=hSUh1eJQTnQ4mX6HZbdUF+5D0PYQ2pUEdlVM2xA40KHfQu/INYfO+3dmw4wt7xCOdl RfkDRku3bajawucn2Y4w366xeW1nkRYV4d/u+TdALgSoS90bWYMUdksOTJ338+ATFFBY 8YBk8/nlUI1qieCwve1a7ErT3vqluyUX2Iis7nyDm0Pp0qsKy4TmQczsLpS873/nLZVi 90i3eDcFukl+NxVglPSTbeWsqXY0K0z2szP4N27fE+/mOpBZE0HZqwk3XDU/m5GYBMkS ryxVAFh/6RNxp1TcLbhSzWGcPCyCAX90+M3NBtu/vSsENTJfsQJwc761hQbfKUc8p2G+ 5Ydg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0XgjptlRthAP9tEr/Xh2UrI7vscVdaZuy1KYFgtrfYM=; b=OozWTt8j6DJnyK5yS/LG9sB6GJmSXOcg1W1l1pfuzlLOWwDXqNWwCwlmLUyikZ5Xje nDLM6PV4li/rJTrPUt88VrL4CVsVGfAnpknqSGY3CYWh/ERrn4AgnzeQiWAWuIRGcuot 53CSZic3iIDOEJdkOqu8t6HKcgdM2HekryHxDvczEA0VQ1ZBJWxHPEjT2M52JwPUZgaa hoOj/uLVGG64jxaT4FlaoXfE1oatZCeL/SId4MQ6Q7WPaVJvDEzTpo4VwFvCEDt0uTZx MiDWzrkaE/HioAyOH2MQNcYaQ7L7M6wSzV8gPwlAFKXxVcv5o4v43s8K46GUDh4qUWTf z3CQ== X-Gm-Message-State: ANoB5pkaKDfEhiTVLDVesMuy8y7TlSY5IYQD10Ezf1k+iqfjYc20K/qb UaFV+D4eb7ubxtP8qp4iRa4= X-Google-Smtp-Source: AA0mqf6jmBHfEQr2UAueWek/fOZmPmomoMgGqfr8Q0Qz2oLSlDXxwvBm+AJS1Ah2UcGXIZYkH/PVMQ== X-Received: by 2002:a1c:7401:0:b0:3cf:934b:b7ad with SMTP id p1-20020a1c7401000000b003cf934bb7admr40906791wmc.22.1670011318911; Fri, 02 Dec 2022 12:01:58 -0800 (PST) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id p17-20020a05600c359100b003c6b9749505sm13805235wmq.30.2022.12.02.12.01.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 02 Dec 2022 12:01:58 -0800 (PST) Message-ID: <51035d42-eacf-15e9-e7a4-cc4b09595789@yandex.ru> Date: Fri, 2 Dec 2022 22:01:55 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US From: Dmitry Gutov To: Eli Zaretskii , Yuan Fu References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: 59662@debbugs.gnu.org, theo@thornhill.no, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 02/12/2022 21:53, Dmitry Gutov wrote: > On 01/12/2022 09:13, Eli Zaretskii wrote: >> After all, until now this functionality and the "C-c C-q" >> binding was only in CC Mode. > > There is also the 'M-q' binding in the popular paredit-mode. > > It runs paredit-reindent-defun. That function runs fill-paragraph when in string or comment, and beginning-of-defun + indent-sexp otherwise. From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 02 15:09:13 2022 Received: (at 59662) by debbugs.gnu.org; 2 Dec 2022 20:09:13 +0000 Received: from localhost ([127.0.0.1]:48596 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1CLP-0000mI-K1 for submit@debbugs.gnu.org; Fri, 02 Dec 2022 15:09:13 -0500 Received: from out2.migadu.com ([188.165.223.204]:25869) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1CLC-0000lu-FF for 59662@debbugs.gnu.org; Fri, 02 Dec 2022 15:09:11 -0500 Date: Fri, 02 Dec 2022 21:07:25 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1670011735; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iaTUwMbG9icZpOSuvtl0TImxLu3qHXymq7KkHWyV4mQ=; b=Zd94ePv8VXvtQgzlGFf/IlPqSHe+LIspK9cK/OMpyzHK2SMvIKzu6/NEXU5jrdvNc+Gcfo 2onlCaOvz6olvA2sAGtNwu1goJR5DCQBcqGWZFosm/7dl/O6LyEJkBp0V0LJAtoE3N3ATj vkizhrK4oaSI1JtrE4TpmgJ0AO+Jrae9L1vNpqjIywIXEUPV8/0AYVBK02slTI0Mpj1kF7 dMBgSEGM5JApKlKmptErAR8bWGI2s4yDpLkuGZClQ30xds/Wl3H1ZmudVQlSsgf9x4n6b6 y0vAfagL3qWo6uQEIj0JB/sL5pihVro0d5L6KODf7S4X/DRHyYT3b9J4SiWotA== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Theodor Thornhill To: Dmitry Gutov , Eli Zaretskii , Yuan Fu Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> Message-ID: <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: 59662@debbugs.gnu.org, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 2 December 2022 20:53:13 CET, Dmitry Gutov wrote: >On 01/12/2022 09:13, Eli Zaretskii wrote: >> After all, until now this functionality and the "C-c C-q" >> binding was only in CC Mode=2E > >There is also the 'M-q' binding in the popular paredit-mode=2E > >It runs paredit-reindent-defun=2E Yeah=2E My first iteration was piggybacking on fill-paragraph-function to = get that binding, but I believe that was undesirable=2E From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 02 15:24:25 2022 Received: (at submit) by debbugs.gnu.org; 2 Dec 2022 20:24:25 +0000 Received: from localhost ([127.0.0.1]:48677 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1Ca8-0000uv-N1 for submit@debbugs.gnu.org; Fri, 02 Dec 2022 15:24:25 -0500 Received: from lists.gnu.org ([209.51.188.17]:32866) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1Ca6-0000up-EA for submit@debbugs.gnu.org; Fri, 02 Dec 2022 15:24:23 -0500 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 1p1Ca6-00057T-2U for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 15:24:22 -0500 Received: from out2.migadu.com ([2001:41d0:2:aacc::]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p1Ca3-00023O-HZ; Fri, 02 Dec 2022 15:24:21 -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=1670012656; 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=kMOeHX45rq0caDfHljenFi9lKVCFk5POLyBFwmpoJwY=; b=jRj+wpzS59q3JY29qe15lUgp4UqyFORw/zkh7O7wLTTPOOiySgAi6AHrYlKC9jlbMDKq12 FHh/WzQmVTngTJzpjYcfmuTgnRIji0GogFPjBK/PXuAPcCYBbzZC387SNqZrySFJvwDOfE rKlfnG7Aa55UxGqe/PmTHgx9ttt/HsFrR+Qmyv4vBUTiPCnQWLF0nZ+KxyiXs9k6xSQj7b MLAgOtFRrAPJjX4Tf4ayVjiDe2NcPj0nNWzZ6WKXh4WN42Q7SQPlRantU/7VpTdpEis0Qe drLz+JT/Qexrt6mjvWemci24dbm6wnjJH7PTxMhgKaI1wv0wJTVGbCkbUjYlBg== From: Theodor Thornhill To: Daniel =?utf-8?Q?Mart=C3=ADn?= , "Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors" Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <56840149-5EB9-4C22-841F-45F410BFC885@thornhill.no> <83edtjimyo.fsf@gnu.org> <875yet975l.fsf@thornhill.no> Date: Fri, 02 Dec 2022 21:24:13 +0100 Message-ID: <87y1rp7dw2.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:2:aacc::; envelope-from=theo@thornhill.no; helo=out2.migadu.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit Cc: Eli Zaretskii , 59662@debbugs.gnu.org, casouri@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Daniel Mart=C3=ADn writes: > Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife > of text editors" writes: > >>> >>> Why in lisp.el? we are talking about a feature of C-like languages. The >>> current binding of "C-c C-q" is in cc-cmds.el, so what I had in mind is= to >>> have its counterpart in c-ts-mode.el. >> >> Something like this? > > Thanks, some comments below: > Thanks for looking! >> >> From 26a8780950017a911bac7290366da05e0e35f13f Mon Sep 17 00:00:00 2001 >> From: Theodor Thornhill >> Date: Fri, 2 Dec 2022 16:05:35 +0100 >> Subject: [PATCH] Add c-ts-mode--indent-defun >> >> Add in this function to mimic 'c-indent-defun' >> >> * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-defun): New function. >> (c-ts-mode-map): New mode map that uses said function. >> --- >> lisp/progmodes/c-ts-mode.el | 18 +++++++++++++++++- >> 1 file changed, 17 insertions(+), 1 deletion(-) >> >> diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el >> index fcabb5beac..3171600901 100644 >> --- a/lisp/progmodes/c-ts-mode.el >> +++ b/lisp/progmodes/c-ts-mode.el >> @@ -518,9 +518,25 @@ c-ts-mode--end-of-defun >> (if (looking-at "\\s<\\|\n") >> (forward-line 1))))) >>=20=20 >> +(defun c-ts-mode--indent-defun () > > This should be public: c-ts-mode-indent-defun > Yeah. >> + "Indent the current top-level declaration syntactically. >> + >> +`treesit-defun-type-regexp' defines what constructs to indent." >> + (interactive) > > (interactive "*") will handle read-only buffers a bit better. > I was wondering about that, but I couldn't really find any situation that gave any difference. But I've added it now. >> + (save-excursion >> + (mark-defun) >> + (indent-region (region-beginning) (region-end)))) > > Nit: Once you call (mark-defun), you can call > > (indent-region (point) (mark)) > > which should be more efficient than calling (region-beginning) or > (region-end). Right - thanks. However, this makes me wonder - should we really be setting mark here? I see that c-indent-defun does not, and it feels weird that indenting adds to the mark ring. What do you think? My first patch used (indent-region (treesit-node-start node) (treesit-node-end node)) Which behaves similarly to c-indent-defun. See attached patch. Thanks, Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-c-ts-mode-indent-defun.patch >From 9c22569f7a98c9fd671664e0834bd079e8f20bd3 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Fri, 2 Dec 2022 16:05:35 +0100 Subject: [PATCH] Add c-ts-mode-indent-defun Add in this function to mimic 'c-indent-defun' * lisp/progmodes/c-ts-mode.el (c-ts-mode-indent-defun): New function. (c-ts-mode-map): New mode map that uses said function. --- lisp/progmodes/c-ts-mode.el | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index fcabb5beac..677ff07a2d 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -518,9 +518,25 @@ c-ts-mode--end-of-defun (if (looking-at "\\s<\\|\n") (forward-line 1))))) +(defun c-ts-mode-indent-defun () + "Indent the current top-level declaration syntactically. + +`treesit-defun-type-regexp' defines what constructs to indent." + (interactive "*") + (save-excursion + (mark-defun) + (indent-region (point) (mark)))) + +(defvar-keymap c-ts-mode-map + :doc "Keymap for the C language with tree-sitter" + :parent prog-mode-map + "C-c C-q" #'c-ts-mode-indent-defun) + ;;;###autoload (define-derived-mode c-ts-base-mode prog-mode "C" - "Major mode for editing C, powered by tree-sitter." + "Major mode for editing C, powered by tree-sitter. + +\\{c-ts-mode-map}" :syntax-table c-ts-mode--syntax-table ;; Navigation. -- 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 02 16:10:09 2022 Received: (at submit) by debbugs.gnu.org; 2 Dec 2022 21:10:09 +0000 Received: from localhost ([127.0.0.1]:48888 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1DIO-0001M3-PP for submit@debbugs.gnu.org; Fri, 02 Dec 2022 16:10:09 -0500 Received: from lists.gnu.org ([209.51.188.17]:50648) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1DIM-0001Ls-Bm for submit@debbugs.gnu.org; Fri, 02 Dec 2022 16:10:07 -0500 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 1p1DIM-00052J-4C for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 16:10:06 -0500 Received: from sonic309-25.consmr.mail.ir2.yahoo.com ([77.238.179.83]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p1DIJ-00089S-Vr for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 16:10:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1670015399; bh=DJglOBtneC8JBhV0a9lwof2RAnc8oeQAYmONvvRh6po=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=lZfK5ITWIapj9B8v0qZDmJ97eRxsKjDRLmOzdP4NZFXjEVOH3Qb8dAE73Am3sircx4tQ2IFdvuJMbzjRa6jZqxcLCPKTzjoDPF/twpFDkrQN+tFx45YjQX09L9u/tv6+/kIrv36oTUUFjLOqXhtboTelCQlA82aAd/Af1TNGZxgkIFEUeqsj8r+mudrL3KMPz7qUeL5/jUwkH+Kf6RLUUIJKKkQ3XyD2mOKK+IA41AC+sutm8MLxXTF4UVhyR8WeM3AhL5tv7wOHGawZ2sgMW8y1JsS3WQ4efwL2TOZX0/kqmNpkg1gmqG9MCFLgrs9MayDXYMfyJnvSfBDsFtoDNA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1670015399; bh=kkFFcyka8OQhN5shUkg/QjF+7MT7VmnnEEfWl9FjEu1=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=Jkp4t6ksE42QDd/s/kQkq87Gy6xNsjiVjif8q4H0wu3ikENIdWrBd/XMVKwLyoctybDhZJ3eOg1nLbKMb+r21F+yc+zqIGcJV1rgY9DpVOVbqniEEDHt9vnr7ORcNFXc3ZK1pLf0wVsU5T80/+W09LNar9jsuFQD2og1YyU2ayF2FWe+va3F0GrH4Qv6JXxpiro9Rl/SPVe1CxfiG43ti169yeD29jcLh2I01e185277vsLyFAppxsB0+kDFEqhNd/jVh+RbtJINCp4ef3mpN0LUXdCT0j9AT5/V9RSRMMr6HD5CFKEFqZyExAYD6eUag5zYe8Ry9hxKMftyq6Llpw== X-YMail-OSG: AYsug0wVM1lO8DPRs2APaiMH.E79zw2wNPyaNb1qtP0Qvzc..cC9anVgjqFy9m5 1iLDouKrKKp4dmbOOsIUHO5hog3wpT27vV6zl5yCYQq238CdFdRmyRFYS7LoORSfkue3yDgzTafu YS5Uh3gc7sGZnSog57MIUNff6.c8tMYdK6nN_nODvIy6jJnF27P8ONazQqFA0hCBKElxwRt2Xphy lecCL1gNVk8Muq.AQWVUiD7921_Icm_iNkjzQuASscIQkW.Mqq2Xhoj6chsWx4zmxyhve3OBm6L9 YZTvEAhZXAqnjzhqzjF0Ok9x4nVyEYRHvXfXZcjKzd2HRTTMh_PRONlgNmCMrAXuZ8N3A2gxg5Kv Rsj3UGQrqiQhl4Kp4bORc.I_Br9Q3G4pUPbghKqhAfNqBdUzF0pd8wSuIxBQ0M2YIvc6Pwt4Z6BO NuAfQcwr3SkMf0puyWkUgYyk.Jyyo27peV7TiWBVN.ZxwnvEEoU8BzrhHvhkzONEwphTtwjuJkAo Myf94jIN5219P7pJY5o6_LBWuWmpl0RBa36WB8m6kBaA4zMgPXnpdiD5oVdKplNOO3MeBD3.XCma ZTbqy25w4WCGNy6OPei9T1COzYAlbzCj2q9fJw4rd8.nAAHYVgtYAL86j17R9J241lDoMcjDGpfG WvD33DnBcOpxUFNKbq7qCbZSu4mxfy4.dLCGWLiyAGYzK0H36UPs9DxF5Lbxe6WjXm60obpIdJLw AKvajetef1uEppWUoiL27CqTMzWy7vuO0c_qiS3rngnuX37y7TtrkTA2Xn7oPfQwSM1GJN.pztqE V_7n1m9OMKw9Ky2hdgiPDUkORgn5PDEox9gBmxPtsyfX8my_he_UdMgLv8wZIgSTzPB7T3ve_vd6 rv1wIsBu8XZYn6Iv2tdY1jad6amVjB67VvDO6lEsuFMLmQjC7WELyu5KPRH1Cq_046nKkIHGB127 32UUc4d67kq5Dz1qwU7gEi9XJsd3rQUmOInWTcxKMUpn4Wl7QioCuKXrNIR3t2ebRQTsfZJvDB_i lIwFASdgTwikKDsda70iFaissEyzXlsnbCOoKgod8DtRNg9FRUJnGDnn.2uBVdEno6HsiZQ4gUu8 92OxM.trlKrSbhGTVhIz3DqDBct4ffvzWmH9cXcieUzP3JwMS3.K.D1LDHHmM3BAsaAiy11nxhF8 g5zTb1.R6JZK.Ha59awpCEhczSeCxbiuFcqsfPZ6bu.mr.gSMbl0iMvEBhAPdvbJcZHGCSs44PDV 1YANwOkFACOKCOaHmcgChxyTM0vkE2Ikk1W6qS4H2Zv_raWq_seNF6UkMixpPo8yBPhcJNg9N5qG GyrsJ0ulsUDgfZVySv.Bw3CpUu_IV1lBP7.aeSfE_IIE4Erme3j5JOWQRGwwQJIIfJeSZGsVIXeu 16xg2XXo8m2XISS.oJfrUhG9X9Az1yX2jAiTtMTGGh5RcIWXFV3hHQbth07ZanhmtzDJij0ogmhw sSpyVb4xjHgGY0ruXG1FCbUFbyVc5QFUBvjeM71cCF7zBpUOECpOjlps2DZKnSGE2K6dn_kqCAhj s8kCxGy7DNncRxX.WJOb0iwIpV5fP3DjSISAMaMsk0692e37lNBzTGM3mMGYYIhxnPqlzbye7adF g_.Jbgk3JJb_cJ2ae6Ocnc9U55pFmQh0wWiy5AH3w25WClADkypdDKfLfLO9m4al8Uz9OvRaesfJ EqDf4C0IpRYZpPRZC9ep5WCtll_WbBq2YyZJ5h4MPQl6YPdXd_5ZS_J6wy5Xd5gTUGnztLzloYEi T5Dgez6Bh5r7snoGZZyqEsFj0fnpe4TlkfaBLJk3u03cVS5BhKAYg2lIquRWeA8BrTTeLDmeo.sM 6YgF1agEoHl66JPHq1vvZ5elNJdphH5Hqd1fkRJ.lhQ9P1eY6hgZAyPs_PZvKRQWs0dHu0D41G80 9AXveJ5t5ASPPwnhGuIaxIE5MbLRREBzKp0emlOSaCOUSBtjWBmKIaTlkl8A1DAPioWyWIYwb1kn HT91AmNHHr.nAufe7j9WwOdroalDYkaaCkpQvGCvFIDk86A5AzR8pdLjGttVZBkxj9S.KJM7lv5. x_e00zhgdLrt6mKNMNFSmO6AVH0PyJ9e0RZJwouqv7CMo2RhIyJiPNXociPIHindXlNilFRbOz8J Srv2WegkrKtmX12wrTkuUQagRuqYNm26AtKUaAHf94VYUqokLPgvmV9_0lMKsiH5zEvtwsn8e2kv yb9dm9pFgwSTolL7fO45scr6CJQSR._oLjOJp_LpzUQ-- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic309.consmr.mail.ir2.yahoo.com with HTTP; Fri, 2 Dec 2022 21:09:59 +0000 Received: by hermes--production-ir2-5795fc58c8-hsgkz (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID e09e85b4492bae80807ffe45c45e28e6; Fri, 02 Dec 2022 21:09:57 +0000 (UTC) From: =?utf-8?Q?Daniel_Mart=C3=ADn?= To: Theodor Thornhill Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <56840149-5EB9-4C22-841F-45F410BFC885@thornhill.no> <83edtjimyo.fsf@gnu.org> <875yet975l.fsf@thornhill.no> <87y1rp7dw2.fsf@thornhill.no> Date: Fri, 02 Dec 2022 22:09:55 +0100 In-Reply-To: <87y1rp7dw2.fsf@thornhill.no> (Theodor Thornhill's message of "Fri, 02 Dec 2022 21:24:13 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (darwin) MIME-Version: 1.0 Content-Type: text/plain X-Mailer: WebService/1.1.20926 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Content-Length: 598 Received-SPF: pass client-ip=77.238.179.83; envelope-from=mardani29@yahoo.es; helo=sonic309-25.consmr.mail.ir2.yahoo.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit Cc: "Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors" , 59662@debbugs.gnu.org, casouri@gmail.com, Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) Theodor Thornhill writes: > Right - thanks. However, this makes me wonder - should we really be > setting mark here? I see that c-indent-defun does not, and it feels > weird that indenting adds to the mark ring. What do you think? My > first patch used > > (indent-region > (treesit-node-start node) > (treesit-node-end node)) > > Which behaves similarly to c-indent-defun. > > See attached patch. I don't have a strong opinion, but if we can indent without setting the mark, I think it'd be a cleaner command. Specially if c-indent-defun doesn't set the mark either. From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 02 16:20:06 2022 Received: (at submit) by debbugs.gnu.org; 2 Dec 2022 21:20:06 +0000 Received: from localhost ([127.0.0.1]:48951 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1DS1-0001S1-W9 for submit@debbugs.gnu.org; Fri, 02 Dec 2022 16:20:06 -0500 Received: from lists.gnu.org ([209.51.188.17]:38128) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1DS0-0001Rv-OJ for submit@debbugs.gnu.org; Fri, 02 Dec 2022 16:20:05 -0500 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 1p1DS0-00083u-JY for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 16:20:04 -0500 Received: from out-230.mta0.migadu.com ([2001:41d0:1004:224b::e6]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p1DRw-0004Kj-VY for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 16:20:04 -0500 Date: Fri, 02 Dec 2022 22:19:21 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1670015998; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ta57AbVJQWdvhC8nEh452/9Dkg57u6OltnmT03RA0Ng=; b=X7DTbHdplyAF4alKN1sbP04VF6cKhSFimpXAQT2jU0bjWckMUCBAq2XohiPse1hbb+OALU LyeUOCmehrpMTHtoCQ2/lGBqcdosnd5J1PhQ2zCA76oexJmJ2w3St9f/g83i1oanGqu+5E CoMrexBpM+2mUvsM+Tig5A5CtvOLTaxj8Rzcz2LvkFxEmSPY4a/FS2Tzn3VecSgANdItXv QeYXipec9OvU/alhvMU8u/BnKNauvzXYJaqb13+jNnLqc4+Evq93EjBkkvyUm9eohVx6zq xzLMBIY6hMFfK0aGNeI7gzVXrlZtpwH28H2tUXyDHNY4UUiA7MFRJWyBuLQe7Q== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Theodor Thornhill To: =?ISO-8859-1?Q?Daniel_Mart=EDn?= Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <56840149-5EB9-4C22-841F-45F410BFC885@thornhill.no> <83edtjimyo.fsf@gnu.org> <875yet975l.fsf@thornhill.no> <87y1rp7dw2.fsf@thornhill.no> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:1004:224b::e6; envelope-from=theo@thornhill.no; helo=out-230.mta0.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit Cc: "Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors" , 59662@debbugs.gnu.org, casouri@gmail.com, Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) On 2 December 2022 22:09:55 CET, "Daniel Mart=C3=ADn" wrote: >Theodor Thornhill writes: > >> Right - thanks=2E However, this makes me wonder - should we really be >> setting mark here? I see that c-indent-defun does not, and it feels >> weird that indenting adds to the mark ring=2E What do you think? My >> first patch used >> >> (indent-region >> (treesit-node-start node) >> (treesit-node-end node)) >> >> Which behaves similarly to c-indent-defun=2E >> >> See attached patch=2E > >I don't have a strong opinion, but if we can indent without setting the >mark, I think it'd be a cleaner command=2E Specially if c-indent-defun >doesn't set the mark either=2E Yeah, we don't need to set the mark=2E Thanks for the feedback :) Theo From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 02 17:28:03 2022 Received: (at 59662) by debbugs.gnu.org; 2 Dec 2022 22:28:03 +0000 Received: from localhost ([127.0.0.1]:49226 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1EVn-000246-HG for submit@debbugs.gnu.org; Fri, 02 Dec 2022 17:28:03 -0500 Received: from mail-wm1-f53.google.com ([209.85.128.53]:55252) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1EVk-00023j-Kj for 59662@debbugs.gnu.org; Fri, 02 Dec 2022 17:28:01 -0500 Received: by mail-wm1-f53.google.com with SMTP id t1so4513373wmi.4 for <59662@debbugs.gnu.org>; Fri, 02 Dec 2022 14:28:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=gdCqYlu9EbhcMre0eVB1ibPaSFUcsLehJYRtKEsx6gE=; b=iqmIb8XuvgB8wQXeWkwAXcJuVgWlrAvAmCr0wPFdRDE/7tDLeVrrIorWyvbiMQwyRg +PZwpHzYF0dTb19QN6E22cjJjNjI6gC5mh05qLmfpDIKyQ0icGJ3aYbMsZojVDnwGqZI MNdFYQ2cDmkChMTrKiEisIgUlsALq3KfsBxz6U7Oj8ggWGAVJssmGQ4amSYtCqVuxwe4 e/pCO02VCtSVQdzDSKnKqu8DOPSFvyFTd37fc6Zwm22VqRLnyGOwcBfubBr95ZcUjwke GZbNJ49e5N8pFFiTD4pSwVx52aSXtdynQBKcXwM8dGvwliPhJTuiuSPPA5RrKDCXmSoD o+5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gdCqYlu9EbhcMre0eVB1ibPaSFUcsLehJYRtKEsx6gE=; b=cRE0rZ6oegY3qPWXs0oerbkVOrqvb8LcaURS5vVJ9u6Or27UIZG7u/YU0tJvLqod+6 Kbs410qg+mbhTIP3+8cYXSKFeUJIAYgXob5pfGJy7L0zJ1jg2FuuEsR00CbE1/l9yhZc hAJAW7+0g29shj++0m+yA2wEXX4AIe1Z2yqpIbkD0clYoJTI+Qdy1yfcSJKnSeMHixRK r8j8M1a1V6jxahco9JzjT/D+r3gk169ka2JS71D4j/Bl1HnRvpR3f1+/a64WzOPQrVsg bbnaKWTbctxMtNck5MaDiBfZYaKNT9ccu7THkfpk8mHFjy5Zw+mz71rOs+g93x0ZeT/+ pcdQ== X-Gm-Message-State: ANoB5pkJ2yla1ujGOl5Bv3YmqlpejWqf/181KzYqtKx5p7mT9ssIHVkh 5mWMvH87vZocTjet9rPiqCM= X-Google-Smtp-Source: AA0mqf451kmbwmq5TeKS996nTJpGH9O8XgIGZl/IB/T/CIHZ11GCGZ0P1RY85GL0wJ9CcRS6A0JeBw== X-Received: by 2002:a05:600c:1da2:b0:3cf:147d:ad9a with SMTP id p34-20020a05600c1da200b003cf147dad9amr40988636wms.33.1670020074607; Fri, 02 Dec 2022 14:27:54 -0800 (PST) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id t17-20020a05600c199100b003c7087f6c9asm14417225wmq.32.2022.12.02.14.27.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 02 Dec 2022 14:27:53 -0800 (PST) Message-ID: Date: Sat, 3 Dec 2022 00:27:51 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US To: Theodor Thornhill , Eli Zaretskii , Yuan Fu References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> From: Dmitry Gutov In-Reply-To: <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: 59662@debbugs.gnu.org, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 02/12/2022 22:07, Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > > On 2 December 2022 20:53:13 CET, Dmitry Gutov wrote: >> On 01/12/2022 09:13, Eli Zaretskii wrote: >>> After all, until now this functionality and the "C-c C-q" >>> binding was only in CC Mode. >> There is also the 'M-q' binding in the popular paredit-mode. >> >> It runs paredit-reindent-defun. > Yeah. My first iteration was piggybacking on fill-paragraph-function to get that binding, but I believe that was undesirable. IME it's quite handy to have in modes where there is separation between (rigid) code and strings/comments. Not sure if that's all of prog-mode descendants, or if there will be exceptions. From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 03 01:48:28 2022 Received: (at 59662) by debbugs.gnu.org; 3 Dec 2022 06:48:28 +0000 Received: from localhost ([127.0.0.1]:51283 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1MK3-0005YA-Sh for submit@debbugs.gnu.org; Sat, 03 Dec 2022 01:48:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47538) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1MK1-0005Xz-TP for 59662@debbugs.gnu.org; Sat, 03 Dec 2022 01:48:26 -0500 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 1p1MJw-0002gH-5G; Sat, 03 Dec 2022 01:48:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=rnT+/TTSVZTMtnuwIBqmTR95NvZCk9ABt1CvoVKoCD4=; b=FmsYDbdSPpTm IjPLTKsulVWqgc4y/cyq6SDVJRyhyze2gJGbCfld3NQpW1wCH2mBPr1+iTqIA75h3QZNsbw8h4EDE OFqiLg3++oaC+CFgIZ8ZiT9N1D7+HGCs1MmSNt5YYVn2NsqsWek8qD8n1GSP8becpPWff/Q0tpe+b i28873MohH29l3b4/sGdQ9rxAPnR8ANbIVPgFpabWotWZzl+Ssk2cM0oNfp2zcOhIYJeUsav52PVi ohvdTg1bS7sx7mVm+kqGt1HMlu9/EKuCur8/rVFIxNpnNfcMkz8WeySqVkHWs57zb4REX5P7FWgUg EHhgGZfRtIW3nRhiNnpq5Q==; 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 1p1MJv-000293-Bg; Sat, 03 Dec 2022 01:48:19 -0500 Date: Sat, 03 Dec 2022 08:47:57 +0200 Message-Id: <83r0xhdluq.fsf@gnu.org> From: Eli Zaretskii To: Dmitry Gutov In-Reply-To: (message from Dmitry Gutov on Sat, 3 Dec 2022 00:27:51 +0200) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: casouri@gmail.com, 59662@debbugs.gnu.org, theo@thornhill.no, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Sat, 3 Dec 2022 00:27:51 +0200 > Cc: 59662@debbugs.gnu.org, casouri@gmail.org > From: Dmitry Gutov > > On 02/12/2022 22:07, Theodor Thornhill via Bug reports for GNU Emacs, > the Swiss army knife of text editors wrote: > > > > On 2 December 2022 20:53:13 CET, Dmitry Gutov wrote: > >> On 01/12/2022 09:13, Eli Zaretskii wrote: > >>> After all, until now this functionality and the "C-c C-q" > >>> binding was only in CC Mode. > >> There is also the 'M-q' binding in the popular paredit-mode. > >> > >> It runs paredit-reindent-defun. > > Yeah. My first iteration was piggybacking on fill-paragraph-function to get that binding, but I believe that was undesirable. > > IME it's quite handy to have in modes where there is separation between > (rigid) code and strings/comments. > > Not sure if that's all of prog-mode descendants, or if there will be > exceptions. I'm okay with making "C-c C-q" work in more modes than just C-related ones, but please do that on master, not on the release branch. As for M-q, it should be bound to a fill-SOMETHING command, not to a indent-SOMETHING command. So from my POV paredit-mode should be fixed to use some other sequence for paredit-reindent-defun, perhaps even "C-c C-q", but that is IMO an unrelated issue. And if you wanted to suggest that an indent-defun command in c-ts-mode be bound to M-q, then I'm very much against that: M-q already has a useful command bound to it in CC Mode, and should do something similar in c-ts-mode; I believe we are discussing that in bug#59763. From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 03 10:59:16 2022 Received: (at 59662) by debbugs.gnu.org; 3 Dec 2022 15:59:16 +0000 Received: from localhost ([127.0.0.1]:52024 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1Uv5-0004ef-Vs for submit@debbugs.gnu.org; Sat, 03 Dec 2022 10:59:16 -0500 Received: from mail-wr1-f50.google.com ([209.85.221.50]:41825) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1Uv3-0004eZ-B9 for 59662@debbugs.gnu.org; Sat, 03 Dec 2022 10:59:13 -0500 Received: by mail-wr1-f50.google.com with SMTP id q7so12337011wrr.8 for <59662@debbugs.gnu.org>; Sat, 03 Dec 2022 07:59:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=Sykb2Ll/hvYP13v0XT7S+L9Y+WVd3Mc2pxmZIT0mQQU=; b=NYc0jjk1msT1PgpTs0+37jyrnatkOzedTgPCKHLi+n3u1mmqO26XEquxjNutmSSPGz 8ijH6NYEqmHPPvJCZI6NDWNb9w/+3cWK4ZKrTURRnT+Ao7gCFQ1YhF7mP2xQ5B7fzZgf SJCD98nDMbwMzjmm9bDm388lbB51f1x4zSsaEfLMezE980ctekv94lrm/VJrsqYHIx7h 8F3YGn9DCRzr4Hk9sSFev+PI5AHO9IyNoce8YQ3GhGdlMYcrsIZHK+3v+y6s3IKO5ple HF93CeSppr3X+/PSHHCSBU2x3lp7tFUaQLIPf1T3c1T6UgliUyQAEIJPSpN/dTSTwHlE oRFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Sykb2Ll/hvYP13v0XT7S+L9Y+WVd3Mc2pxmZIT0mQQU=; b=kwvI3qxYC2+K+f9aZxBftwgb/SxcObIO58piugWRswKiYzt93Bt2aZGv+Uk7hVzGel knNOyiyOJqzEgMfocurZMMZ5lCFUbat54WeQk2JWkqsPYt4mXO7GK9puhJkGwkNIMsRo vqrd6qzBZxb2suFrOD9vZJFzuPiMQuVhpw3j7q7320FavBu2eiczEi2/HARov65D0GEp LBgVLE3I53Tc7/1ESj+LJVev/6FwvKJN+VQU1K193KheUNbvRcBkaxRDmLywzt8RPb/J uyKaI9ME4FMnILV0vS9kWBbc9bgd4PyR1TKF48FIRGsTwL1GJuw04y+dXpv2u9T2CRWX Ey9g== X-Gm-Message-State: ANoB5pms8O3px9vajNsA2uEDqMsfxLzk3GYF6TefXPLvhaJ0jBILjTTd Fw2sBRDWFrpgMJuUPxj/uAg= X-Google-Smtp-Source: AA0mqf7JKSqbQQFysyNwqwbB2jJ1B+N+fOKmzDugt1gTTtgleAryykU84UjEzsiGmwCu88A22O7k9w== X-Received: by 2002:a5d:4344:0:b0:22e:3430:475d with SMTP id u4-20020a5d4344000000b0022e3430475dmr47164636wrr.65.1670083147313; Sat, 03 Dec 2022 07:59:07 -0800 (PST) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id o37-20020a05600c512500b003cf5ec79bf9sm13745079wms.40.2022.12.03.07.59.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 03 Dec 2022 07:59:06 -0800 (PST) Message-ID: <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> Date: Sat, 3 Dec 2022 17:59:04 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US To: Eli Zaretskii References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> From: Dmitry Gutov In-Reply-To: <83r0xhdluq.fsf@gnu.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: casouri@gmail.com, 59662@debbugs.gnu.org, theo@thornhill.no, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 03/12/2022 08:47, Eli Zaretskii wrote: >> Date: Sat, 3 Dec 2022 00:27:51 +0200 >> Cc: 59662@debbugs.gnu.org, casouri@gmail.org >> From: Dmitry Gutov >> >> On 02/12/2022 22:07, Theodor Thornhill via Bug reports for GNU Emacs, >> the Swiss army knife of text editors wrote: >>> >>> On 2 December 2022 20:53:13 CET, Dmitry Gutov wrote: >>>> On 01/12/2022 09:13, Eli Zaretskii wrote: >>>>> After all, until now this functionality and the "C-c C-q" >>>>> binding was only in CC Mode. >>>> There is also the 'M-q' binding in the popular paredit-mode. >>>> >>>> It runs paredit-reindent-defun. >>> Yeah. My first iteration was piggybacking on fill-paragraph-function to get that binding, but I believe that was undesirable. >> >> IME it's quite handy to have in modes where there is separation between >> (rigid) code and strings/comments. >> >> Not sure if that's all of prog-mode descendants, or if there will be >> exceptions. > > I'm okay with making "C-c C-q" work in more modes than just C-related ones, > but please do that on master, not on the release branch. > > As for M-q, it should be bound to a fill-SOMETHING command, not to a > indent-SOMETHING command. So from my POV paredit-mode should be fixed to > use some other sequence for paredit-reindent-defun, perhaps even "C-c C-q", > but that is IMO an unrelated issue. > > And if you wanted to suggest that an indent-defun command in c-ts-mode be > bound to M-q, then I'm very much against that: M-q already has a useful > command bound to it in CC Mode, and should do something similar in > c-ts-mode; I believe we are discussing that in bug#59763. Both c-fill-paragraph and the proposed ts-c-fill-paragraph perform fill-region when inside a string or comment. Otherwise, do nothing. paredit-reindent-defun, like I described, does all that too. But when outside strings and comments, it reindents the current defun. AFAICT, these behaviors are quite compatible. But paredit's binding seems to be useful in more contexts. From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 03 12:55:25 2022 Received: (at 59662) by debbugs.gnu.org; 3 Dec 2022 17:55:26 +0000 Received: from localhost ([127.0.0.1]:52501 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1WjV-0005gH-C1 for submit@debbugs.gnu.org; Sat, 03 Dec 2022 12:55:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54604) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1WjT-0005g9-RF for 59662@debbugs.gnu.org; Sat, 03 Dec 2022 12:55:24 -0500 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 1p1WjM-0005Wq-Uu; Sat, 03 Dec 2022 12:55:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=M6deO1GTLtUuUVaC6woRDMOn4U802yDYVLe163kk1ME=; b=PqSOkCLZMK/k 6aEyvIUR4hPdJJqNh72V0Fn+nD7QILaPHXE1+nZtmnyzQbVU1UXxjz57vDMYjGqBk4dGuBMGmfMIF Qu8zMBT+a5OEl+VKOzZ8JBg9E17ddSQiHOFHxLHKgvkBV8goh9mjeIF+rFCKz3H8oJSYrWlaHJkwK ZAPRgo8TdEtCCLz+Pl7UkbpaaWALX2Sh4/b+mCGKpvGH/bdWTgzI9jL/Bbg07uubs1BYstYLg5YNg FYUCZ3DYYqoBI83G04j4yzYqWr60KTuSuFZYSbc8bmgJB4TJY/LEi2PWi6tC9Uo0vXh0xW3AAQMf+ wri1v8ZVvuFSdr7XcLEsMQ==; 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 1p1WjM-0004za-CF; Sat, 03 Dec 2022 12:55:16 -0500 Date: Sat, 03 Dec 2022 19:54:55 +0200 Message-Id: <83wn78cqz4.fsf@gnu.org> From: Eli Zaretskii To: Dmitry Gutov In-Reply-To: <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> (message from Dmitry Gutov on Sat, 3 Dec 2022 17:59:04 +0200) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: casouri@gmail.com, 59662@debbugs.gnu.org, theo@thornhill.no, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Sat, 3 Dec 2022 17:59:04 +0200 > Cc: theo@thornhill.no, casouri@gmail.com, 59662@debbugs.gnu.org, > casouri@gmail.org > From: Dmitry Gutov > > > As for M-q, it should be bound to a fill-SOMETHING command, not to a > > indent-SOMETHING command. So from my POV paredit-mode should be fixed to > > use some other sequence for paredit-reindent-defun, perhaps even "C-c C-q", > > but that is IMO an unrelated issue. > > > > And if you wanted to suggest that an indent-defun command in c-ts-mode be > > bound to M-q, then I'm very much against that: M-q already has a useful > > command bound to it in CC Mode, and should do something similar in > > c-ts-mode; I believe we are discussing that in bug#59763. > > Both c-fill-paragraph and the proposed ts-c-fill-paragraph perform > fill-region when inside a string or comment. Otherwise, do nothing. Yes. > paredit-reindent-defun, like I described, does all that too. But when > outside strings and comments, it reindents the current defun. So maybe paredit-reindent-defun doesn't need any fixes, but using it as a role model for the C-like languages is not TRT, since in C these are two separate commands with two different key bindings. > AFAICT, these behaviors are quite compatible. But paredit's binding > seems to be useful in more contexts. I'm fine with trying something like that on master, to see whether users like this conflation, but not on the release branch. From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 04 07:33:58 2022 Received: (at submit) by debbugs.gnu.org; 4 Dec 2022 12:33:58 +0000 Received: from localhost ([127.0.0.1]:57328 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1oBx-0007QK-Vp for submit@debbugs.gnu.org; Sun, 04 Dec 2022 07:33:58 -0500 Received: from lists.gnu.org ([209.51.188.17]:59856) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1oBu-0007QE-EV for submit@debbugs.gnu.org; Sun, 04 Dec 2022 07:33:55 -0500 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 1p1oBq-0005py-5w for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 07:33:50 -0500 Received: from out2.migadu.com ([188.165.223.204]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p1oBo-00038V-1i; Sun, 04 Dec 2022 07:33:49 -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=1670157217; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8Y2KcLM72joUzalOY734G4HTv314B5zeO52/6q+X1fI=; b=f8QsyuUrpMzN8yV/ohHSIaNQxwj8JKBulg1duYivwQtTMYXO1mHEB+j7xrD4OhIzAIIDHG JPksUEM0U8Uyq9H75oY5zr+SnfvvD5BTVT9X8wCl7CQbDb2eRy4+HxlS944khFf641FStT Bx7WwAOfyMShh44PZ1rRlPZUeu6eTIk2vaFhi97B8nawSKJMMDaxS6XDCVJ1f9EuD6sO8W 5Ss+Fe+f04SU6V83CJSNVW+RedGLtWFLY3OIYR/AeuM8NDpujlAClf9kYEANOECneFfQhT J9ZfgG0vBVll+2r8gwIlI2MZvreWXEshYh4S0BFd66Jzp4GKLV7+OyPVDSRpfQ== From: Theodor Thornhill To: Daniel =?utf-8?Q?Mart=C3=ADn?= Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <56840149-5EB9-4C22-841F-45F410BFC885@thornhill.no> <83edtjimyo.fsf@gnu.org> <875yet975l.fsf@thornhill.no> <87y1rp7dw2.fsf@thornhill.no> Date: Sun, 04 Dec 2022 13:33:35 +0100 Message-ID: <87o7sjcpr4.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=188.165.223.204; envelope-from=theo@thornhill.no; helo=out2.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit Cc: "Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors" , 59662@debbugs.gnu.org, casouri@gmail.com, Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) Theodor Thornhill writes: > On 2 December 2022 22:09:55 CET, "Daniel Mart=C3=ADn" wrote: >>Theodor Thornhill writes: >> >>> Right - thanks. However, this makes me wonder - should we really be >>> setting mark here? I see that c-indent-defun does not, and it feels >>> weird that indenting adds to the mark ring. What do you think? My >>> first patch used >>> >>> (indent-region >>> (treesit-node-start node) >>> (treesit-node-end node)) >>> >>> Which behaves similarly to c-indent-defun. >>> >>> See attached patch. >> >>I don't have a strong opinion, but if we can indent without setting the >>mark, I think it'd be a cleaner command. Specially if c-indent-defun >>doesn't set the mark either. > > Yeah, we don't need to set the mark. Thanks for the feedback :) > Theo Eli, do you have any opinion on this matter? Should we implement this function without using marks? That will make the function a smidge bigger, but would not mess up the mark-ring. I think that's desirable, at least. Theo From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 04 07:40:41 2022 Received: (at submit) by debbugs.gnu.org; 4 Dec 2022 12:40:41 +0000 Received: from localhost ([127.0.0.1]:57371 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1oIS-0007Uv-NE for submit@debbugs.gnu.org; Sun, 04 Dec 2022 07:40:41 -0500 Received: from lists.gnu.org ([209.51.188.17]:33402) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1oIP-0007Up-OM for submit@debbugs.gnu.org; Sun, 04 Dec 2022 07:40:38 -0500 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 1p1oIO-00008x-Ta for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 07:40:37 -0500 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 1p1oIO-00066E-Hw; Sun, 04 Dec 2022 07:40:36 -0500 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=5N2jd/7sgLi07jMKZDkVhXdPO9c12vdbk113hirm7pQ=; b=MxGrY//9eNoi4vfkS3UZ xst85TTNuavlweI7LlZ/zIOG9DPus1lVgvrxraHs2FQ7mYNMce/zdGfmAoFkZythX/OtLHWdXHK+O Oit+O9/ZMiL0kLc6VL8mfzlEveWC4z5p9Z67BMOul0+A6V0Is2pkhbZXeIXj9GZ1rgGpmf64ZrFBG MRHmy62DOaY0knKRi+GBR+/N2f/D6XWbSWzQ6wAGrNgqiFxc4idf1+Ns07eMq1trC452OA+rm1Gxy g3b+86LlkAxtMqGcXdjCojlGUWvmmczazvHrGJjVxT0nvKtC2bs6u6EQ+PKO48gWZ3QyTggM/q4hs v7A+O6qRTZx9DQ==; 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 1p1oIN-00064u-WE; Sun, 04 Dec 2022 07:40:36 -0500 Date: Sun, 04 Dec 2022 14:40:17 +0200 Message-Id: <83359vbavi.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: <87o7sjcpr4.fsf@thornhill.no> (message from Theodor Thornhill on Sun, 04 Dec 2022 13:33:35 +0100) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <56840149-5EB9-4C22-841F-45F410BFC885@thornhill.no> <83edtjimyo.fsf@gnu.org> <875yet975l.fsf@thornhill.no> <87y1rp7dw2.fsf@thornhill.no> <87o7sjcpr4.fsf@thornhill.no> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit Cc: bug-gnu-emacs@gnu.org, 59662@debbugs.gnu.org, casouri@gmail.com, mardani29@yahoo.es X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Theodor Thornhill > Cc: "Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife > of text editors" , Eli Zaretskii , > casouri@gmail.com, 59662@debbugs.gnu.org > Date: Sun, 04 Dec 2022 13:33:35 +0100 > > Theodor Thornhill writes: > > > On 2 December 2022 22:09:55 CET, "Daniel Martín" wrote: > >>Theodor Thornhill writes: > >> > >>> Right - thanks. However, this makes me wonder - should we really be > >>> setting mark here? I see that c-indent-defun does not, and it feels > >>> weird that indenting adds to the mark ring. What do you think? My > >>> first patch used > >>> > >>> (indent-region > >>> (treesit-node-start node) > >>> (treesit-node-end node)) > >>> > >>> Which behaves similarly to c-indent-defun. > >>> > >>> See attached patch. > >> > >>I don't have a strong opinion, but if we can indent without setting the > >>mark, I think it'd be a cleaner command. Specially if c-indent-defun > >>doesn't set the mark either. > > > > Yeah, we don't need to set the mark. Thanks for the feedback :) > > Theo > > Eli, do you have any opinion on this matter? Should we implement this > function without using marks? That will make the function a smidge > bigger, but would not mess up the mark-ring. I think that's desirable, > at least. IMO, it is better not to set the mark, indeed. From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 07 04:31:25 2022 Received: (at submit) by debbugs.gnu.org; 7 Dec 2022 09:31:25 +0000 Received: from localhost ([127.0.0.1]:48816 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2qlw-0001Tj-VB for submit@debbugs.gnu.org; Wed, 07 Dec 2022 04:31:25 -0500 Received: from lists.gnu.org ([209.51.188.17]:51750) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2qlt-0001Tc-0Q for submit@debbugs.gnu.org; Wed, 07 Dec 2022 04:31:21 -0500 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 1p2qls-0007XV-RA for bug-gnu-emacs@gnu.org; Wed, 07 Dec 2022 04:31:20 -0500 Received: from out-233.mta0.migadu.com ([2001:41d0:1004:224b::e9]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p2qlq-000753-8q for bug-gnu-emacs@gnu.org; Wed, 07 Dec 2022 04:31: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=1670405475; 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=kp0W5L+/5GKMJUYpjk4zpiNaosZUwSHlr5CwSI5nOu8=; b=GqplYhc2G4OT49o5wv6XgU8wxK0c13if2rDvWrXjQpAVtjvVik9v9kr/vbp9MKmeh93x6B 9u5zY6A0IZkJ981Yh70R02AcWZYAtVtSkjVglO7g5lc3vxihce1glkO4Bv9CEc6LknBO5q f961MXwWY8z3rNgX5g9IMxtI9upNijR9XHbH/ND7uOBE1PspiAp+KT0Z4/Eq0mVxkNDQyb Xj7GqLt7kLp4ZfytHC3hkTAlgJeZx/qbIT9PY3R/y7iJCBUSdFJvwTQmRgMizkiF8ehuls SstNNt+6uYrc8nR/Izzoj6otTN7CRTGUJduTf4ZhR5+d7GQng7lA9CNqOmTZwQ== From: Theodor Thornhill To: Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <83359vbavi.fsf@gnu.org> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <56840149-5EB9-4C22-841F-45F410BFC885@thornhill.no> <83edtjimyo.fsf@gnu.org> <875yet975l.fsf@thornhill.no> <87y1rp7dw2.fsf@thornhill.no> <87o7sjcpr4.fsf@thornhill.no> <83359vbavi.fsf@gnu.org> Date: Wed, 07 Dec 2022 10:31:13 +0100 Message-ID: <87pmcvzhjy.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:1004:224b::e9; envelope-from=theo@thornhill.no; helo=out-233.mta0.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit Cc: bug-gnu-emacs@gnu.org, 59662@debbugs.gnu.org, casouri@gmail.com, mardani29@yahoo.es X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Eli Zaretskii writes: >> From: Theodor Thornhill >> Cc: "Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army kni= fe >> of text editors" , Eli Zaretskii , >> casouri@gmail.com, 59662@debbugs.gnu.org >> Date: Sun, 04 Dec 2022 13:33:35 +0100 >>=20 >> Theodor Thornhill writes: >>=20 >> > On 2 December 2022 22:09:55 CET, "Daniel Mart=C3=ADn" wrote: >> >>Theodor Thornhill writes: >> >> >> >>> Right - thanks. However, this makes me wonder - should we really be >> >>> setting mark here? I see that c-indent-defun does not, and it feels >> >>> weird that indenting adds to the mark ring. What do you think? My >> >>> first patch used >> >>> >> >>> (indent-region >> >>> (treesit-node-start node) >> >>> (treesit-node-end node)) >> >>> >> >>> Which behaves similarly to c-indent-defun. >> >>> >> >>> See attached patch. >> >> >> >>I don't have a strong opinion, but if we can indent without setting the >> >>mark, I think it'd be a cleaner command. Specially if c-indent-defun >> >>doesn't set the mark either. >> > >> > Yeah, we don't need to set the mark. Thanks for the feedback :) >> > Theo >>=20 >> Eli, do you have any opinion on this matter? Should we implement this >> function without using marks? That will make the function a smidge >> bigger, but would not mess up the mark-ring. I think that's desirable, >> at least. > > IMO, it is better not to set the mark, indeed. Agreed, see attached patch. What do you think, Yuan and Eli? Should we expose the internal helper I used, or maybe this function could just as well live in treesit.c? Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-c-ts-mode-indent-defun.patch >From 7638a3b0c4c15800f70d0d7e1f444d7512e8994f Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Fri, 2 Dec 2022 16:05:35 +0100 Subject: [PATCH] Add c-ts-mode-indent-defun Add in this function to mimic 'c-indent-defun' * lisp/progmodes/c-ts-mode.el (c-ts-mode-indent-defun): New function. (c-ts-mode-map): New mode map that uses said function. (bug#59662) --- lisp/progmodes/c-ts-mode.el | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 0c66b4959e..998e988901 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -517,9 +517,30 @@ c-ts-mode--end-of-defun (if (looking-at "\\s<\\|\n") (forward-line 1))))) +(defun c-ts-mode-indent-defun () + "Indent the current top-level declaration syntactically. + +`treesit-defun-type-regexp' defines what constructs to indent." + (interactive "*") + (when-let ((node (treesit-search-forward + (treesit-node-at (point)) + treesit-defun-type-regexp t t))) + ;; Use internal function to make sure we get the top-level node. + (setq node (treesit--defun-maybe-top-level node)) + (indent-region + (treesit-node-start node) + (treesit-node-end node)))) + +(defvar-keymap c-ts-mode-map + :doc "Keymap for the C language with tree-sitter" + :parent prog-mode-map + "C-c C-q" #'c-ts-mode-indent-defun) + ;;;###autoload (define-derived-mode c-ts-base-mode prog-mode "C" - "Major mode for editing C, powered by tree-sitter." + "Major mode for editing C, powered by tree-sitter. + +\\{c-ts-mode-map}" :syntax-table c-ts-mode--syntax-table ;; Navigation. -- 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 07 08:44:44 2022 Received: (at submit) by debbugs.gnu.org; 7 Dec 2022 13:44:44 +0000 Received: from localhost ([127.0.0.1]:50445 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2uj5-0000zv-Km for submit@debbugs.gnu.org; Wed, 07 Dec 2022 08:44:43 -0500 Received: from lists.gnu.org ([209.51.188.17]:42048) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2uj4-0000zp-A2 for submit@debbugs.gnu.org; Wed, 07 Dec 2022 08:44:42 -0500 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 1p2uj2-00061v-Kw for bug-gnu-emacs@gnu.org; Wed, 07 Dec 2022 08:44:42 -0500 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 1p2uj1-0002AY-Vy; Wed, 07 Dec 2022 08:44:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=0yMweUzeQyxNytwtXbW3r8+svrTDSW1xmhBnwYKldxg=; b=Q53ijVZIJaTv qqRKrVYca3n5H+3OJGUM8+uuxl5DdFdnNU3mhQIibOPjhXWC04HPj3fCEvonpZ3E6IaDNSrBhUwNu ZQWuIIpK6aoFhu+5G2UJlFiNUsdmg9SAnve/MBYrllFw/dTO3G/G3nPNWDmPRnhrSjowO+2NGSe+5 yFSloF3J0L9JYTCAAknifUfB1kJuYfHE1ZWSF44OZtiduiI3QminOwKYLhkmy/ZV/FxCEdshJ2DqN GQKqHQLY14vt6VL2OeegjI6CO9d6D67rP/JVxolpd8Il/uJBiMCiDOF7AF8/9gP/BgVHnTRbXc+aX aMw9Gz4CYHcqDhmaxihsgQ==; 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 1p2uiv-0001Hc-8Q; Wed, 07 Dec 2022 08:44:39 -0500 Date: Wed, 07 Dec 2022 15:44:17 +0200 Message-Id: <83sfhr49ce.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: <87pmcvzhjy.fsf@thornhill.no> (message from Theodor Thornhill on Wed, 07 Dec 2022 10:31:13 +0100) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <56840149-5EB9-4C22-841F-45F410BFC885@thornhill.no> <83edtjimyo.fsf@gnu.org> <875yet975l.fsf@thornhill.no> <87y1rp7dw2.fsf@thornhill.no> <87o7sjcpr4.fsf@thornhill.no> <83359vbavi.fsf@gnu.org> <87pmcvzhjy.fsf@thornhill.no> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit Cc: bug-gnu-emacs@gnu.org, 59662@debbugs.gnu.org, casouri@gmail.com, mardani29@yahoo.es X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Theodor Thornhill > Cc: mardani29@yahoo.es, bug-gnu-emacs@gnu.org, casouri@gmail.com, > 59662@debbugs.gnu.org > Date: Wed, 07 Dec 2022 10:31:13 +0100 > > > IMO, it is better not to set the mark, indeed. > > Agreed, see attached patch. What do you think, Yuan and Eli? > > Should we expose the internal helper I used, or maybe this function > could just as well live in treesit.c? If it is expected to be useful outside treesit.el, I think it should become public. From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 07 14:54:49 2022 Received: (at 59662) by debbugs.gnu.org; 7 Dec 2022 19:54:49 +0000 Received: from localhost ([127.0.0.1]:51938 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p30VE-0002nI-Nc for submit@debbugs.gnu.org; Wed, 07 Dec 2022 14:54:49 -0500 Received: from mail-pg1-f178.google.com ([209.85.215.178]:40691) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p30VB-0002nC-NT for 59662@debbugs.gnu.org; Wed, 07 Dec 2022 14:54:46 -0500 Received: by mail-pg1-f178.google.com with SMTP id f9so17303993pgf.7 for <59662@debbugs.gnu.org>; Wed, 07 Dec 2022 11:54:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=1IyppNEhQU2gODlyXDVJB5y2AZTatN0zEQr9CbRPiko=; b=jDo0b4nU93LwfoGYBHZ+vt2+6XuMVeDTl+z3CVx2YdxK4ubX7UncSO8T9NO95HdWKW zuiCXf5RRKKA9J/fqODKz8tc4bgjGwy9xMlZvFhlsp2tLPVk46f5bVn5det0VJZzNuXF VHz+58/2BUIMRwhfwSNc+hTKLP6l1L3g6cHUVTDiW7wiake16xxn9j2HZpzoKFazMz/B 5hDjuMwclKe1sLN2YkPc5oO0k205L6DlW1L/nTSxK7SlbZ4KpO9NZ6MwDRuJe7JgjHLm Oor6joGM6POv3r+pYcDT0Rmz/1elEsWQttxq/gHV5mDJABp/h3/4Mn3HTWFBnXLeywvt jNlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1IyppNEhQU2gODlyXDVJB5y2AZTatN0zEQr9CbRPiko=; b=q5aA5gCZgZ7R7OLXDQhzg7uOHIGUjs5KzIWuTYtajXv/IXeYCuuTYAKf0HBipbo8SH 0S/RWPm8PaWq1uB+exZZZuW3+y8BkgBa43D7ofVZu6p1oXj0f/GeHyncclHU7tQKyRZF +QFs3iqXW6NUvbGixbiEj+XsijmMa1bfvQg+oRxbD5/DB9OHaX+BJXJa2MNJCibGpM4t EmfKe9isncgPXfcelfCA4UG3/H7eNGNXjtVe2ITMkNAvCOQNrBfRUSWZV7bOaMKEd+Uy f9nISkGB0v4+r3I1OJP2RS0tCkaZ6J4mIFu+F0KbIXosJ25Ix788/gyM0DwSAiQsEC48 S8eQ== X-Gm-Message-State: ANoB5pmPkC1ZC0lSKsmMg9uDGMAVVaQnY5AMvq7XiWpMBr4XdduKG+sm Y1FAeEr9+liN3XoPyhVQ8so= X-Google-Smtp-Source: AA0mqf56UH2D3kmJ5/a3d4U6VkR+CpmSY1QTnlzs46YRmfHCJgUQ3ALva2Np1Z2+oXst3siJ+zXTRg== X-Received: by 2002:a05:6a00:4308:b0:575:649c:e9e3 with SMTP id cb8-20020a056a00430800b00575649ce9e3mr43515251pfb.48.1670442879859; Wed, 07 Dec 2022 11:54:39 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id i22-20020a635416000000b00460ea630c1bsm11923567pgb.46.2022.12.07.11.54.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Dec 2022 11:54:39 -0800 (PST) From: Yuan Fu Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Message-Id: Date: Wed, 7 Dec 2022 11:54:37 -0800 To: Theodor Thornhill X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: Eli Zaretskii , 59662@debbugs.gnu.org, mardani29@yahoo.es X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Theodor Thornhill writes: > Eli Zaretskii writes: > >>> From: Theodor Thornhill >>> Cc: "Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army = knife >>> of text editors" , Eli Zaretskii = , >>> casouri@gmail.com, 59662@debbugs.gnu.org >>> Date: Sun, 04 Dec 2022 13:33:35 +0100 >>>=20 >>> Theodor Thornhill writes: >>>=20 >>> > On 2 December 2022 22:09:55 CET, "Daniel Mart=C3=ADn" = wrote: >>> >>Theodor Thornhill writes: >>> >> >>> >>> Right - thanks. However, this makes me wonder - should we = really be >>> >>> setting mark here? I see that c-indent-defun does not, and it = feels >>> >>> weird that indenting adds to the mark ring. What do you think? = My >>> >>> first patch used >>> >>> >>> >>> (indent-region >>> >>> (treesit-node-start node) >>> >>> (treesit-node-end node)) >>> >>> >>> >>> Which behaves similarly to c-indent-defun. >>> >>> >>> >>> See attached patch. >>> >> >>> >>I don't have a strong opinion, but if we can indent without = setting the >>> >>mark, I think it'd be a cleaner command. Specially if = c-indent-defun >>> >>doesn't set the mark either. >>> > >>> > Yeah, we don't need to set the mark. Thanks for the feedback :) >>> > Theo >>>=20 >>> Eli, do you have any opinion on this matter? Should we implement = this >>> function without using marks? That will make the function a smidge >>> bigger, but would not mess up the mark-ring. I think that's = desirable, >>> at least. >> >> IMO, it is better not to set the mark, indeed. > > Agreed, see attached patch. What do you think, Yuan and Eli? > > Should we expose the internal helper I used, or maybe this function > could just as well live in treesit.c? > > Theo > Very nice, I applied this patch with some changes to the function. I think using treesit-beginning/end-of-defun is more robust. Yuan From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 07 15:06:56 2022 Received: (at 59662) by debbugs.gnu.org; 7 Dec 2022 20:06:56 +0000 Received: from localhost ([127.0.0.1]:51999 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p30gy-0002uY-CY for submit@debbugs.gnu.org; Wed, 07 Dec 2022 15:06:56 -0500 Received: from out2.migadu.com ([188.165.223.204]:33898) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p30gv-0002uS-GN for 59662@debbugs.gnu.org; Wed, 07 Dec 2022 15:06:56 -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=1670443612; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o1DISV8e771Dd1FztYPgz+T5WXMox2KZnvOPp2y07+U=; b=0j3bSBh4BOhhDswys3KYD44jhwI/9j0axcAOJcs2etera08CdBpcG/KgZBbZl6qCuPubHz bc3+PhlXXF0XLrT3QKxtQKlnleR8lfzVg/khZcO7MHm4fyj8zDis9M06OQ9qqv/K060UiX bfBSK/aGeaMxNWP7nozTxaizMFwxrXsDq0pvMER764g697be/jBpfYKZOCcm9vKP4CFhCq bH8RLkMZtOS3TYq/np6zTyOPylxSIrCJABEMj7bPNioO7dKAIzXhVtumNpYI7x/+xuAlM6 fWDwJIubv9Gl32OLklduMb5XJO9m+txFSAHhYe92Kww9ukROJwrhnnBU+n/xRg== From: Theodor Thornhill To: Yuan Fu Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: References: Date: Wed, 07 Dec 2022 21:06:51 +0100 Message-ID: <87a63zyo4k.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: Eli Zaretskii , 59662@debbugs.gnu.org, mardani29@yahoo.es X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Yuan Fu writes: > Theodor Thornhill writes: > >> Eli Zaretskii writes: >> >>>> From: Theodor Thornhill >>>> Cc: "Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army k= nife >>>> of text editors" , Eli Zaretskii , >>>> casouri@gmail.com, 59662@debbugs.gnu.org >>>> Date: Sun, 04 Dec 2022 13:33:35 +0100 >>>>=20 >>>> Theodor Thornhill writes: >>>>=20 >>>> > On 2 December 2022 22:09:55 CET, "Daniel Mart=C3=ADn" wrote: >>>> >>Theodor Thornhill writes: >>>> >> >>>> >>> Right - thanks. However, this makes me wonder - should we really = be >>>> >>> setting mark here? I see that c-indent-defun does not, and it feels >>>> >>> weird that indenting adds to the mark ring. What do you think? My >>>> >>> first patch used >>>> >>> >>>> >>> (indent-region >>>> >>> (treesit-node-start node) >>>> >>> (treesit-node-end node)) >>>> >>> >>>> >>> Which behaves similarly to c-indent-defun. >>>> >>> >>>> >>> See attached patch. >>>> >> >>>> >>I don't have a strong opinion, but if we can indent without setting = the >>>> >>mark, I think it'd be a cleaner command. Specially if c-indent-defun >>>> >>doesn't set the mark either. >>>> > >>>> > Yeah, we don't need to set the mark. Thanks for the feedback :) >>>> > Theo >>>>=20 >>>> Eli, do you have any opinion on this matter? Should we implement this >>>> function without using marks? That will make the function a smidge >>>> bigger, but would not mess up the mark-ring. I think that's desirable, >>>> at least. >>> >>> IMO, it is better not to set the mark, indeed. >> >> Agreed, see attached patch. What do you think, Yuan and Eli? >> >> Should we expose the internal helper I used, or maybe this function >> could just as well live in treesit.c? >> >> Theo >> > > Very nice, I applied this patch with some changes to the function. I > think using treesit-beginning/end-of-defun is more robust. > > Yuan Thanks! Would you mind describing why? Theo From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 07 16:40:44 2022 Received: (at 59662) by debbugs.gnu.org; 7 Dec 2022 21:40:44 +0000 Received: from localhost ([127.0.0.1]:52362 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p329k-0003dl-Av for submit@debbugs.gnu.org; Wed, 07 Dec 2022 16:40:44 -0500 Received: from mail-pg1-f181.google.com ([209.85.215.181]:40742) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p329f-0003df-Fy for 59662@debbugs.gnu.org; Wed, 07 Dec 2022 16:40:43 -0500 Received: by mail-pg1-f181.google.com with SMTP id f9so17539941pgf.7 for <59662@debbugs.gnu.org>; Wed, 07 Dec 2022 13:40:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=fdYrSc+qyyjvnPZ3Ol3RAB5ER0WJAk4/vPwL14Ns3RY=; b=Tf6MM84eL92HnnISr9PIyk7bYzA7ivMRBiZYYzG9HNFZJE7xcdL9AZZ0m0/mP454j7 HlV1Fmp+0bXlsvz0LtVZ51H2m74JGOG7NcaOITnehTwN4lbDfhdnzuc8JF1stoB/+Ouc Jxnz+RAW3guFGPFY/TVfTST6Se0StsrfJb8XcOZCirsyB09qA03zJbz/bI3RK+idrwrQ v+L79KmMWvc2AiCIe5z0+tzDudCfS0frmS2IIOadO+O03ARpBkW9StDZ74FuHnaqrVG/ dybFYiauiSXWgnyRrol7h7qL28jzjE2ZiIzQwykJOxgV5bByeb5j215mZ6039r2o/Bwc X7qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fdYrSc+qyyjvnPZ3Ol3RAB5ER0WJAk4/vPwL14Ns3RY=; b=T3RRzZkoH8yjJQTVu+q2BT+sxKp4L0gLB6z9/rd69Zrs/EUSrQ5rZVGfJmAri2iP3W gc5CWmq86VAzOmkXRT856Ai4AwWY5hj0/p3blT68Jhm9XiVVYhy6VyT4qngAJ5WRRfQY 9WX1bOF3kwq96EgTIu+6vMyH2DWTWQ2huLbQhJB2JusKk7ck6jb+VM5i1i5RahugHVor bxoFRroJJNvozySS/q3czL+Dusyj/CJK4vLqbFvdWzzkNhyoD+4qbn8TvExLULQGoKTe 7IIv/Y/BA0rsps+40i/ulw/9XT3QN34TYVW/7V5UuCU8YXf/xJqTan8evDmbJODKwox/ THIg== X-Gm-Message-State: ANoB5pmX2/+gdPmpVFeGQUps8iB/2B3v/hoaOd4c4gkKaVvvk3DkTBa8 ulZukQjIurZywYUhiFP0j/I= X-Google-Smtp-Source: AA0mqf67ervCoS6zxxOBqnA+d9yv/hRYKtSARkYt5uo2l+nVw5WOIQxJJhEuLYPtyOoTOzGbn+6THQ== X-Received: by 2002:aa7:9097:0:b0:56c:674a:16f0 with SMTP id i23-20020aa79097000000b0056c674a16f0mr79510773pfa.10.1670449233450; Wed, 07 Dec 2022 13:40:33 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id z4-20020a17090abd8400b0021828120643sm1596156pjr.45.2022.12.07.13.40.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Dec 2022 13:40:32 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun From: Yuan Fu In-Reply-To: <87a63zyo4k.fsf@thornhill.no> Date: Wed, 7 Dec 2022 13:40:31 -0800 Content-Transfer-Encoding: quoted-printable Message-Id: <840EC1DB-C322-494D-96DA-5D9582E0C8C5@gmail.com> References: <87a63zyo4k.fsf@thornhill.no> To: Theodor Thornhill X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: Eli Zaretskii , 59662@debbugs.gnu.org, mardani29@yahoo.es X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > On Dec 7, 2022, at 12:06 PM, Theodor Thornhill = wrote: >=20 > Yuan Fu writes: >=20 >> Theodor Thornhill writes: >>=20 >>> Eli Zaretskii writes: >>>=20 >>>>> From: Theodor Thornhill >>>>> Cc: "Theodor Thornhill via Bug reports for GNU Emacs, the Swiss = army knife >>>>> of text editors" , Eli Zaretskii = , >>>>> casouri@gmail.com, 59662@debbugs.gnu.org >>>>> Date: Sun, 04 Dec 2022 13:33:35 +0100 >>>>>=20 >>>>> Theodor Thornhill writes: >>>>>=20 >>>>>> On 2 December 2022 22:09:55 CET, "Daniel Mart=C3=ADn" = wrote: >>>>>>> Theodor Thornhill writes: >>>>>>>=20 >>>>>>>> Right - thanks. However, this makes me wonder - should we = really be >>>>>>>> setting mark here? I see that c-indent-defun does not, and it = feels >>>>>>>> weird that indenting adds to the mark ring. What do you think? = My >>>>>>>> first patch used >>>>>>>>=20 >>>>>>>> (indent-region >>>>>>>> (treesit-node-start node) >>>>>>>> (treesit-node-end node)) >>>>>>>>=20 >>>>>>>> Which behaves similarly to c-indent-defun. >>>>>>>>=20 >>>>>>>> See attached patch. >>>>>>>=20 >>>>>>> I don't have a strong opinion, but if we can indent without = setting the >>>>>>> mark, I think it'd be a cleaner command. Specially if = c-indent-defun >>>>>>> doesn't set the mark either. >>>>>>=20 >>>>>> Yeah, we don't need to set the mark. Thanks for the feedback :) >>>>>> Theo >>>>>=20 >>>>> Eli, do you have any opinion on this matter? Should we implement = this >>>>> function without using marks? That will make the function a = smidge >>>>> bigger, but would not mess up the mark-ring. I think that's = desirable, >>>>> at least. >>>>=20 >>>> IMO, it is better not to set the mark, indeed. >>>=20 >>> Agreed, see attached patch. What do you think, Yuan and Eli? >>>=20 >>> Should we expose the internal helper I used, or maybe this function >>> could just as well live in treesit.c? >>>=20 >>> Theo >>>=20 >>=20 >> Very nice, I applied this patch with some changes to the function. I >> think using treesit-beginning/end-of-defun is more robust. >>=20 >> Yuan >=20 > Thanks! Would you mind describing why? Yes, sorry. I=E2=80=99m planning to change treesit-beginning-of-defun = and treesit-end-of-defun so they can behave differently according to = user configuration, basically they can decide whether to skip nested = defuns or not. If we use these functions rather than re-implementing = their logic (to some extent) in c-ts-mode-indent-defun, any improvement = to defun navigation would automatically benefit c-ts-mode-indent-defun. Yuan= From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 07 16:53:39 2022 Received: (at 59662) by debbugs.gnu.org; 7 Dec 2022 21:53:39 +0000 Received: from localhost ([127.0.0.1]:52419 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p32ME-0003ms-SP for submit@debbugs.gnu.org; Wed, 07 Dec 2022 16:53:39 -0500 Received: from out2.migadu.com ([188.165.223.204]:11275) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p32MC-0003mm-D0 for 59662@debbugs.gnu.org; Wed, 07 Dec 2022 16:53:37 -0500 Date: Wed, 07 Dec 2022 22:53:03 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1670450014; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nzfyyMfOH1kVaCQe9Oo2rxwOBR9/3fTMSzXYxIHhJRg=; b=O6GjR4QEEvVXdhgG4RTsR/oJpSb26qLaviHKSmjGd3hcaV7usi90vGdggK2XKVAeGj4xu6 X8IKLX1IxZE4+ElfiQfZ4Jtgt16pjlONbXFdqugrLz21d70gVMd7S3GL90Wl93CCPq9SUB PvlMpBKjy4Y987vzp90tKHzDpN5AGByvdvFVzReyUgn3l82fOCoZVCclIflaQ1bBibFgUf KTp2aoQVvPkN/OeyHjouX1cQ93de04CO4E+R5/wq6gxTMRJJWEHUDW98kLgL7wKmQOh+qo ibjFCW31wOy6xDbq1eIk84Ajk+wMMVUiUIp73qSLAfwRTMNM2Ol1iipwAmlBog== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Theodor Thornhill To: Yuan Fu Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <840EC1DB-C322-494D-96DA-5D9582E0C8C5@gmail.com> References: <87a63zyo4k.fsf@thornhill.no> <840EC1DB-C322-494D-96DA-5D9582E0C8C5@gmail.com> Message-ID: <6AD2610D-8A71-4F34-A8CC-119C2FB55C40@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: Eli Zaretskii , 59662@debbugs.gnu.org, mardani29@yahoo.es X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 7 December 2022 22:40:31 CET, Yuan Fu wrote: > > >> On Dec 7, 2022, at 12:06 PM, Theodor Thornhill wr= ote: >>=20 >> Yuan Fu writes: >>=20 >>> Theodor Thornhill writes: >>>=20 >>>> Eli Zaretskii writes: >>>>=20 >>>>>> From: Theodor Thornhill >>>>>> Cc: "Theodor Thornhill via Bug reports for GNU Emacs, the Swiss arm= y knife >>>>>> of text editors" , Eli Zaretskii , >>>>>> casouri@gmail=2Ecom, 59662@debbugs=2Egnu=2Eorg >>>>>> Date: Sun, 04 Dec 2022 13:33:35 +0100 >>>>>>=20 >>>>>> Theodor Thornhill writes: >>>>>>=20 >>>>>>> On 2 December 2022 22:09:55 CET, "Daniel Mart=C3=ADn" wrote: >>>>>>>> Theodor Thornhill writes: >>>>>>>>=20 >>>>>>>>> Right - thanks=2E However, this makes me wonder - should we rea= lly be >>>>>>>>> setting mark here? I see that c-indent-defun does not, and it fe= els >>>>>>>>> weird that indenting adds to the mark ring=2E What do you think= ? My >>>>>>>>> first patch used >>>>>>>>>=20 >>>>>>>>> (indent-region >>>>>>>>> (treesit-node-start node) >>>>>>>>> (treesit-node-end node)) >>>>>>>>>=20 >>>>>>>>> Which behaves similarly to c-indent-defun=2E >>>>>>>>>=20 >>>>>>>>> See attached patch=2E >>>>>>>>=20 >>>>>>>> I don't have a strong opinion, but if we can indent without setti= ng the >>>>>>>> mark, I think it'd be a cleaner command=2E Specially if c-indent= -defun >>>>>>>> doesn't set the mark either=2E >>>>>>>=20 >>>>>>> Yeah, we don't need to set the mark=2E Thanks for the feedback :) >>>>>>> Theo >>>>>>=20 >>>>>> Eli, do you have any opinion on this matter? Should we implement th= is >>>>>> function without using marks? That will make the function a smidge >>>>>> bigger, but would not mess up the mark-ring=2E I think that's desi= rable, >>>>>> at least=2E >>>>>=20 >>>>> IMO, it is better not to set the mark, indeed=2E >>>>=20 >>>> Agreed, see attached patch=2E What do you think, Yuan and Eli? >>>>=20 >>>> Should we expose the internal helper I used, or maybe this function >>>> could just as well live in treesit=2Ec? >>>>=20 >>>> Theo >>>>=20 >>>=20 >>> Very nice, I applied this patch with some changes to the function=2E I >>> think using treesit-beginning/end-of-defun is more robust=2E >>>=20 >>> Yuan >>=20 >> Thanks! Would you mind describing why? > >Yes, sorry=2E I=E2=80=99m planning to change treesit-beginning-of-defun a= nd treesit-end-of-defun so they can behave differently according to user co= nfiguration, basically they can decide whether to skip nested defuns or not= =2E If we use these functions rather than re-implementing their logic (to s= ome extent) in c-ts-mode-indent-defun, any improvement to defun navigation = would automatically benefit c-ts-mode-indent-defun=2E > >Yuan Thanks for explaining your rationale=2E=20 By the way, there's an issue with the patch you applied: void foo() { =2E=2E=2E } If point is at the v in void, the current implementation will not reinvent= =2E I didn't get time to debug yet, though=2E Possibly that will be fixed a= fter your rework as well=2E Theo From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 07 18:09:36 2022 Received: (at 59662) by debbugs.gnu.org; 7 Dec 2022 23:09:36 +0000 Received: from localhost ([127.0.0.1]:52728 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p33Xj-0004OE-Hv for submit@debbugs.gnu.org; Wed, 07 Dec 2022 18:09:35 -0500 Received: from mail-pl1-f178.google.com ([209.85.214.178]:44861) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p33Xe-0004O5-QJ for 59662@debbugs.gnu.org; Wed, 07 Dec 2022 18:09:33 -0500 Received: by mail-pl1-f178.google.com with SMTP id g10so18466320plo.11 for <59662@debbugs.gnu.org>; Wed, 07 Dec 2022 15:09:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=XSmcx9Lb0XTSo1wpuDffC35awnMChdM+F02IFIDj24Y=; b=MrA8AKYkFElu59o9t2jKZ91GjW3ePz2AXl4hLZVXB/3x5LUNMCM748VP7VNeqbTBRY HO+FnM+ATR5JcPFRUF58qje15L3mQMRb/aRne0QWL6j8LlJ9s7v7cIOytXMyHOCmjLwH Q3qSnfex+EQmAZH+EsxUorCC3HMAEJKtQGe5Z0Fbb3THeqDumVix+IwwPWqUEi09FQ9t ICpdysNPU5SUoTcTj9ySwoIHtMJfjSbQvBO0haVtwA0VN1MhbxyNwu2IXinstIxu+EyT LdfRe6imUxxxAQsgQDuQ7ETewzIKZFkEzmMj/4EdsR/YH1MdGW40ahhOEKZ1r+RIsCdV DDeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XSmcx9Lb0XTSo1wpuDffC35awnMChdM+F02IFIDj24Y=; b=R9TmdonnQMZD/Up2LmTfMu4wXwcmkk+vRmjFx3BFWCv5oTAtKudr4cN03JUbg3vWe1 KuFuRMHjp3nyIyBKfRLd3L/PvPMKnPjD/z1KTAnFJO/yRUEpYd7WKbhh1TAaMZfz7IBn qKcOmCpvmcKW92emZ6hKdEa4WQtn7SbU0d6U35wSPO+ZQczSPVTdDp4cA9JOjsjKB1Tu VX1ch4d3wYeW2//HwXabOBiLCd6nzlTR94Bk3uwKt4vWvJGAukD+LOThkJ9nOwK6P261 K0AExvll+xHyVER6wc1eSfjq4oPVLCytMEnHe9Gb2BI3Ma+Y2Au/runxK15GY2zrt/zH M8pA== X-Gm-Message-State: ANoB5pmOjxcGzNnLbbGLkKQ26ftv7BAodkAVsCFo0OI7H7+UoV3mETuq Ud6zj10bDqrmbmZN7VSQxbg= X-Google-Smtp-Source: AA0mqf6wNqBqkb5CHCsTZ2DWnIKxeJGkmTQgR6TGsZrpeYybZ4eE2HDfPus+2s1QDihbl0tdxS1xIw== X-Received: by 2002:a05:6a20:9d92:b0:a3:c2a2:260f with SMTP id mu18-20020a056a209d9200b000a3c2a2260fmr1510599pzb.48.1670454564837; Wed, 07 Dec 2022 15:09:24 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id h13-20020a65468d000000b00477f5ae26bbsm11959418pgr.50.2022.12.07.15.09.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Dec 2022 15:09:23 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun From: Yuan Fu In-Reply-To: <6AD2610D-8A71-4F34-A8CC-119C2FB55C40@thornhill.no> Date: Wed, 7 Dec 2022 15:09:22 -0800 Content-Transfer-Encoding: quoted-printable Message-Id: References: <87a63zyo4k.fsf@thornhill.no> <840EC1DB-C322-494D-96DA-5D9582E0C8C5@gmail.com> <6AD2610D-8A71-4F34-A8CC-119C2FB55C40@thornhill.no> To: Theodor Thornhill X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: Eli Zaretskii , 59662@debbugs.gnu.org, mardani29@yahoo.es X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > On Dec 7, 2022, at 1:53 PM, Theodor Thornhill = wrote: >=20 >=20 >=20 > On 7 December 2022 22:40:31 CET, Yuan Fu wrote: >>=20 >>=20 >>> On Dec 7, 2022, at 12:06 PM, Theodor Thornhill = wrote: >>>=20 >>> Yuan Fu writes: >>>=20 >>>> Theodor Thornhill writes: >>>>=20 >>>>> Eli Zaretskii writes: >>>>>=20 >>>>>>> From: Theodor Thornhill >>>>>>> Cc: "Theodor Thornhill via Bug reports for GNU Emacs, the Swiss = army knife >>>>>>> of text editors" , Eli Zaretskii = , >>>>>>> casouri@gmail.com, 59662@debbugs.gnu.org >>>>>>> Date: Sun, 04 Dec 2022 13:33:35 +0100 >>>>>>>=20 >>>>>>> Theodor Thornhill writes: >>>>>>>=20 >>>>>>>> On 2 December 2022 22:09:55 CET, "Daniel Mart=C3=ADn" = wrote: >>>>>>>>> Theodor Thornhill writes: >>>>>>>>>=20 >>>>>>>>>> Right - thanks. However, this makes me wonder - should we = really be >>>>>>>>>> setting mark here? I see that c-indent-defun does not, and it = feels >>>>>>>>>> weird that indenting adds to the mark ring. What do you = think? My >>>>>>>>>> first patch used >>>>>>>>>>=20 >>>>>>>>>> (indent-region >>>>>>>>>> (treesit-node-start node) >>>>>>>>>> (treesit-node-end node)) >>>>>>>>>>=20 >>>>>>>>>> Which behaves similarly to c-indent-defun. >>>>>>>>>>=20 >>>>>>>>>> See attached patch. >>>>>>>>>=20 >>>>>>>>> I don't have a strong opinion, but if we can indent without = setting the >>>>>>>>> mark, I think it'd be a cleaner command. Specially if = c-indent-defun >>>>>>>>> doesn't set the mark either. >>>>>>>>=20 >>>>>>>> Yeah, we don't need to set the mark. Thanks for the feedback :) >>>>>>>> Theo >>>>>>>=20 >>>>>>> Eli, do you have any opinion on this matter? Should we implement = this >>>>>>> function without using marks? That will make the function a = smidge >>>>>>> bigger, but would not mess up the mark-ring. I think that's = desirable, >>>>>>> at least. >>>>>>=20 >>>>>> IMO, it is better not to set the mark, indeed. >>>>>=20 >>>>> Agreed, see attached patch. What do you think, Yuan and Eli? >>>>>=20 >>>>> Should we expose the internal helper I used, or maybe this = function >>>>> could just as well live in treesit.c? >>>>>=20 >>>>> Theo >>>>>=20 >>>>=20 >>>> Very nice, I applied this patch with some changes to the function. = I >>>> think using treesit-beginning/end-of-defun is more robust. >>>>=20 >>>> Yuan >>>=20 >>> Thanks! Would you mind describing why? >>=20 >> Yes, sorry. I=E2=80=99m planning to change treesit-beginning-of-defun = and treesit-end-of-defun so they can behave differently according to = user configuration, basically they can decide whether to skip nested = defuns or not. If we use these functions rather than re-implementing = their logic (to some extent) in c-ts-mode-indent-defun, any improvement = to defun navigation would automatically benefit c-ts-mode-indent-defun. >>=20 >> Yuan >=20 > Thanks for explaining your rationale.=20 >=20 > By the way, there's an issue with the patch you applied: >=20 > void > foo() > { > ... > } >=20 > If point is at the v in void, the current implementation will not = reinvent. I didn't get time to debug yet, though. Possibly that will be = fixed after your rework as well. Ah, thanks, I=E2=80=99ll fix that. And I=E2=80=99ll ask for your opinion = before making changes next time, however innocent I thought the change = is :-) Yuan= From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 07 20:38:06 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 01:38:06 +0000 Received: from localhost ([127.0.0.1]:53431 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p35rR-0007yJ-TN for submit@debbugs.gnu.org; Wed, 07 Dec 2022 20:38:06 -0500 Received: from mail-wm1-f48.google.com ([209.85.128.48]:38777) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p35rP-0007xu-NU for 59662@debbugs.gnu.org; Wed, 07 Dec 2022 20:38:04 -0500 Received: by mail-wm1-f48.google.com with SMTP id r65-20020a1c4444000000b003d1e906ca23so2388119wma.3 for <59662@debbugs.gnu.org>; Wed, 07 Dec 2022 17:38:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:sender:from:to:cc:subject :date:message-id:reply-to; bh=wpeJmOHHEMCpZy5hk1xqOqAbT4K557kPRwOV5fIQbc0=; b=bE2qHYU2GR2e2AxXzGDeeG3NxBNPmGHRezEQP606FZahM53bE6Qa3rh+n/Vq8jF5WY +pJtZrlDgqXyg3WFJD6v5FB2j905ga/3fte7iZB/8HJ1YyzMBdjGqury2dTo1tRIDAEY ryzUq1AC2at6lqDIMITDWsJBGaNHuaG9pkl3NQwKCeojW3YnI8TLs4cagyJmVd7p7qpP ssQmKXHL26vRUG4E7O9xTmyejhTHJqjhQZkR2B9yu5RjKMh5mHq/nLg11lB73ij1/cK6 HOCMnAj4qJa/Mul+oQ3i2pVmIDruNBAm+hzcVq06wp2wR5y4ffNFIzYTe9+3hXDyBZqZ BpBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:sender:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=wpeJmOHHEMCpZy5hk1xqOqAbT4K557kPRwOV5fIQbc0=; b=XaRVpgEr5qasVS4XK2LVmCWGDcV/SqdviUOFNnrOKg6jyErIeVLU2BkkR4+kP8Bj0r V+D/7ZhJfNJKsb9uPBpMqUhWn2yrJqRMdqXE8phIuHrhiG8Nxwe50LxKn2fXyNd64blV MOraKhILU9Jv4uzcDy1srWhg8+cxJ21vd103AVjPwJrkUpD/Ng9U9jYt6WPNWW3njtoH ueJWtzIdeEufEJ7m96S9VKjMuXyFLXyRHtVm5/qtxl1JkouB+I6dYigLBSMM/2lOFykB Bd5AVbyoCE9ppoqUhxzOJZjOhrEtoojXdnRuMJVxA69ADF60gvzArRP8avxUvBiazZQJ 2sLQ== X-Gm-Message-State: ANoB5pldmRxSR6Y/WB0BJr2+JFYlFMIPyU2pN8+UkrWeWvp2hvzTrRhP 0ZoQVbnM5fUFjyjPbjZD8/4= X-Google-Smtp-Source: AA0mqf5AE7HAXYrbeOjCkFm3VUbjWR5XvY4hhm3DQZfnz67KKOLcWuxD4q7h7J/B8G/gZfmkKZRG5A== X-Received: by 2002:a05:600c:1826:b0:3cf:608b:1b6a with SMTP id n38-20020a05600c182600b003cf608b1b6amr60501654wmp.20.1670463477618; Wed, 07 Dec 2022 17:37:57 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id k32-20020a05600c1ca000b003b4ff30e566sm9259899wms.3.2022.12.07.17.37.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Dec 2022 17:37:56 -0800 (PST) Content-Type: multipart/mixed; boundary="------------huhqv3iE4JfQ03r8DomzDXhr" Message-ID: <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> Date: Thu, 8 Dec 2022 03:37:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US To: Eli Zaretskii References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> From: Dmitry Gutov In-Reply-To: <83wn78cqz4.fsf@gnu.org> X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: casouri@gmail.com, 59662@debbugs.gnu.org, theo@thornhill.no, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) This is a multi-part message in MIME format. --------------huhqv3iE4JfQ03r8DomzDXhr Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 03/12/2022 19:54, Eli Zaretskii wrote: >> paredit-reindent-defun, like I described, does all that too. But when >> outside strings and comments, it reindents the current defun. > So maybe paredit-reindent-defun doesn't need any fixes, but using it as a > role model for the C-like languages is not TRT, since in C these are two > separate commands with two different key bindings. It's not a given that the current state of things must automatically be optimal. But of course I can't vouch whether this behavior is optimal for every language. And major modes will continue to be able to rebind these key sequences. >> AFAICT, these behaviors are quite compatible. But paredit's binding >> seems to be useful in more contexts. > I'm fine with trying something like that on master, to see whether users > like this conflation, but not on the release branch. Here's a patch that people can try. From my brief testing, seems useful enough. I suppose some might dislike it, though, in some codebases where the methods/functions are consistently longer than a screenful. I do like this binding in Emacs Lisp too, though. --------------huhqv3iE4JfQ03r8DomzDXhr Content-Type: text/x-patch; charset=UTF-8; name="prog-reindent-defun.diff" Content-Disposition: attachment; filename="prog-reindent-defun.diff" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL2xpc3AvcHJvZ21vZGVzL3Byb2ctbW9kZS5lbCBiL2xpc3AvcHJvZ21v ZGVzL3Byb2ctbW9kZS5lbAppbmRleCA1OGNiNDhmMTgyLi40NmJhY2VhNzM3IDEwMDY0NAot LS0gYS9saXNwL3Byb2dtb2Rlcy9wcm9nLW1vZGUuZWwKKysrIGIvbGlzcC9wcm9nbW9kZXMv cHJvZy1tb2RlLmVsCkBAIC0xMDIsNyArMTAyLDggQEAgcHJvZy1jb250ZXh0LW1lbnUKIAog KGRlZnZhci1rZXltYXAgcHJvZy1tb2RlLW1hcAogICA6ZG9jICJLZXltYXAgdXNlZCBmb3Ig cHJvZ3JhbW1pbmcgbW9kZXMuIgotICAiQy1NLXEiICMncHJvZy1pbmRlbnQtc2V4cCkKKyAg IkMtTS1xIiAjJ3Byb2ctaW5kZW50LXNleHAKKyAgIk0tcSIgIydwcm9nLXJlaW5kZW50LWRl ZnVuKQogCiAoZGVmdmFyIHByb2ctaW5kZW50YXRpb24tY29udGV4dCBuaWwKICAgIldoZW4g bm9uLW5pbCwgcHJvdmlkZXMgY29udGV4dCBmb3IgaW5kZW50aW5nIGVtYmVkZGVkIGNvZGUg Y2h1bmtzLgpAQCAtMTQ0LDYgKzE0NSwyNiBAQCBwcm9nLWZpcnN0LWNvbHVtbgogICAiUmV0 dXJuIHRoZSBpbmRlbnRhdGlvbiBjb2x1bW4gbm9ybWFsbHkgdXNlZCBmb3IgdG9wLWxldmVs IGNvbnN0cnVjdHMuIgogICAob3IgKGNhciBwcm9nLWluZGVudGF0aW9uLWNvbnRleHQpIDAp KQogCisoZGVmdW4gcHJvZy1yZWluZGVudC1kZWZ1biAoJm9wdGlvbmFsIGFyZ3VtZW50KQor ICAiUmVmaWxsIHBhcmFncmFwaCBvciByZWluZGVudCB0aGUgZGVmaW5pdGlvbiB0aGF0IHRo ZSBwb2ludCBpcyBvbi4KKworSWYgdGhlIHBvaW50IGlzIGluIGEgc3RyaW5nLCBvciBpbiBh IGNvbW1lbnQsIG9yIHRoZXJlIGlzIGEKK2NvbW1lbnQgb24gdGhlIGN1cnJlbnQgbGluZSwg ZmlsbCB0aGUgcGFyYWdyYXBoIHRoYXQgdGhlIHBvaW50IGlzCitpbiBvciBpcyBvbiB0aGUg c2FtZSBsaW5lLgorCitPdGhlcndpc2UsIHJlaW5kZW50IHRoZSBkZWZpbml0aW9uIGFyb3Vu ZCBvciBiZWxvdyBwb2ludC4iCisgIChpbnRlcmFjdGl2ZSAiUCIpCisgIChzYXZlLWV4Y3Vy c2lvbgorICAgIChpZiAob3IgKG50aCA4IChzeW50YXgtcHBzcykpCisgICAgICAgICAgICAo cmUtc2VhcmNoLWZvcndhcmQgY29tbWVudC1zdGFydC1za2lwIChsaW5lLWVuZC1wb3NpdGlv bikgdCkpCisgICAgICAgIChpZiAobWVtcSBmaWxsLXBhcmFncmFwaC1mdW5jdGlvbiAnKHQg bmlsKSkKKyAgICAgICAgICAgIChsaXNwLWZpbGwtcGFyYWdyYXBoIGFyZ3VtZW50KQorICAg ICAgICAgIChmdW5jYWxsIGZpbGwtcGFyYWdyYXBoLWZ1bmN0aW9uIGFyZ3VtZW50KSkKKyAg ICAgIChlbmQtb2YtZGVmdW4pCisgICAgICAobGV0ICgoZW5kIChwb2ludCkpKQorICAgICAg ICAoYmVnaW5uaW5nLW9mLWRlZnVuKQorICAgICAgICAoaW5kZW50LXJlZ2lvbiAocG9pbnQp IGVuZCkpKSkpCisKIChkZWZ2YXItbG9jYWwgcHJldHRpZnktc3ltYm9scy1hbGlzdCBuaWwK ICAgIkFsaXN0IG9mIHN5bWJvbCBwcmV0dGlmaWNhdGlvbnMuCiBFYWNoIGVsZW1lbnQgbG9v a3MgbGlrZSAoU1lNQk9MIC4gQ0hBUkFDVEVSKSwgd2hlcmUgdGhlIHN5bWJvbAo= --------------huhqv3iE4JfQ03r8DomzDXhr-- From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 01:04:02 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 06:04:02 +0000 Received: from localhost ([127.0.0.1]:54587 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3A0o-00048f-Cn for submit@debbugs.gnu.org; Thu, 08 Dec 2022 01:04:02 -0500 Received: from out-228.mta0.migadu.com ([91.218.175.228]:10049) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3A0j-00048S-Mp for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 01:04:01 -0500 Date: Thu, 08 Dec 2022 07:02:47 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1670479436; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0WtqKQXSjkPT8irFdbL6pUp6KQwmk3cfjdQjSAeGcTI=; b=rKbPgox8E3I5wderYBZNSD4eqnUtecAmXcdjYIeOA4g3iFf+igtzyWvXgEP0W4SxoEhWck 1lare4ZEUy/PWA3HopRXruzDO6qUCri+Prpwfx9TkHgnEcYeR6eUxQgCYwCgTzXBScEN3C Azi/7sM87x6gtRnSEZxZ0lbBHQ18Cja1Yep01PIqcZYJ+coVPrydg/P8qXk1/Uc8v0Ftrn +EWO7atT3og9WUTNWk0w26NM7UN/DUfVIXhOgBdF4XtEDl9tJXbuu809axxN4t4TbfZ/hU f4Nw3Vi6lk2p2GJgbGq2kzut/GvXwJDEwiWeNz8eegrl4IKpyf7QUPOetKXjIw== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Theodor Thornhill To: Yuan Fu Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: References: <87a63zyo4k.fsf@thornhill.no> <840EC1DB-C322-494D-96DA-5D9582E0C8C5@gmail.com> <6AD2610D-8A71-4F34-A8CC-119C2FB55C40@thornhill.no> Message-ID: <65F2C4BB-BFD4-4116-B454-2C0AE06F3D2B@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: Eli Zaretskii , 59662@debbugs.gnu.org, mardani29@yahoo.es X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Would you mind describing why? >>>=20 >>> Yes, sorry=2E I=E2=80=99m planning to change treesit-beginning-of-defu= n and treesit-end-of-defun so they can behave differently according to user= configuration, basically they can decide whether to skip nested defuns or = not=2E If we use these functions rather than re-implementing their logic (t= o some extent) in c-ts-mode-indent-defun, any improvement to defun navigati= on would automatically benefit c-ts-mode-indent-defun=2E >>>=20 >>> Yuan >>=20 >> Thanks for explaining your rationale=2E=20 >>=20 >> By the way, there's an issue with the patch you applied: >>=20 >> void >> foo() >> { >> =2E=2E=2E >> } >>=20 >> If point is at the v in void, the current implementation will not reinv= ent=2E I didn't get time to debug yet, though=2E Possibly that will be fixe= d after your rework as well=2E > >Ah, thanks, I=E2=80=99ll fix that=2E And I=E2=80=99ll ask for your opinio= n before making changes next time, however innocent I thought the change is= :-) > >Yuan No stress, just wanted to point it out, but thanks! Theo From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 02:16:23 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 07:16:24 +0000 Received: from localhost ([127.0.0.1]:54928 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3B8p-0004zg-GS for submit@debbugs.gnu.org; Thu, 08 Dec 2022 02:16:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57902) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3B8n-0004za-7D for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 02:16:21 -0500 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 1p3B8f-0003G1-JI; Thu, 08 Dec 2022 02:16:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=r1K29HVj5o59kbsbLv1XIFxoFoxlSlau60qm4d1gooM=; b=fx9BBWhzz7pH FrI+S802cjUqSASitDXFmw295gpap/WCB/uXwooWm3PS+cD4pOzG01EuNEkDNP8iOfT/n7KdMnbDf j0kTy1OOEddClIFfEhlVULzvZ7iDU5W9XFGI9UrXV3hN0U/jsmSPAzC9Cgq0ffghF841wTjTmR0uv gU3sQWnauNEwYLAK9OEwznxIUaXmXyB+ZR7kQhkRQvtwOU1HIOX+JwNhPXm2dsqRWBU6QILMk3Za9 j5dsqoKUz9TClfKq78f5b53x8EvEyhPTrZxZiMY4iXhLMmnJDh4YuwhcZxMgYw+gqxdwWBcbz6eFp 0qCM94PTjmcekC3CxR57IA==; 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 1p3B8d-0002I8-N3; Thu, 08 Dec 2022 02:16:13 -0500 Date: Thu, 08 Dec 2022 09:16:00 +0200 Message-Id: <83y1ri2wnj.fsf@gnu.org> From: Eli Zaretskii To: Dmitry Gutov , Stefan Monnier , Lars Ingebrigtsen In-Reply-To: <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> (message from Dmitry Gutov on Thu, 8 Dec 2022 03:37:54 +0200) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: casouri@gmail.com, 59662@debbugs.gnu.org, theo@thornhill.no, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Thu, 8 Dec 2022 03:37:54 +0200 > Cc: theo@thornhill.no, casouri@gmail.com, 59662@debbugs.gnu.org, > casouri@gmail.org > From: Dmitry Gutov > > >> AFAICT, these behaviors are quite compatible. But paredit's binding > >> seems to be useful in more contexts. > > I'm fine with trying something like that on master, to see whether users > > like this conflation, but not on the release branch. > > Here's a patch that people can try. From my brief testing, seems useful > enough. I suppose some might dislike it, though, in some codebases where > the methods/functions are consistently longer than a screenful. I do > like this binding in Emacs Lisp too, though. Stefan, Lars: any comments? I'm okay with installing this on master, but please rename the new function to something like prog-fill-reindent; the "fill" part should appear in the name, to explain why we have both prog-indent and this function. Also, a NEWS entry and some addition to the "Multi-line Indent" node of the Emacs user manual would be nice. Bonus points for adding something that could use treesit.el capabilities, when those are available, instead of syntax-ppss, to determine when we are in a comment or in a string. Or maybe Theo or Yuan could suggest such an addition. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 03:11:37 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 08:11:37 +0000 Received: from localhost ([127.0.0.1]:55166 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3C0G-0005VM-I1 for submit@debbugs.gnu.org; Thu, 08 Dec 2022 03:11:37 -0500 Received: from out2.migadu.com ([188.165.223.204]:26112) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3C0D-0005VF-Dv for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 03:11:34 -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=1670487090; 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=kYerDy25dc21u7i0UClgGNcAGqxWNcKQyDAt5UJTuJQ=; b=0Cq78XBZJNU7AU4obCbsaGd3+8xbXV8HSAm6lr7FVn6U0TmgcAvrmTn3E/0rbQBJ6cW+z2 Gl19oGQ6m3ToDKRVXBKYgNsKCo0eqy2iyaSA7MZqYvG5ynUXNXStWlcvAZGdLAyVcZ4Q1G kLHkFn3NGKri1GSyd3tiBQXMgakzdax2KCUPt0xZGW5M2zL1pofwqJbiO4jSpaNo1m3jOK 5jWNfofOdCky35u63ey1htoTrEhdv6TdGXLuJPIINKfZIT1fJDmof1jrA0UXdrJYYZE4tQ cURZqbjwl+av43pUloae+sz0KO8ek3KFkKYkM1arDx9v206cvM82MJJ6qQnFCw== From: Theodor Thornhill To: Eli Zaretskii , Dmitry Gutov , Stefan Monnier , Lars Ingebrigtsen Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <83y1ri2wnj.fsf@gnu.org> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> Date: Thu, 08 Dec 2022 09:11:28 +0100 Message-ID: <875yemz55b.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: casouri@gmail.com, 59662@debbugs.gnu.org, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> Date: Thu, 8 Dec 2022 03:37:54 +0200 >> Cc: theo@thornhill.no, casouri@gmail.com, 59662@debbugs.gnu.org, >> casouri@gmail.org >> From: Dmitry Gutov >> >> >> AFAICT, these behaviors are quite compatible. But paredit's binding >> >> seems to be useful in more contexts. >> > I'm fine with trying something like that on master, to see whether users >> > like this conflation, but not on the release branch. >> >> Here's a patch that people can try. From my brief testing, seems useful >> enough. I suppose some might dislike it, though, in some codebases where >> the methods/functions are consistently longer than a screenful. I do >> like this binding in Emacs Lisp too, though. > > Stefan, Lars: any comments? > > I'm okay with installing this on master, but please rename the new > function to something like prog-fill-reindent; the "fill" part should > appear in the name, to explain why we have both prog-indent and this > function. > > Also, a NEWS entry and some addition to the "Multi-line Indent" node > of the Emacs user manual would be nice. > > Bonus points for adding something that could use treesit.el > capabilities, when those are available, instead of syntax-ppss, to > determine when we are in a comment or in a string. Or maybe Theo or > Yuan could suggest such an addition. > This works perfectly as is in *-ts-modes. At least for modes where syntax-table is set correctly. I don't think there's a reason to enable treesit.el capabilities, unless there's a case where this doesn't work. If this ends up in master, should I backport some similar feature for the *ts-modes? Theo From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 03:28:06 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 08:28:06 +0000 Received: from localhost ([127.0.0.1]:55241 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3CGD-0005ev-Rf for submit@debbugs.gnu.org; Thu, 08 Dec 2022 03:28:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58302) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3CG9-0005eW-5S for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 03:28:04 -0500 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 1p3CG0-0002bL-IV; Thu, 08 Dec 2022 03:27:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=3YZ5B3G5YBohp6x7q/pI16WbXRC4ZjOp1JmddUxcAWE=; b=ngO6R3ZLXR75 kpjMmMH75yKTXQBjUMwagJuAt5AItvKinCuxZyt+8AwhkGSqOVmZYr4fV4xJTjf3rVwjoIPzSs7zN KZIlmel9vtRHmQbl2qkgM6j1t+DU/KdPDrxAQ6YH3pfr0pmfPMfD/XU2/jS+OaunGlQc/9DmfrCsn L1Yenqu6bhaYeCQVOwK+rXnAFo9vP5kzp5zDKJCUglXWiROxN2lRKCiguLZbPdxivYe4dpktNZCZ5 WWWIvIIn26U41BAtbCw0x04oGmODdJsEI87mc3c2dp24UcJF+9TLiAId1dL0iuPJJyOQyWMSMbESZ v+YIE7w5oyk/m7pBCRQYAQ==; 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 1p3CFz-0003gX-Fa; Thu, 08 Dec 2022 03:27:52 -0500 Date: Thu, 08 Dec 2022 10:27:39 +0200 Message-Id: <83r0xa2tc4.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: <875yemz55b.fsf@thornhill.no> (message from Theodor Thornhill on Thu, 08 Dec 2022 09:11:28 +0100) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: casouri@gmail.com, 59662@debbugs.gnu.org, monnier@iro.umontreal.ca, dgutov@yandex.ru, larsi@gnus.org, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Theodor Thornhill > Cc: casouri@gmail.com, 59662@debbugs.gnu.org, casouri@gmail.org > Date: Thu, 08 Dec 2022 09:11:28 +0100 > > > Bonus points for adding something that could use treesit.el > > capabilities, when those are available, instead of syntax-ppss, to > > determine when we are in a comment or in a string. Or maybe Theo or > > Yuan could suggest such an addition. > > This works perfectly as is in *-ts-modes. At least for modes where > syntax-table is set correctly. I don't think there's a reason to enable > treesit.el capabilities, unless there's a case where this doesn't work. My point is that tree-sitter in many cases parses the program better than syntax-ppss. So if we can use its information about comments and strings, why not do that? It's exactly the same logic that Dmitry used: > + (if (or (nth 8 (syntax-ppss)) > + (re-search-forward comment-start-skip (line-end-position) t)) which falls back on regexp search if syntax-ppss cannot help. I'm asking why not try tree-sitter before we fall back on syntax-ppss or regexp search? Does that make sense? If not, why not? > If this ends up in master, should I backport some similar feature for > the *ts-modes? Why do we need this on the release branch? A general indent-or-fill-comment feature for all the progmodes didn't exist until now, which is why we intend to install this on master. From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 03:56:54 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 08:56:54 +0000 Received: from localhost ([127.0.0.1]:55380 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3Ci6-0005y7-35 for submit@debbugs.gnu.org; Thu, 08 Dec 2022 03:56:54 -0500 Received: from out2.migadu.com ([188.165.223.204]:20503) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3Ci2-0005y1-8p for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 03:56:53 -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=1670489809; 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=W1Wx3pUTS9rIdr667R3ChhTL//6u4UI+G7Zh/4fhrM0=; b=KAMath7JmkDIVdyU7vTfwVVu7/1MbxTcod0KK0EBobGRVmHy83Yn3ea/EpsQPsBW57QjEO NJRqDgZdLDfVhM/05gkk1CP92ao6/ZwpYDJFPhOPFfCn2FIgxz0F1vrqE8DV2jkucjBPEU 7UReLyPyxRA3TnHCRx906dTXCODVPY2b3yhgami8JusVbp4JUGNK2CrR43Hk7jbcq/xIP3 gd/z9rOGHxvEJcdbUClMldbXrr64FjGANr9wnG4afnBx6nCGWU+zDcDAOfUVr1Ak85qZBd H4o/L68vo6IqqUNL6p2kYtUA5npOI0cxu5I5DFl1IZ/5VPPPEu8hsdJ2++ZjNA== From: Theodor Thornhill To: Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <83r0xa2tc4.fsf@gnu.org> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> Date: Thu, 08 Dec 2022 09:56:44 +0100 Message-ID: <87zgbyxohf.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: casouri@gmail.org, larsi@gnus.org, 59662@debbugs.gnu.org, monnier@iro.umontreal.ca, dgutov@yandex.ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> From: Theodor Thornhill >> Cc: casouri@gmail.com, 59662@debbugs.gnu.org, casouri@gmail.org >> Date: Thu, 08 Dec 2022 09:11:28 +0100 >> >> > Bonus points for adding something that could use treesit.el >> > capabilities, when those are available, instead of syntax-ppss, to >> > determine when we are in a comment or in a string. Or maybe Theo or >> > Yuan could suggest such an addition. >> >> This works perfectly as is in *-ts-modes. At least for modes where >> syntax-table is set correctly. I don't think there's a reason to enable >> treesit.el capabilities, unless there's a case where this doesn't work. > > My point is that tree-sitter in many cases parses the program better > than syntax-ppss. So if we can use its information about comments and > strings, why not do that? It's exactly the same logic that Dmitry > used: > Something like this? If we add a defvar such as the below, similar to treesit-defun-type-regexp we can use that in the function below: ``` (defvar-local treesit-comment-type-regexp nil "A regexp that matches the node type of comment nodes. For example, \"(line|block)_comment\". ") (defun prog-reindent-defun (&optional argument) "Refill paragraph or reindent the definition that the point is on. If the point is in a string, or in a comment, or there is a comment on the current line, fill the paragraph that the point is in or is on the same line. Otherwise, reindent the definition around or below point." (interactive "P") (save-excursion (if (or (and (treesit-available-p) (treesit-ready-p (treesit-language-at (point))) (string-match-p treesit-comment-type-regexp (treesit-node-type (treesit-node-at (point))))) (nth 8 (syntax-ppss)) (re-search-forward comment-start-skip (line-end-position) t)) (if (memq fill-paragraph-function '(t nil)) (lisp-fill-paragraph argument) (funcall fill-paragraph-function argument)) (end-of-defun) (let ((end (point))) (beginning-of-defun) (indent-region (point) end))))) ``` The error handling here is naive, but is this something in the line of what you're suggesting? If so, I can tweak the error handling and create a patch for it? Unless you want to do that, Dmitry >> + (if (or (nth 8 (syntax-ppss)) >> + (re-search-forward comment-start-skip (line-end-position) t)) > > which falls back on regexp search if syntax-ppss cannot help. I'm > asking why not try tree-sitter before we fall back on syntax-ppss or > regexp search? > > Does that make sense? If not, why not? > It does. >> If this ends up in master, should I backport some similar feature for >> the *ts-modes? > > Why do we need this on the release branch? A general > indent-or-fill-comment feature for all the progmodes didn't exist > until now, which is why we intend to install this on master. Yeah, sure :-) Theo From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 04:08:30 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 09:08:30 +0000 Received: from localhost ([127.0.0.1]:55440 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3CtK-000660-9t for submit@debbugs.gnu.org; Thu, 08 Dec 2022 04:08:30 -0500 Received: from out-213.mta0.migadu.com ([91.218.175.213]:36651) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3CtB-00065u-Qq for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 04:08:28 -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=1670490499; 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=1WWCf2pmkCA5F3PnFK5XhLThFMtYdfLFdKaFpmR1NOo=; b=iUDGxzlOX7WwH8AcNtv4Vl0KxexQZyVQLyJHXNU8XuJkix1XUHiXt5iqNpzlGFL7lGi8B4 TYAJln/TSnr4ilH9GIDoIJZwPzVfIdXht9kUI0el1EhMZve+dWEW9vEs/1FWHnMGQ+L/5z 7/Vwd23FElcjPKSEezrVufRx2C3djGg2jNSD1XDcGjXVpRhCA8V/K8Rh/ggRsxeshn+Y9o wsmVee5LTOunosNLw8GQHQvzfRf0fY9FZj5wJ1q83SbJXYoGYxuqyRIJXLDtax2pl92Rod aABOHSySvJ+gD8WBW8YxWutk4o6b/7Q1pC7d7SQAl2SEz+C7J+OniAGtz4ZpCA== From: Theodor Thornhill To: Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <87zgbyxohf.fsf@thornhill.no> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> Date: Thu, 08 Dec 2022 10:08:17 +0100 Message-ID: <87wn72xny6.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, Yuan Fu , monnier@iro.umontreal.ca, dgutov@yandex.ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Resending because I removed the wrong email to Yuan... Theodor Thornhill writes: > Eli Zaretskii writes: > >>> From: Theodor Thornhill >>> Cc: casouri@gmail.com, 59662@debbugs.gnu.org, casouri@gmail.org >>> Date: Thu, 08 Dec 2022 09:11:28 +0100 >>> >>> > Bonus points for adding something that could use treesit.el >>> > capabilities, when those are available, instead of syntax-ppss, to >>> > determine when we are in a comment or in a string. Or maybe Theo or >>> > Yuan could suggest such an addition. >>> >>> This works perfectly as is in *-ts-modes. At least for modes where >>> syntax-table is set correctly. I don't think there's a reason to enable >>> treesit.el capabilities, unless there's a case where this doesn't work. >> >> My point is that tree-sitter in many cases parses the program better >> than syntax-ppss. So if we can use its information about comments and >> strings, why not do that? It's exactly the same logic that Dmitry >> used: >> > > Something like this? If we add a defvar such as the below, similar to > treesit-defun-type-regexp we can use that in the function below: > > ``` > (defvar-local treesit-comment-type-regexp nil > "A regexp that matches the node type of comment nodes. > > For example, \"(line|block)_comment\". ") > > > (defun prog-reindent-defun (&optional argument) > "Refill paragraph or reindent the definition that the point is on. > > If the point is in a string, or in a comment, or there is a > comment on the current line, fill the paragraph that the point is > in or is on the same line. > > Otherwise, reindent the definition around or below point." > (interactive "P") > (save-excursion > (if (or (and (treesit-available-p) > (treesit-ready-p (treesit-language-at (point))) > (string-match-p > treesit-comment-type-regexp > (treesit-node-type (treesit-node-at (point))))) > (nth 8 (syntax-ppss)) > (re-search-forward comment-start-skip (line-end-position) t)) > (if (memq fill-paragraph-function '(t nil)) > (lisp-fill-paragraph argument) > (funcall fill-paragraph-function argument)) > (end-of-defun) > (let ((end (point))) > (beginning-of-defun) > (indent-region (point) end))))) > ``` > > The error handling here is naive, but is this something in the line of > what you're suggesting? If so, I can tweak the error handling and > create a patch for it? Unless you want to do that, Dmitry > >>> + (if (or (nth 8 (syntax-ppss)) >>> + (re-search-forward comment-start-skip (line-end-position) t)) >> >> which falls back on regexp search if syntax-ppss cannot help. I'm >> asking why not try tree-sitter before we fall back on syntax-ppss or >> regexp search? >> >> Does that make sense? If not, why not? >> > > It does. > >>> If this ends up in master, should I backport some similar feature for >>> the *ts-modes? >> >> Why do we need this on the release branch? A general >> indent-or-fill-comment feature for all the progmodes didn't exist >> until now, which is why we intend to install this on master. > > Yeah, sure :-) > > Theo From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 05:39:59 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 10:39:59 +0000 Received: from localhost ([127.0.0.1]:55946 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3EJp-00006B-DG for submit@debbugs.gnu.org; Thu, 08 Dec 2022 05:39:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39554) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3EJl-000065-Gc for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 05:39:56 -0500 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 1p3EJd-0007IZ-GW; Thu, 08 Dec 2022 05:39:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=kLftWve1EDFss/df1QbMkGn5NiL5zVoNX1QsTJXkSSo=; b=roqqJu+cAdp1 Y28Llmy1248k0A4hwDhYIIb3IGyD9hFpmsfhPlaC8ZzMcqw+gDjWEAprN1aBSZNRGfg661mXVpqC0 rhlHZTJlvwHhoiiXqIgi394qtPdZ9oxVM8+ZNBnhfql53md40yIK4aQ9a+N5Q/p3+rRFDUlOOj/tY xTEFlQdjo12XmfCUtrUDyx6q4/n4qk5QfmZvHW1DwlEo+gKiFdbPfnfN8ywbu/tOBDJYEYGItUsxG AIzONgRzj7ubfmPeDv4gBwk+qcnX4btk5Y1oivVUMbZFmetV+Bz3KJjQEnmFxnL/5fkyqIFOmlkaW Jk5HvybFAYjbWpni3UnDKQ==; 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 1p3EJc-00025L-Ps; Thu, 08 Dec 2022 05:39:45 -0500 Date: Thu, 08 Dec 2022 12:39:34 +0200 Message-Id: <83o7se2n89.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: <87zgbyxohf.fsf@thornhill.no> (message from Theodor Thornhill on Thu, 08 Dec 2022 09:56:44 +0100) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Theodor Thornhill > Cc: dgutov@yandex.ru, monnier@iro.umontreal.ca, larsi@gnus.org, > 59662@debbugs.gnu.org, casouri@gmail.org > Date: Thu, 08 Dec 2022 09:56:44 +0100 > > Eli Zaretskii writes: > > > My point is that tree-sitter in many cases parses the program better > > than syntax-ppss. So if we can use its information about comments and > > strings, why not do that? It's exactly the same logic that Dmitry > > used: > > > > Something like this? If we add a defvar such as the below, similar to > treesit-defun-type-regexp we can use that in the function below: > > ``` > (defvar-local treesit-comment-type-regexp nil > "A regexp that matches the node type of comment nodes. > > For example, \"(line|block)_comment\". ") The intent is that major modes set this variable? SGTM. > (if (or (and (treesit-available-p) > (treesit-ready-p (treesit-language-at (point))) I'd imagine that this kind of test should have an API, so the treesit-ready-p call should not be made explicitly? Yuan, WDYT? Also, isn't it enough to check whether the buffer has a tree-sitter parser or something? > The error handling here is naive, but is this something in the line of > what you're suggesting? Yes, it is what I had in mind, but see above. From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 06:09:23 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 11:09:23 +0000 Received: from localhost ([127.0.0.1]:56097 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3EmJ-0000SF-5J for submit@debbugs.gnu.org; Thu, 08 Dec 2022 06:09:23 -0500 Received: from out-9.mta0.migadu.com ([91.218.175.9]:52232) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3EmH-0000S9-5v for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 06:09:22 -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=1670497760; 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=5ClDanvEjBUliHSfkh66v6WP5Imn4tlkJQndJt+k7jA=; b=O6GYJ5baJKQxpLjrB/uj5xYei3ApZiPrTYXHu2g0DfYP9pK3etZIXSlalnsQiSijSGbE9T ayxxGzSUkzQ+uy5BXRc4gr/NamWERqFLHbq2Uo4XZStLN8lEUj/m/rokL+KpgJZhfppR/w cYWTNB6API6bZEfF8dWG67SYWEDHvEdMzq60tZhlXERhhbzvx56HrFuLU9wisFl9jsbdIM UkLm7eJrkq3MsmWawZe0MUwROnIsk5SRVYkfOLy1pe8SWnTg8biknyn8f+K12VV26p3LyI MwelEfheEJjhpPG/LWGM+ir+X0zpj366+DI1WBlblwy29iiUY0u/wnd3SXZJmw== From: Theodor Thornhill To: Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <83o7se2n89.fsf@gnu.org> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <83o7se2n89.fsf@gnu.org> Date: Thu, 08 Dec 2022 12:09:18 +0100 Message-ID: <87tu269mox.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> From: Theodor Thornhill >> Cc: dgutov@yandex.ru, monnier@iro.umontreal.ca, larsi@gnus.org, >> 59662@debbugs.gnu.org, casouri@gmail.org >> Date: Thu, 08 Dec 2022 09:56:44 +0100 >> >> Eli Zaretskii writes: >> >> > My point is that tree-sitter in many cases parses the program better >> > than syntax-ppss. So if we can use its information about comments and >> > strings, why not do that? It's exactly the same logic that Dmitry >> > used: >> > >> >> Something like this? If we add a defvar such as the below, similar to >> treesit-defun-type-regexp we can use that in the function below: >> >> ``` >> (defvar-local treesit-comment-type-regexp nil >> "A regexp that matches the node type of comment nodes. >> >> For example, \"(line|block)_comment\". ") > > The intent is that major modes set this variable? SGTM. Yeah, that was the idea. > >> (if (or (and (treesit-available-p) >> (treesit-ready-p (treesit-language-at (point))) > > I'd imagine that this kind of test should have an API, so the > treesit-ready-p call should not be made explicitly? Yuan, WDYT? > > Also, isn't it enough to check whether the buffer has a tree-sitter > parser or something? > >> The error handling here is naive, but is this something in the line of >> what you're suggesting? > > Yes, it is what I had in mind, but see above. What about this? I changed it to make a point that we should fill if inside of a string or comment, and indent if inside a code block. We one such variable for each type, or in both as suggested below. ``` (defvar-local treesit-text-type-regexp nil "A regexp that matches the node type of textual nodes. For example, \"(line|block)_comment\" in the case of a comment, or \"string_literal\" in the case of a string.") (defun prog-reindent-defun (&optional argument) "Refill paragraph or reindent the definition that the point is on. If the point is in a string, or in a comment, or there is a comment on the current line, fill the paragraph that the point is in or is on the same line. Otherwise, reindent the definition around or below point." (interactive "P") (save-excursion (if (or (and (treesit-parser-list) (string-match-p treesit-text-type-regexp (treesit-node-type (treesit-node-at (point))))) (nth 8 (syntax-ppss)) (re-search-forward comment-start-skip (line-end-position) t)) (if (memq fill-paragraph-function '(t nil)) (lisp-fill-paragraph argument) (funcall fill-paragraph-function argument)) (end-of-defun) (let ((end (point))) (beginning-of-defun) (indent-region (point) end))))) ``` From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 06:38:35 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 11:38:35 +0000 Received: from localhost ([127.0.0.1]:56247 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3FEZ-0003Hv-5L for submit@debbugs.gnu.org; Thu, 08 Dec 2022 06:38:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41902) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3FEX-0003Hj-3x for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 06:38:33 -0500 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 1p3FEQ-0007ag-I8; Thu, 08 Dec 2022 06:38:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=S6wl/MuS6TdF9Dhdz7EEDfP0gEJ5OZBaRPU5B1daoCE=; b=rufOM8Tz+HYL hUy5gXNFvX4Qgr8OzLG9sI8kHbeNEcZvDqw7VVZHiIBy7ItniAYWFoycMzJi/GB4T9giKSC+hqOUx NQrxxnIFDaaPInzSkS0R1nQxUfRNqSzr3NOQSJt8aj3cJ6LL6DmdVlnJde8iVYAuQZ6u39MSYhTgt H2rFYJS5N30/GccOdv72CXtu5kAynmPhR7CJZmTLxNJeT+I6/wk3bBUy9ZP50hboalVdcchIOBTBb 1sXdZ80bcCz11PTNiR4XP0pU7iMP1ev4tKsLyoVyr/Hv8cjKi0DHThyL8MCyJk8rMRU9AHN9JIelJ gzXVE++WoMsWl7hqtmSbNg==; 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 1p3FEP-0002FZ-Le; Thu, 08 Dec 2022 06:38:25 -0500 Date: Thu, 08 Dec 2022 13:38:16 +0200 Message-Id: <83fsdq2kif.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: <87tu269mox.fsf@thornhill.no> (message from Theodor Thornhill on Thu, 08 Dec 2022 12:09:18 +0100) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <83o7se2n89.fsf@gnu.org> <87tu269mox.fsf@thornhill.no> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Theodor Thornhill > Cc: dgutov@yandex.ru, monnier@iro.umontreal.ca, larsi@gnus.org, > 59662@debbugs.gnu.org, casouri@gmail.com > Date: Thu, 08 Dec 2022 12:09:18 +0100 > > What about this? I changed it to make a point that we should fill if > inside of a string or comment, and indent if inside a code block. We > one such variable for each type, or in both as suggested below. I'll defer to Dmitry on that. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 09:18:28 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 14:18:28 +0000 Received: from localhost ([127.0.0.1]:57065 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3HjH-0003UN-Sq for submit@debbugs.gnu.org; Thu, 08 Dec 2022 09:18:28 -0500 Received: from mail-wr1-f48.google.com ([209.85.221.48]:46861) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3HjG-0003UH-7H for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 09:18:26 -0500 Received: by mail-wr1-f48.google.com with SMTP id h11so1750872wrw.13 for <59662@debbugs.gnu.org>; Thu, 08 Dec 2022 06:18:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=md3AoaFZWUIlkeTlVfvjIICvUSZOAtlGdQg0MYgohAQ=; b=I5grnAcqaM5Cpl2H4wlhkyzAMo+MJdmz/Jaomytn870xB9PIwJUzKzLEFPj6v95Am0 SiSa23BkJTNo3dRRbeF8V4Q6kSpBcd2LE+29OWCjjsviJaP1F9TNicABKDRNgwVfMn7Z M9PyvWbIv0mmjZM8zWBXdkX0KTvGR/Qg2tYil69MyRJblqFY3XhE+iu3AZ13eplu6IHa xF2y3jwKx3a5Dd9uLlcZwoU61bciWyXQxyJAQbGYgIpBytdp4njdIuhdYEICv1YhOTET WWpOV1GGSUcVl1ayM/8G+iuMcvfzelxGDVzZreY+m0acgZfximE266Ono9bmW/U9BvS6 K5UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=md3AoaFZWUIlkeTlVfvjIICvUSZOAtlGdQg0MYgohAQ=; b=1DfLysRuHcBaL9ktMIyw7FdAGgqXF3MMCl/gA93+iDFoTBFkv56v+k7OhTZ5Q7TZrq z51+Bvbe3mCQukw97JHmcPmz5e6dG7FlIK99qj/fe+HzYgJc4VkG9BxI3UJAYJvSRpHQ Zv6900GC58IF8yDjyahhLiKfAWncWF8CAc779/nf/z6igN1K0zzY0zxqildyTTz7Y1et BgnXb0HMC2XjOp9Cn9X4Wv1unUxvQIegycq61Gseyx2Y6kKGuKhVjSmFjcpkwpc8BM+u aDaCqgpIglwAcI82/D0YY3wZHHMAFcu/IUODDUjKksiBhSx8lMcFbUJPETPw2ERU0gXu DTkQ== X-Gm-Message-State: ANoB5pkzfP+6SYSWXSZrO5CCmhocZGWj6BMlh5yHReP6QakSZv4sKfvg hFW0wOpqX5xRSzNBgi/HrLI= X-Google-Smtp-Source: AA0mqf7wrdasQuMfPUGG8w1hBH9X2sTpos6v07dlhrZJaOr+JNF56hX52cuxq9DGofaTzh3QnCqZHQ== X-Received: by 2002:a05:6000:83:b0:242:fd7:285f with SMTP id m3-20020a056000008300b002420fd7285fmr1528674wrx.45.1670509100137; Thu, 08 Dec 2022 06:18:20 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id a16-20020a5d4570000000b00242109cf587sm22488613wrc.28.2022.12.08.06.18.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Dec 2022 06:18:19 -0800 (PST) Message-ID: Date: Thu, 8 Dec 2022 16:18:17 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US To: Theodor Thornhill , Eli Zaretskii References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> From: Dmitry Gutov In-Reply-To: <87zgbyxohf.fsf@thornhill.no> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, monnier@iro.umontreal.ca, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 08/12/2022 10:56, Theodor Thornhill wrote: > (if (or (and (treesit-available-p) > (treesit-ready-p (treesit-language-at (point))) > (string-match-p > treesit-comment-type-regexp > (treesit-node-type (treesit-node-at (point))))) I was kind of hoping that sometime in the near future our tree-sitter code would somehow plug into syntax-ppss (maybe via advice or etc) to provide the same results faster. Or that we'd add similar helpers which would dispatch to either syntax-ppss or tree-sitter, depending on whether the latter is enabled and working. The first approach will be more compatible for third-party code to use right now; the second will probably be more powerful. We might even do both. As a result, a lot of functions won't have to reimplement the quoted part. Inside, and (more importantly) outside Emacs core. So my preference would be to check in the implementation as-is (if everybody agrees with the behavior), and then migrate it to new helpers (in case plugging into syntax-ppss won't be automatic). But I don't really mind the code you posted, if somebody (e.g. Eli) is going to insist on it. It just doesn't seem critical from the performance POV, and the variable treesit-comment-type-regexp seems to be a little out of place. But then again, if the helpers will be put in prog-mode.el, the var will be there as well. From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 09:22:44 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 14:22:44 +0000 Received: from localhost ([127.0.0.1]:57089 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3HnP-0003XM-QP for submit@debbugs.gnu.org; Thu, 08 Dec 2022 09:22:43 -0500 Received: from mail-wr1-f53.google.com ([209.85.221.53]:40635) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3HnN-0003XE-JR for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 09:22:41 -0500 Received: by mail-wr1-f53.google.com with SMTP id m14so1789675wrh.7 for <59662@debbugs.gnu.org>; Thu, 08 Dec 2022 06:22:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=0fTz/sIH2QQAcbXvjAQq1bewNsSBfZjhXGKE3AbvLKE=; b=gHkikmGYwaAjV8kY6CeXlqWUBUXTEK8vRw1RCTndJRv9amuvLOpyGcvd9DQPGmUPea NcFK08EzwBzUGZHGHOUO6KIGNehm3Apnsn8r4zB+f8WB1rNBnGOd8+rI3o6qu3l/OeqR 2I+avgJkB6vNb9UivP8c8YeQS8eR5O8N0WfZx3HQVfq4+G5ggChj3TWBGAOKh3M+hgO+ +r3AAVSJO69I62Mt0vtqO1R4yYwDdgxWAjFqpI2Tv0vPd23neKGthcaqRILaA5eYzZdY DdiB3Xqfgu/Mmaw7YSIzjW9Ah9lIHLesCBIDdg85Q86tlKdZ718gjXpLadCd7lkWCFof cx8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0fTz/sIH2QQAcbXvjAQq1bewNsSBfZjhXGKE3AbvLKE=; b=YuQBazib2KuvhHSGqxv022yPaccIPDyeG0EsQeIyCrL8RlvZutlCwzn9bvNl2aX2lE 9f3US5xpD3ht+13GwdM8LmBdb3HlGfEm0zXxV7znXOjCB9aNjlu0rW9x2rg+cvf8WFFC NhQ6UwXvxXwsKdcJVcl8e1XoPnFaJ+YQqHvTAJ48f0L1/i3xt1hHXOdN95nECqGGClxj R/DRTbQ0wNOxEfEGWf9aULW2RW1svyWqgnYL3jlIQzmqPnDVlinCBp7UpUd/lqPhsDLM eEgKq1zoPZ4zUSsC7uaKVRVQ6mBntE2AFufNwSPl/dfG65XIFAylEsayQ13TGdhUPHeC vHPg== X-Gm-Message-State: ANoB5plpZywZ4iOARP6Uszr4xw/joOLEdq0oXbbyvJ+sFOBbgC3PgDeR 5cd70D5StdGqmRZuu7wFJ84= X-Google-Smtp-Source: AA0mqf6K03r78mPf2XNXDUPEyNu0r2vMfxRTfg8YObqbU7iJAg7focLDOIqjJD4w44yco/rio6svWg== X-Received: by 2002:a5d:4481:0:b0:232:be5a:f580 with SMTP id j1-20020a5d4481000000b00232be5af580mr1548852wrq.10.1670509355933; Thu, 08 Dec 2022 06:22:35 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id l7-20020a5d4107000000b00242246c2f7csm22334490wrp.101.2022.12.08.06.22.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Dec 2022 06:22:35 -0800 (PST) Message-ID: <34c2b5b5-3312-066e-50f4-2aa776d0273f@yandex.ru> Date: Thu, 8 Dec 2022 16:22:33 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US To: Theodor Thornhill , Eli Zaretskii References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <83o7se2n89.fsf@gnu.org> <87tu269mox.fsf@thornhill.no> From: Dmitry Gutov In-Reply-To: <87tu269mox.fsf@thornhill.no> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 08/12/2022 13:09, Theodor Thornhill wrote: > What about this? I changed it to make a point that we should fill if > inside of a string or comment, and indent if inside a code block. We > one such variable for each type, or in both as suggested below. Could you rephrase maybe? I'm not seeing the difference. From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 09:24:33 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 14:24:33 +0000 Received: from localhost ([127.0.0.1]:57100 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3HpB-0003Ym-6g for submit@debbugs.gnu.org; Thu, 08 Dec 2022 09:24:33 -0500 Received: from mail-wr1-f52.google.com ([209.85.221.52]:39815) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3HpA-0003Yf-BK for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 09:24:32 -0500 Received: by mail-wr1-f52.google.com with SMTP id h7so1801748wrs.6 for <59662@debbugs.gnu.org>; Thu, 08 Dec 2022 06:24:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=W4r40NGIIT8uhUdmEC1RdvZ5tnp+4/vEjdH8BG0aqgc=; b=T7aleev76364cmPez7LkZXmkRvyzz2LrIrY1/dZi1+4i6z7cGCNiEo/ir3VSmo436L MoRzS6gAyx+gHoovTCeJHxFLwjcKT6Hdm+szwA65ojgjwzQJHWvj4ozWnIgs0UYTbGJ6 MkFXCCBcSrSFJ1AzDobtzPwjbRWK+vtOuX4yhDo4nS+kgmQ/Y8CcgtB4oiJye4fJFHNR b/6GdDtbYBYW+XPupas8RG+uW+asBliPmTBGkfyKDmQhck3rVOFR6n06GN6Uvq0EgfhP o5JjuTJzAlM4EogvSWLB/+q2pxjsiCU7XpW7itEz9HeOuoKmG0W+m+/dqYlPnTWOtvd3 3Nfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=W4r40NGIIT8uhUdmEC1RdvZ5tnp+4/vEjdH8BG0aqgc=; b=kHJq8cFF+lDIL/8ia1DQEAtxa2GikZA0F7rukl/KkC1dqRWKnF8n5xMuny273S9hJg baIYwl5LU1aS4atM1jxTruTN/BiQVtxg3NVpnETAUE6063j1KA3bTFUsgB5dSXjLKtkr MczYgIfkPrZYIp1akRIkWXGbw31aXSPQ9Rr2SfrtseZxkFczYP6TZhvbssS5obPdz5kB v61SuGVdkQS/zLJI4+ad1QYabjU4Jcj3SKw4lpqy1uB6PCYhHitLCp73uJKH8EdxZSYS LJrgocUKPyW4G6QeA045bpK7LyQuamhaunCpJbB2pDlur+eKg8YvL0WQwjJKP2hNQCR7 ESbQ== X-Gm-Message-State: ANoB5pnwkihfRcT2zIJrlpth/jHHK9CeUUtQh0GpdnydxzaJryY3ewj3 ZXSzZm5SYbK89rIYS2lTz4k= X-Google-Smtp-Source: AA0mqf6gBe744plBlyrBhK9TBFYjU4pxXCdlDpa8bdPMerv+4BElG0vAsN1djSHK8IpKUq5Pmlj4BA== X-Received: by 2002:a5d:6291:0:b0:242:5b1f:3dcf with SMTP id k17-20020a5d6291000000b002425b1f3dcfmr1595449wru.63.1670509466546; Thu, 08 Dec 2022 06:24:26 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id z8-20020adfdf88000000b002258235bda3sm22261647wrl.61.2022.12.08.06.24.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Dec 2022 06:24:26 -0800 (PST) Message-ID: Date: Thu, 8 Dec 2022 16:24:24 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US To: Eli Zaretskii , Stefan Monnier , Lars Ingebrigtsen References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> From: Dmitry Gutov In-Reply-To: <83y1ri2wnj.fsf@gnu.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: casouri@gmail.com, 59662@debbugs.gnu.org, theo@thornhill.no, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 08/12/2022 09:16, Eli Zaretskii wrote: > I'm okay with installing this on master, but please rename the new > function to something like prog-fill-reindent; the "fill" part should > appear in the name, to explain why we have both prog-indent and this > function. Sure. prog-indent-sexp is fairly different, though, so it wouldn't be out of the question to have both commands, even if prog-reindent-defun didn't refill. > Also, a NEWS entry and some addition to the "Multi-line Indent" node > of the Emacs user manual would be nice. I suppose. From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 09:54:16 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 14:54:16 +0000 Received: from localhost ([127.0.0.1]:57241 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3IHv-0003mk-GB for submit@debbugs.gnu.org; Thu, 08 Dec 2022 09:54:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52992) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3IHt-0003me-H4 for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 09:54:14 -0500 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 1p3IHn-0005q2-Fk; Thu, 08 Dec 2022 09:54:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=0SbQ3ZNH3C1+HMCikcgC1di1agCu/19k0iaBI/zzCjI=; b=CohnO3AsqTc+ jqWR72KvAj5+vdCufw53KMxLsezqXsIsW14PuI3JkWdfQnWm7X8sFFJORcLdRmKIRYwx1rPDw/ZZ0 80NBedr8SaaDDG2dQCtzYUZCZ0b14pzUIIXP9yFjg0ZwQ0NXTTw7LRMP130FIj1o3EV4HdRvYinYD 7sWVpBZSWvMEIwc75N5gO0tiwXrpVbG4q4kLCDAEyKr+A/gIobTsctJxuHjyckmEJF74/rKoKeR3c b7CNXto0ZLUMFbMo8R5SoTTiXfGVeNE/egtyddweetLVIszLmUW80ApCh7rPtMaXlPVnKSa1024bm wuqanjUISixTz6b/wuJeCg==; 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 1p3IHj-0005iM-JU; Thu, 08 Dec 2022 09:54:07 -0500 Date: Thu, 08 Dec 2022 16:53:54 +0200 Message-Id: <837cz22bgd.fsf@gnu.org> From: Eli Zaretskii To: Dmitry Gutov In-Reply-To: (message from Dmitry Gutov on Thu, 8 Dec 2022 16:18:17 +0200) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, theo@thornhill.no, monnier@iro.umontreal.ca, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Thu, 8 Dec 2022 16:18:17 +0200 > Cc: monnier@iro.umontreal.ca, larsi@gnus.org, 59662@debbugs.gnu.org, > casouri@gmail.org > From: Dmitry Gutov > > On 08/12/2022 10:56, Theodor Thornhill wrote: > > (if (or (and (treesit-available-p) > > (treesit-ready-p (treesit-language-at (point))) > > (string-match-p > > treesit-comment-type-regexp > > (treesit-node-type (treesit-node-at (point))))) > > I was kind of hoping that sometime in the near future our tree-sitter > code would somehow plug into syntax-ppss (maybe via advice or etc) to > provide the same results faster. It is too early to consider practical code along these lines, we don't have enough experience with tree-sitter. I'm not even sure it can be easily factored into the same categories as syntax-ppss uses. IMO, the way to move to a unified handling is to use tree-sitter wherever we can, originally as special-cased code, and later refactor that into generalized APIs, when we know more about how to define and use them. > So my preference would be to check in the implementation as-is (if > everybody agrees with the behavior), and then migrate it to new helpers > (in case plugging into syntax-ppss won't be automatic). > > But I don't really mind the code you posted, if somebody (e.g. Eli) is > going to insist on it. It just doesn't seem critical from the > performance POV, and the variable treesit-comment-type-regexp seems to > be a little out of place. But then again, if the helpers will be put in > prog-mode.el, the var will be there as well. I don't insist, but it sounds like the logical thing to do. So unless you feel strongly against that, I'd say let's add that part. This is, after all, an experiment, so let's experiment. From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 09:58:59 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 14:58:59 +0000 Received: from localhost ([127.0.0.1]:57265 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3IMV-0003p2-DA for submit@debbugs.gnu.org; Thu, 08 Dec 2022 09:58:59 -0500 Received: from out2.migadu.com ([188.165.223.204]:35820) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3IMS-0003ow-Vc for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 09:58:58 -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=1670511534; 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=8yebdnKLnbhRIEI5sLDHjM1BW1YKMpJW/TDSpBi6l5Q=; b=ZeLNLQ0uXmjAWd6oYxaDcA6/DD9rQD74fQY9OMUKDUUPfrYXbZRVh84Zf4SvIev7yYvnHS xISBuuHiw+2KzGg1nQk7pgm7amLzdEy9GQcIFvQqFFa/KFTYvboI7CDtVMPIM4xx7boNok wt1NlaDlhWBsbxhIb8C72aXFUOCmS0Aa5sXyTHiWz3gxyjGNqNDABrP8gFpY9JBZ1KJw1K QmvuUYQO+JtGgfoYPVk8P7i9QeqNwL3JgUJKjF+VQZhEQHF6tpHGrukj3r6iDDgsoccpvm 0TKxkeKq2x1nnhPEMLKG4rFFWa13Dc5OXkoqV4nImNo1eNfJHwhO/sH8lrBUIw== From: Theodor Thornhill To: Dmitry Gutov , Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <34c2b5b5-3312-066e-50f4-2aa776d0273f@yandex.ru> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <83o7se2n89.fsf@gnu.org> <87tu269mox.fsf@thornhill.no> <34c2b5b5-3312-066e-50f4-2aa776d0273f@yandex.ru> Date: Thu, 08 Dec 2022 15:58:52 +0100 Message-ID: <87k032c577.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Dmitry Gutov writes: > On 08/12/2022 13:09, Theodor Thornhill wrote: >> What about this? I changed it to make a point that we should fill if >> inside of a string or comment, and indent if inside a code block. We >> one such variable for each type, or in both as suggested below. > > Could you rephrase maybe? I'm not seeing the difference. In the first example I made the variable specific to comments. But filling should work on everything that's considered text, IIUC. So if the variable refers to both the regex needs to accommodate strings and comments. That will in turn make it less useful if we want to find comments specifically, or strings specifically. so we could have both 'treesit-comment-regexp' and 'treesit-string-regexp' and match on '(or treesit-comment-regexp treesit-string-regexp)' in this particular case. Not really sure if that made more sense. From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 10:38:06 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 15:38:06 +0000 Received: from localhost ([127.0.0.1]:57463 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3IyL-0004CU-Om for submit@debbugs.gnu.org; Thu, 08 Dec 2022 10:38:05 -0500 Received: from mail-wm1-f47.google.com ([209.85.128.47]:53862) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3IyK-0004C5-Ki for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 10:38:04 -0500 Received: by mail-wm1-f47.google.com with SMTP id n7so1339633wms.3 for <59662@debbugs.gnu.org>; Thu, 08 Dec 2022 07:38:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=Vsjtq6sZY8yHirZmrsQ1ZoUSTz07omZPWpe7RbxX9VY=; b=B31z2AGCphABNttHXARw8xSu8h3AFxJ6Lzk2k47F2Q56D6eutSHiBFyvmPYm85/ZIW bWcA8wvbYHbDD2MAgVg88S0tXI6RpUy4gtDE77aB0mqFANrEuuISJz7Fq8U7w3Ifwl4p WCH492BV4XsSc99+HpVW6H/FQP+VkI7jj5EhLBHr5ulO3tCO723XZ5IqM7MWOSLfCC2L EFrSD0ThyUHQc+n4ysv2Eql40KocJN+bTFAp5KugwjC7tbKA9oJj2X0n2/SSnajYNrmr 3SqKHB6C1uvHjj766xp/dErcU8AhSwMpTmUW4ZITuzxaQL34696L/74dWUrm+Cw7POcr PIAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Vsjtq6sZY8yHirZmrsQ1ZoUSTz07omZPWpe7RbxX9VY=; b=eZy0A6PvQxrJCxGilwxKQJm++/7LZkfgO1vXy5uqMa3qkCwZujHoQXMseUuIKOcKFw LDjZ5/J6qrfvbydifOUa/VCaD7KAxZWYJ1TOaBUy7iqIDwhmol5LVKI1Q5LnU/eSCFxX eXR5U1LL0rRwNAYAeudDUrKK8qDbkvvxneYh5eRRqiRVtBjfFi7MrtByjCGnKXBFEN7N A/4pkoO3OaSC3RyBFvTRmlxYaNNPncJvqmZpiIaKy9F6kEx5N53yD//GUWO/20ZgHN2V w+fmvY+LsbCqjp4wr4+XDj96b8XfLnQViwocRRbjpWQN5fS6aXpmMrREohJbePrbXZzl t+BA== X-Gm-Message-State: ANoB5pmOz/cV8SUaBg0wX+MWvgNEUdORb+CQT9OrOhS0xbFKQ3CKKbhu Rxl2p3tuVB0sr9nBnyuyUHo= X-Google-Smtp-Source: AA0mqf5SEKj650i8WODGs5di/6XrA6iBYBewOfF1Rxn1lXLE2m0TmPpP7/fsz77BHEy0eDf0T+6Ilw== X-Received: by 2002:a1c:7c15:0:b0:3cf:7197:e67c with SMTP id x21-20020a1c7c15000000b003cf7197e67cmr2340089wmc.25.1670513878629; Thu, 08 Dec 2022 07:37:58 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id g6-20020a05600c4ec600b003cf57329221sm6426187wmq.14.2022.12.08.07.37.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Dec 2022 07:37:57 -0800 (PST) Message-ID: <7c38aeac-4cda-e729-cbe8-0ac44d725abe@yandex.ru> Date: Thu, 8 Dec 2022 17:37:55 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US From: Dmitry Gutov To: Eli Zaretskii , Stefan Monnier , Lars Ingebrigtsen References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: casouri@gmail.com, 59662@debbugs.gnu.org, theo@thornhill.no, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 08/12/2022 16:24, Dmitry Gutov wrote: > On 08/12/2022 09:16, Eli Zaretskii wrote: >> I'm okay with installing this on master, but please rename the new >> function to something like prog-fill-reindent; the "fill" part should >> appear in the name, to explain why we have both prog-indent and this >> function. > > Sure. I think we'll need to cram the word "defun" in the name too, won't we? From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 10:44:13 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 15:44:14 +0000 Received: from localhost ([127.0.0.1]:57505 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3J4H-0004GN-CG for submit@debbugs.gnu.org; Thu, 08 Dec 2022 10:44:13 -0500 Received: from mail-wm1-f49.google.com ([209.85.128.49]:55222) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3J47-0004Ft-NN for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 10:44:11 -0500 Received: by mail-wm1-f49.google.com with SMTP id o15so1021952wmr.4 for <59662@debbugs.gnu.org>; Thu, 08 Dec 2022 07:44:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=LjHEHs58l1L9jE8QZlaqcfJn9I42R38MpdD8JR4lICI=; b=qKQiH9f3v1IZoljtAyyIsb8hPSmQm+UOPr0ey0z2IaDea9XpZo9LpZMGMzuytuiRrq 6DooZGgMQeqqpL5joPzascOfgw+qcZ72Gk1xT1s8JON5nGU/eZglUfZbj6uOyquXPh3p sXlMo2rZCm9imvh/LwHm0ZMXq2YzF7sy2LRpgOfOh80ZVTJqhzqyC6cEFiWlj2qCQH5u PQy0Fg+a8XCvmP2uJSWwf+nqytg+FcBcVwhgKwUKfc/ZioBqF/8nnrP5ImMXQgHhKzTn BDJkm9lgt7UXHdRCJ9KNFy7VA3l7JAwUR31V8j/1m+4YYkUYVZlBI4limedhz3+0sQse YMrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LjHEHs58l1L9jE8QZlaqcfJn9I42R38MpdD8JR4lICI=; b=fHxpcu8dhBXcMUgtrvA+rUoR9lfF2W6BsyxcXdKfiA4ymSISDlRCsf1o8rsFErMiRY 0ypqxlihgvX8dMfY89oSoQ2xqCnKkaptdNWtjQI3z05ln2Hc3OMfYmBzpJWWTD3zrupv amQNrnpqgn5t8XbzvcLEDPEtll9B9RnGhAJr3tbR7egXKVa3LyIcO1RK1mdxNapi0NPk TJ8dOhVFE0k5S6DrZCdK3KazYb7QqCU81uI4itF0b625lAkK7+EyQvYe/8W1loUjGrbi Egw9Lm6+5ALWBxVETiRWvv2zlVhOf+kUQMXQjYsuKDIL2AJxqKzzOdoIYjAB8iALPweo Jq0Q== X-Gm-Message-State: ANoB5plHsMI2GfY2q8t3WM06jwAuFvdRAXu9vWZXo4GQgGd0MYJ3IYtW pTyFvBc6/nnsNJFIkbydR1w= X-Google-Smtp-Source: AA0mqf5u7h3CKqeBY45A3yfeGUufht2b2JulSBxpio7S5vAu8z5WyNBQJptpdbsQ74pUftbZnRdSgg== X-Received: by 2002:a05:600c:354e:b0:3cf:5d41:b748 with SMTP id i14-20020a05600c354e00b003cf5d41b748mr2316584wmq.36.1670514236750; Thu, 08 Dec 2022 07:43:56 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id j42-20020a05600c1c2a00b003c6d21a19a0sm6339982wms.29.2022.12.08.07.43.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Dec 2022 07:43:56 -0800 (PST) Message-ID: Date: Thu, 8 Dec 2022 17:43:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US To: Eli Zaretskii References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> From: Dmitry Gutov In-Reply-To: <837cz22bgd.fsf@gnu.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, theo@thornhill.no, monnier@iro.umontreal.ca, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 08/12/2022 16:53, Eli Zaretskii wrote: >> Date: Thu, 8 Dec 2022 16:18:17 +0200 >> Cc: monnier@iro.umontreal.ca, larsi@gnus.org, 59662@debbugs.gnu.org, >> casouri@gmail.org >> From: Dmitry Gutov >> >> On 08/12/2022 10:56, Theodor Thornhill wrote: >>> (if (or (and (treesit-available-p) >>> (treesit-ready-p (treesit-language-at (point))) >>> (string-match-p >>> treesit-comment-type-regexp >>> (treesit-node-type (treesit-node-at (point))))) >> >> I was kind of hoping that sometime in the near future our tree-sitter >> code would somehow plug into syntax-ppss (maybe via advice or etc) to >> provide the same results faster. > > It is too early to consider practical code along these lines, we don't > have enough experience with tree-sitter. I'm not even sure it can be > easily factored into the same categories as syntax-ppss uses. I'm fairly certain that tree-sitter contexts could be "dumbed down" into syntax-ppss categories. But that's not the only way: another is to just use tree-sitter to find a "safe place" to call parse-partial-sexp from. That would give us the speed bump together with 100% backward compatibility. > IMO, the way to move to a unified handling is to use tree-sitter > wherever we can, originally as special-cased code, and later refactor > that into generalized APIs, when we know more about how to define and > use them. syntax-ppss is used in a lot of places. A "free" improvement like the above wouldn't hurt. >> So my preference would be to check in the implementation as-is (if >> everybody agrees with the behavior), and then migrate it to new helpers >> (in case plugging into syntax-ppss won't be automatic). >> >> But I don't really mind the code you posted, if somebody (e.g. Eli) is >> going to insist on it. It just doesn't seem critical from the >> performance POV, and the variable treesit-comment-type-regexp seems to >> be a little out of place. But then again, if the helpers will be put in >> prog-mode.el, the var will be there as well. > > I don't insist, but it sounds like the logical thing to do. So unless > you feel strongly against that, I'd say let's add that part. This is, > after all, an experiment, so let's experiment. I'm not going to object. Doubly so if somebody else wants to finish up the patch and commit it with NEWS and documentation updates. ;-) From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 10:47:07 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 15:47:07 +0000 Received: from localhost ([127.0.0.1]:57524 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3J75-0004Il-Fx for submit@debbugs.gnu.org; Thu, 08 Dec 2022 10:47:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44614) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3J73-0004IL-Ow for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 10:47:06 -0500 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 1p3J6w-0000k1-EV; Thu, 08 Dec 2022 10:46:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=CRKptxmQhTSfE96dXCQr+zbd376ObJPzbz7IECFBlDA=; b=FsxGE5Qv6yRT qAwrSOD8y1Ey4UJqgaQ3+2ANWi/zzr+NAQFVOfe8doJXdeuuFYKHeIOtakYNNCYdEU4TYu9MR0Pzg fGNZxZhqeXCY+BqTBDBV6fQ1mRErQmDe0kJ0OQAYsjkTp+m1JHLXZp8uw5IbuGJR2aiaH2R3SYHhW BudMxzo2jcEIbcNNBCe3DeYjqZdZli/OeeNOYOlVkF7+tOm+FNASXM8ljW/ip+OGIJdFbQKNFFVW7 DnoDeY20tqLnW/ebyK1HAw5oiE6Mzxocq5nQF9kTWiOL+0A5Gwiz5maD1MH3QqKymd0czfaXd/xck VZ0tPpQBaxOTQtPwI1hy0w==; 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 1p3J6j-0004QH-QC; Thu, 08 Dec 2022 10:46:58 -0500 Date: Thu, 08 Dec 2022 17:46:37 +0200 Message-Id: <83v8ml290i.fsf@gnu.org> From: Eli Zaretskii To: Dmitry Gutov In-Reply-To: <7c38aeac-4cda-e729-cbe8-0ac44d725abe@yandex.ru> (message from Dmitry Gutov on Thu, 8 Dec 2022 17:37:55 +0200) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <7c38aeac-4cda-e729-cbe8-0ac44d725abe@yandex.ru> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: casouri@gmail.com, 59662@debbugs.gnu.org, theo@thornhill.no, monnier@iro.umontreal.ca, larsi@gnus.org, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Thu, 8 Dec 2022 17:37:55 +0200 > From: Dmitry Gutov > Cc: casouri@gmail.com, 59662@debbugs.gnu.org, theo@thornhill.no, > casouri@gmail.org > > On 08/12/2022 16:24, Dmitry Gutov wrote: > > On 08/12/2022 09:16, Eli Zaretskii wrote: > >> I'm okay with installing this on master, but please rename the new > >> function to something like prog-fill-reindent; the "fill" part should > >> appear in the name, to explain why we have both prog-indent and this > >> function. > > > > Sure. > > I think we'll need to cram the word "defun" in the name too, won't we? I won't object to that. From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 11:06:36 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 16:06:36 +0000 Received: from localhost ([127.0.0.1]:57616 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3JPv-0004T5-Pm for submit@debbugs.gnu.org; Thu, 08 Dec 2022 11:06:36 -0500 Received: from mail-wm1-f54.google.com ([209.85.128.54]:34464) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3JPu-0004Sz-SX for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 11:06:35 -0500 Received: by mail-wm1-f54.google.com with SMTP id ay8-20020a05600c1e0800b003d0808d2826so4348356wmb.1 for <59662@debbugs.gnu.org>; Thu, 08 Dec 2022 08:06:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=p1ETjYNQF1Wcw2ITBu06KcxlOjnAY1FYnOK2RwmrbOk=; b=WUhSvipW7bd+R28BCisBxSecs+rbh7stS5sQpDuLlyhlWpYlToSEOfNOMMs+JGhL+o +maJjxWnWCA9RB6848qSYIDFjDbkv0dZD5qWaNZa/bMDQ5rjIbQD0VpbETHc64toBAkB OMBH8+6iZa3U+WzFZOflLt0K2zwMeCqfDqBZjqsfjT3r1n/HuPuG4+YP7WL6QUitVqs8 ekyxzUiRwC7HfRHmo0RQH+/0q4Yu46Olibum1JFtl2Nt0Z/seH+D+5AZ13UuRHasgNtW zHJ34fRzV+rXy3oWE/LgGObhjZ/Dh71lQGoYDJ2QY/dBLM0BTRB/Bu7zUeWgAmgX2wRT mSHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=p1ETjYNQF1Wcw2ITBu06KcxlOjnAY1FYnOK2RwmrbOk=; b=4CD6kw8H1hPBgjHuVPWnqmbVovDt0SRaAcne5Y9TbmsKEIs9gysB88umSlshGcE7ZA il+x3kL28FqNA5KWEMVMlhg62gW6HRMBQxJK9ShuiAtslixXiIndHV/9LIE6nb0xwxIb 3tMTE1MgzaXLSeWGaTZGT9xhHxSPdsHZb5zYI5xGMrCq1zVvc4mUkOFCmRxB8s+VVqtx stRP0ZnTdnVuzmuB07APdJl8Kg7pyuNTBbRf1pn8aSI1Ls3mPvZzKiYyccnazkfknKOD Q4Gr8GkqLOWOdCwSYukT+ddylzziqZylTd530UU/tD9rF7gc1eEHpWBbt/6W7HSdGAeH jYrg== X-Gm-Message-State: ANoB5pn0/0kmQ+AX71MxqOaNsuvW2iFiE7a+ADzGQlvCvztBEf875bbT pFY2nX3PiI3YGS4lyZ87RSU= X-Google-Smtp-Source: AA0mqf7jUlqLvMI+MTJEtUn036VXsZ+nVWkp3yKBZQpizrdXufOfI/8HQ4RwoaP7HpKN8KKcPjlFNA== X-Received: by 2002:a05:600c:3b8a:b0:3d1:f0f1:ceb4 with SMTP id n10-20020a05600c3b8a00b003d1f0f1ceb4mr2145655wms.19.1670515589103; Thu, 08 Dec 2022 08:06:29 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id i10-20020a1c540a000000b003d1f2c3e571sm5190839wmb.33.2022.12.08.08.06.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Dec 2022 08:06:28 -0800 (PST) Message-ID: <617cb890-b622-4f76-c446-f4c95c377cc5@yandex.ru> Date: Thu, 8 Dec 2022 18:06:26 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US To: Theodor Thornhill , Eli Zaretskii References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <83o7se2n89.fsf@gnu.org> <87tu269mox.fsf@thornhill.no> <34c2b5b5-3312-066e-50f4-2aa776d0273f@yandex.ru> <87k032c577.fsf@thornhill.no> From: Dmitry Gutov In-Reply-To: <87k032c577.fsf@thornhill.no> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 08/12/2022 16:58, Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > Dmitry Gutov writes: > >> On 08/12/2022 13:09, Theodor Thornhill wrote: >>> What about this? I changed it to make a point that we should fill if >>> inside of a string or comment, and indent if inside a code block. We >>> one such variable for each type, or in both as suggested below. >> Could you rephrase maybe? I'm not seeing the difference. > In the first example I made the variable specific to comments. But > filling should work on everything that's considered text, IIUC. So if > the variable refers to both the regex needs to accommodate strings and > comments. That will in turn make it less useful if we want to find > comments specifically, or strings specifically. so we could have both > 'treesit-comment-regexp' and 'treesit-string-regexp' and match on '(or > treesit-comment-regexp treesit-string-regexp)' in this particular case. > > Not really sure if that made more sense. Ah. So that was about the name of the variable. Looks good. Note that if the improvement which I described ever comes to life (hopefully), then the variable will probably need to be renamed/moved/multiplied again. From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 11:08:20 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 16:08:20 +0000 Received: from localhost ([127.0.0.1]:57627 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3JRc-0004U3-AZ for submit@debbugs.gnu.org; Thu, 08 Dec 2022 11:08:20 -0500 Received: from out2.migadu.com ([188.165.223.204]:52875) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3JRa-0004Tx-3I for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 11:08:18 -0500 Date: Thu, 08 Dec 2022 17:04:42 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1670515696; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qTUty4PhsfLiGovbLMlf7D0U7tZx2+nCtdQSlcI1Euc=; b=bsTWNJ7TbCBd8SM9d40OnXcARLeDaEtXPj2STFlA69lqrmJwVuJX3ZkNOoIYu1zlsaYmXM BArRJh0yXSdZ02D/fYDplSzaLJsFxYZHIHJyUVhYrJCxx45FY6pTD+ZPj5Lzl/IWshRbja G5Bh8Hn0qOAbfDeBmVkPJDPtt4fCW7rwW2Iw8IgRNZVNMJQRLhVf1A4xX5GJYfAXI9T2vz jHuo2t+7AOiRqSwePdHwPwAGeiz3C5UlQRovHMUNZHL+z0L8Nb7c4XTTgtLP+qgdOioUvk 3dOvRXYRbvJxBGQ2H7+LaE1fjS3/jkxkQJc18+hYsGB5gfwV3ePxDCN+uAE0HQ== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Theodor Thornhill To: Dmitry Gutov , Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> Message-ID: <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, monnier@iro.umontreal.ca, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > >syntax-ppss is used in a lot of places=2E A "free" improvement like the a= bove wouldn't hurt=2E > >>> So my preference would be to check in the , the var will be there as w= ell=2E >>=20 >> I don't insist, but it sounds like the logical thing to do=2E So unles= s >> you feel strongly against that, I'd say let's add that part=2E This is= , >> after all, an experiment, so let's experiment=2E > >I'm not going to object=2E > >Doubly so if somebody else wants to finish up the patch and commit it wit= h NEWS and documentation updates=2E ;-) I can finish up the patch if you don't want to :) Theo From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 11:23:27 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 16:23:27 +0000 Received: from localhost ([127.0.0.1]:57719 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3JgE-0006vM-UA for submit@debbugs.gnu.org; Thu, 08 Dec 2022 11:23:27 -0500 Received: from mail-wm1-f49.google.com ([209.85.128.49]:41487) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3JgC-0006vF-RB for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 11:23:25 -0500 Received: by mail-wm1-f49.google.com with SMTP id o7-20020a05600c510700b003cffc0b3374so1440433wms.0 for <59662@debbugs.gnu.org>; Thu, 08 Dec 2022 08:23:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=sKR31xNTg40XsuWbWDK83FzZh01kw56yU06KAQwBeHU=; b=KtD5ewafrh6W57OUTUxw6fx4XSK9Pi7mnjJ3bX+y5/0/+XttDBLdvs/Nx1u97mp8g9 8NPn00+gGT2HTsQ2C97+2meltd5PcfIfoD4hmv1mqgGQ4+xbOI7AATdNGikzadKE+CYu EAOrm1ftEcWNtAH+8XDTeWbHP91UITGkRnRGQ9FbccOcZNIILAaWsJ+0O1lvnjyWeT0F e7KnCPijF2+6DklsE4HzsQPpr5Jhh2+HtEmu55eY5yI5RLE6dLHizXESeXPifXJyFU6j 4+RyP5yMVNFXF6h+zo3io63k42fY8ebvlUSXLpHE+rBEY9/pYYsW6J/VS72umuWAo3vX aiLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=sKR31xNTg40XsuWbWDK83FzZh01kw56yU06KAQwBeHU=; b=O9kQJN478nUhu4OEekUfzztt0myZZ2CCWYCkth77ujlL3tzQpEWkkVHFTku157nqpj yymU6JOYqGDVqEjtvOi/6rvDm5rVFbADVB4IoWogIOt8EgtuVVSj+nYMs4Zw1n/47HWt ZpuSr9EJngXuGp9u8+yeLLsDbx2gANh60Y+c1Lt8/hrwkETmmC0w6hHDNFzRdPz6qIbg c2ZklNVZ3/qdMHwsslIMSKNk5IhWFW4+t7XpHmMPJBwuKDSzh9JTxg4Ui8255zbd+BI5 r9P48HqVfsiGuqlq5+reUtK7Nz7L5sc2VBiRtxRY9HSL5uMlty0zih3UEp6M2T66L5// J9mA== X-Gm-Message-State: ANoB5ploA48Z9KjbuuOuunWacDO5SQzUPVncKNIYSIb46U6sW1/Wu8GM dEGSVg9PA+eAnIkDfS8vX2Q= X-Google-Smtp-Source: AA0mqf7Mk7f/cE1DSGsbCCYaIrOh2kWubA3UFKd/andajY0KEkgu/A1Y32z5nh7xYCYX1EkhyU33Yg== X-Received: by 2002:a05:600c:5109:b0:3cf:63dc:c3fd with SMTP id o9-20020a05600c510900b003cf63dcc3fdmr2533223wms.34.1670516598936; Thu, 08 Dec 2022 08:23:18 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id o17-20020a05600c511100b003cfa3a12660sm12260607wms.1.2022.12.08.08.23.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Dec 2022 08:23:18 -0800 (PST) Message-ID: Date: Thu, 8 Dec 2022 18:23:16 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US To: Theodor Thornhill , Eli Zaretskii References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> From: Dmitry Gutov In-Reply-To: <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, monnier@iro.umontreal.ca, casouri@gmail.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 08/12/2022 18:04, Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > > >> syntax-ppss is used in a lot of places. A "free" improvement like the above wouldn't hurt. >> >>>> So my preference would be to check in the , the var will be there as well. >>> I don't insist, but it sounds like the logical thing to do. So unless >>> you feel strongly against that, I'd say let's add that part. This is, >>> after all, an experiment, so let's experiment. >> I'm not going to object. >> >> Doubly so if somebody else wants to finish up the patch and commit it with NEWS and documentation updates. 😉 > I can finish up the patch if you don't want to 😄 If you don't mind. Thank you. :-) From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 11:41:30 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 16:41:30 +0000 Received: from localhost ([127.0.0.1]:57819 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3Jxh-00076j-Rd for submit@debbugs.gnu.org; Thu, 08 Dec 2022 11:41:30 -0500 Received: from out-208.mta0.migadu.com ([91.218.175.208]:16741) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3Jxe-00076c-RC for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 11:41:27 -0500 Date: Thu, 08 Dec 2022 17:33:04 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1670517684; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jB0s6c2en75SnDNFxWbQ6ha/r7GzFG33m7HjLdS6R5s=; b=XYclYmYO1W5lErLUzV6X4HH0zCr8I0ufo9R4eZRRuac0b5C9RObb+Musb1OCw0kz9sVZW9 2rEFaaMNWEZg64ys4zgBd4lpSo34Zr4UnGAyO2wtwvtLZEJLSfrQl9Jc4ibW3pWYMSfnH6 Eg63CmWNO5CjZc2L9iszvKzDgzlqLIQZ/DJ8Btw+IjagNrT6XQU/c2wPlChK4jylLnj/xf EUdJ0D4V8e8/ls2zB+gk1YjvF4GnKJs4vBnKlu0naS4G3bYdMXb8DTw85bY3DO7CCihrJX cvGlqMN8ZPIxwjlvT0MPS9xqy/eAyMOSJKRnBCJP5dcykFyqqyNO02wn60XCug== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Theodor Thornhill To: Dmitry Gutov , Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <617cb890-b622-4f76-c446-f4c95c377cc5@yandex.ru> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <83o7se2n89.fsf@gnu.org> <87tu269mox.fsf@thornhill.no> <34c2b5b5-3312-066e-50f4-2aa776d0273f@yandex.ru> <87k032c577.fsf@thornhill.no> <617cb890-b622-4f76-c446-f4c95c377cc5@yandex.ru> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 8 December 2022 17:06:26 CET, Dmitry Gutov wrote: >On 08/12/2022 16:58, Theodor Thornhill via Bug reports for GNU Emacs, the= Swiss army knife of text editors wrote: >> Dmitry Gutov writes: >>=20 >>> On 08/12/2022 13:09, Theodor Thornhill wrote: >>>> What about this? I changed it to make a point that we should fill if >>>> inside of a string or comment, and indent if inside a code block=2E = We >>>> one such variable for each type, or in both as suggested below=2E >>> Could you rephrase maybe? I'm not seeing the difference=2E >> In the first example I made the variable specific to comments=2E But >> filling should work on everything that's considered text, IIUC=2E So i= f >> the variable refers to both the regex needs to accommodate strings and >> comments=2E That will in turn make it less useful if we want to find >> comments specifically, or strings specifically=2E so we could have both >> 'treesit-comment-regexp' and 'treesit-string-regexp' and match on '(or >> treesit-comment-regexp treesit-string-regexp)' in this particular case= =2E >>=20 >> Not really sure if that made more sense=2E > >Ah=2E So that was about the name of the variable=2E Looks good=2E > Yeah, and thus what nodes it should capture >Note that if the improvement which I described ever comes to life (hopefu= lly), then the variable will probably need to be renamed/moved/multiplied a= gain=2E Why is that? From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 14:15:44 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 19:15:44 +0000 Received: from localhost ([127.0.0.1]:58537 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3MMx-0002YV-Cg for submit@debbugs.gnu.org; Thu, 08 Dec 2022 14:15:44 -0500 Received: from out2.migadu.com ([188.165.223.204]:41004) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3MMu-0002YI-1g for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 14:15:41 -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=1670526938; 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=DE2SefOxgHesDFhoui0LtMEXLTltlQb+ZTU7nzW9SCg=; b=lMY/5qnqcYFuIsGlA4q3zNX5fl/EuidlWqqTBneVKozxYulChmWDbHjquwVvRIL5dGZerG j9LUY/9KsyQZ+VIgeOIP9uDKjoS9QoFxPrw+7UXUtvHWQxcpS+M3ghEVwo9SAlBVzoCr70 rcvrtnPsXyk52HAQgLVwuHEDx2YvtOWKJ3qCZX3ZE0Aua7bUTexzTBiWMASe+3Mdz8dcyI l9WMYH7Jh35psRS7IcVqwSTSmcVqmVxX9tcBHe38hP4w6O20O8B5DecI60tAD4QbjAGpkz ATm7hL6iH/ZdDSZDNRowmgRjC18Tn/xZKobeAoQvgmFjO5hPTgf4FmMHYqDtwA== From: Theodor Thornhill To: Dmitry Gutov , Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> Date: Thu, 08 Dec 2022 20:15:37 +0100 Message-ID: <877cz1d7vq.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, Yuan Fu , monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Dmitry Gutov writes: > On 08/12/2022 18:04, Theodor Thornhill via Bug reports for GNU Emacs,=20 > the Swiss army knife of text editors wrote: >>=20 >>=20 >>> syntax-ppss is used in a lot of places. A "free" improvement like the a= bove wouldn't hurt. >>> >>>>> So my preference would be to check in the , the var will be there as = well. >>>> I don't insist, but it sounds like the logical thing to do. So unless >>>> you feel strongly against that, I'd say let's add that part. This is, >>>> after all, an experiment, so let's experiment. >>> I'm not going to object. >>> >>> Doubly so if somebody else wants to finish up the patch and commit it w= ith NEWS and documentation updates. =F0=9F=98=89 >> I can finish up the patch if you don't want to =F0=9F=98=84 > > If you don't mind. Thank you. :-) Ok, will do. In preparation for that function, we need that variable on the emacs-29 branch, right? So here's a patch for that. What do you think, Dmitry, Eli and Yuan? If this gets installed on emacs-29, I can make the function we discussed on the master branch when that is merged. Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-treesit-text-type-regexp.patch >From 5edf9bd675b35f97cc0245036ae6ceeb91de1c52 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Thu, 8 Dec 2022 20:06:09 +0100 Subject: [PATCH] Add treesit-text-type-regexp Sometimes it is good to easily differentiate between textual nodes and normal code. One such case is for a filling and reindenting command, where we fill the textual node if point is on one, and reindent code otherwise. This is a part of bug#59662. * lisp/treesit.el: New variable. * lisp/progmodes/c-ts-mode.el (c-ts-mode--font-lock-settings): Add raw_string_literal for C++. (c-ts-mode, c++-ts-mode): Add regexp for the new variable. * lisp/progmodes/csharp-mode.el: Add regexp for the new variable. * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Add text_block as no-indent. (java-ts-mode--font-lock-settings): Add text_block font-lock-rule. (java-ts-mode): Add regexp for the new variable. * lisp/progmodes/js.el (js-ts-mode): Add regexp for the new variable. * lisp/progmodes/json-ts-mode.el (json-ts-mode--font-lock-settings): Add comment font-lock-rule. (json-ts-mode): Add regexp for the new variable, and use the new comment feature. * lisp/progmodes/python.el (python-ts-mode): Add regexp for the new variable. * lisp/progmodes/sh-script.el (bash-ts-mode): Add regexp for the new variable. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-base-mode): Add regexp for the new variable. * lisp/textmodes/css-mode.el (css-ts-mode): Add regexp for the new variable. --- lisp/progmodes/c-ts-mode.el | 12 +++++++++++- lisp/progmodes/csharp-mode.el | 5 +++++ lisp/progmodes/java-ts-mode.el | 9 ++++++++- lisp/progmodes/js.el | 5 +++++ lisp/progmodes/json-ts-mode.el | 8 +++++++- lisp/progmodes/python.el | 2 ++ lisp/progmodes/sh-script.el | 4 ++++ lisp/progmodes/typescript-ts-mode.el | 4 ++++ lisp/textmodes/css-mode.el | 2 ++ lisp/treesit.el | 8 ++++++++ 10 files changed, 56 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 0b17541a0a..10aec36c2f 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -252,7 +252,9 @@ c-ts-mode--font-lock-settings :language mode :feature 'string `((string_literal) @font-lock-string-face - (system_lib_string) @font-lock-string-face) + (system_lib_string) @font-lock-string-face + ,@(when (eq mode 'cpp) + '((raw_string_literal) @font-lock-string-face))) :language mode :feature 'literal @@ -592,6 +594,10 @@ c-ts-mode (setq-local comment-start-skip (rx (or (seq "/" (+ "/")) (seq "/" (+ "*"))) (* (syntax whitespace)))) + + (setq-local treesit-text-type-regexp + (regexp-opt '("comment"))) + (setq-local comment-end-skip (rx (* (syntax whitespace)) (group (or (syntax comment-end) @@ -628,6 +634,10 @@ c++-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "raw_string_literal"))) + (treesit-parser-create 'cpp) (setq-local treesit-simple-indent-rules diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index 82e3bc0d54..f83ab16caa 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el @@ -912,6 +912,11 @@ csharp-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "verbatim_string-literal" + "interpolated_verbatim_string-text"))) + ;; Indent. (setq-local treesit-simple-indent-rules csharp-ts-mode--indent-rules) diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index bda4ac86c8..30c920be7f 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -73,6 +73,7 @@ java-ts-mode--indent-rules ((node-is "]") parent-bol 0) ((and (parent-is "comment") comment-end) comment-start -1) ((parent-is "comment") comment-start-skip 0) + ((parent-is "text_block") no-indent) ((parent-is "class_body") parent-bol java-ts-mode-indent-offset) ((parent-is "interface_body") parent-bol java-ts-mode-indent-offset) ((parent-is "constructor_body") parent-bol java-ts-mode-indent-offset) @@ -162,7 +163,8 @@ java-ts-mode--font-lock-settings :language 'java :override t :feature 'string - `((string_literal) @font-lock-string-face) + `((string_literal) @font-lock-string-face + (text_block) @font-lock-string-face) :language 'java :override t :feature 'literal @@ -313,6 +315,11 @@ java-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("line_comment" + "block_comment" + "text_block"))) + ;; Indent. (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 45dfef372c..d0b243a22f 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3857,6 +3857,11 @@ js-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) (setq-local comment-multi-line t) + + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "template_string"))) + ;; Electric-indent. (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) ;FIXME: js2-mode adds "[]*". diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index f3bd93923e..d655821ec9 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -75,6 +75,9 @@ json-ts--indent-rules (defvar json-ts-mode--font-lock-settings (treesit-font-lock-rules + :language 'json + :feature 'comment + '((comment) @font-lock-comment-face) :language 'json :feature 'bracket '((["[" "]" "{" "}"]) @font-lock-bracket-face) @@ -159,10 +162,13 @@ json-ts-mode (setq-local treesit-defun-type-regexp (rx (or "pair" "object"))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment"))) + ;; Font-lock. (setq-local treesit-font-lock-settings json-ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list - '((constant number pair string) + '((comment constant number pair string) (escape-sequence) (bracket delimiter error))) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index ebee703499..f678e10fdf 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -6631,6 +6631,8 @@ python-ts-mode #'python-imenu-treesit-create-index) (setq-local treesit-defun-type-regexp (rx (or "function" "class") "_definition")) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment"))) (treesit-major-mode-setup) (when python-indent-guess-indent-offset diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index e170d18afe..1605e40347 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1619,6 +1619,10 @@ bash-ts-mode ( bracket delimiter misc-punctuation operator))) (setq-local treesit-font-lock-settings sh-mode--treesit-settings) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "heredoc_start" + "heredoc_body"))) (treesit-major-mode-setup))) (advice-add 'bash-ts-mode :around #'sh--redirect-bash-ts-mode diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index a56568ae78..e502c6d249 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -329,6 +329,10 @@ typescript-ts-base-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "template_string"))) + ;; Electric (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 822097a86d..eb4fbc887c 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1835,6 +1835,8 @@ css-ts-mode (treesit-parser-create 'css) (setq-local treesit-simple-indent-rules css--treesit-indent-rules) (setq-local treesit-defun-type-regexp "rule_set") + (setq-local treesit-text-type-regexp + (regexp-opt '("comment"))) (setq-local treesit-font-lock-settings css--treesit-settings) (setq-local treesit-font-lock-feature-list '((selector comment query keyword) diff --git a/lisp/treesit.el b/lisp/treesit.el index 85154d0d1c..cc94b460c7 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1639,6 +1639,14 @@ treesit-end-of-defun (when top (goto-char (treesit-node-end top))))) +(defvar-local treesit-text-type-regexp nil + "A regexp that matches the node type of textual nodes. + +A textual is a node that is not normal code, such as comments and +multiline string literals. For example, \"(line|block)_comment\" +in the case of a comment, or \"verbatim_string_literal\" in the +case of a string.") + ;;; Activating tree-sitter (defun treesit-ready-p (language &optional quiet) -- 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 14:51:37 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 19:51:37 +0000 Received: from localhost ([127.0.0.1]:58769 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3Mvg-00030U-Od for submit@debbugs.gnu.org; Thu, 08 Dec 2022 14:51:36 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:5294) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3Mve-00030O-Q2 for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 14:51:35 -0500 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 326FE1000EF; Thu, 8 Dec 2022 14:51:29 -0500 (EST) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 55DA41000DC; Thu, 8 Dec 2022 14:51:27 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1670529087; bh=QnnNQ+M0CEcgh3dyQWYM0tuq8Eh9amjpbSRxjUu7l6g=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ksXLr3NJ8rHa1Hdo1XzNqpO7DnKSheSzDqDjH13q+yoOYfwOGQiZFCXvZ9YwrFYJc Uo3uVjVG8TXiFvf0IliFgc4ZCcF6pE+mZxYmeotMdNwriLrgI6N/ElpZSrE9Gm6rXp hHr7g5DOTBhdr2mf1viZRc3L6rnYfh2jWFDLsj2PJgX8pRIOCMnMWfeK2qABwntQ++ +sNirdyMATLEb7RlHG2YqiQ+/NaMQogHSrDCnI2wt4c7Jlvt+eOPcysm8PExkRFChA mNtu9xt8hTfXYvEwXQiD9gG0dWwHg4l3hz6DXiop8Jd3k2F9nc8YrnBGWq0lO2UIFj 4azr46XgfzcPA== Received: from alfajor (unknown [45.44.229.252]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id ED361120FD8; Thu, 8 Dec 2022 14:51:26 -0500 (EST) From: Stefan Monnier To: Theodor Thornhill Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <877cz1d7vq.fsf@thornhill.no> (Theodor Thornhill's message of "Thu, 08 Dec 2022 20:15:37 +0100") Message-ID: References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> Date: Thu, 08 Dec 2022 14:50:32 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.228 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: Eli Zaretskii , 59662@debbugs.gnu.org, Yuan Fu , larsi@gnus.org, Dmitry Gutov X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Sometimes it is good to easily differentiate between textual nodes and > normal code. One such case is for a filling and reindenting command, > where we fill the textual node if point is on one, and reindent code > otherwise. This is a part of bug#59662. I wonder if we shouldn't have something slightly more general, such as a function which returns nil for "normal code" nodes and non-nil for "textual" nodes, in which case it could additionally return info such as whether it's rather like a comment or rather like a string or maybe some information about how to insert/remove a linebreak from within it (in case they need to be escaped somehow, or for line-comments). Stefan From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 15:13:13 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 20:13:13 +0000 Received: from localhost ([127.0.0.1]:58862 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3NGb-0003CX-DF for submit@debbugs.gnu.org; Thu, 08 Dec 2022 15:13:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59790) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3NGZ-0003CQ-2y for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 15:13:11 -0500 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 1p3NGR-0006Q5-Ks; Thu, 08 Dec 2022 15:13:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=NrrvAMC7u6sIOCZx35HxYmt8+rmqCoOqRXOJ5hC0MQ8=; b=Cm7r1I0KBeB8 SszJuOyi97GGFt1jCPD2K5jUJ92p+X+Ud+OfegwYtoBR7NF0c5ZfD3KiqeYCQc6eO1Qr5AxfpZb5Q lbQCKihjzh67YOjA3pFhBG+/unyUc80Oi0AYatpsXFylQTV+3UOdEMv11IiQoLrA05NlfSdVhy7eH SFsESyiWQ1lpAMeGoLjRb+T1yudgLSM7xHlFaUOPPWvNfndI6Wczytl+0JQbilsaAavnI9jMriBpD QbHW6d9s0QQ8/wEVaq5EDedC9Ix1/WOvjUwHJhlfN/DnhPON7P+OGM/GzfvQ/GH9cOryZYvvhwHhs 44Ypwr56U/cuPVGLjtJ3Sw==; 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 1p3NGP-0002iE-Nl; Thu, 08 Dec 2022 15:13:03 -0500 Date: Thu, 08 Dec 2022 22:12:50 +0200 Message-Id: <83ilil1wot.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: <877cz1d7vq.fsf@thornhill.no> (message from Theodor Thornhill on Thu, 08 Dec 2022 20:15:37 +0100) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Theodor Thornhill > Cc: larsi@gnus.org, 59662@debbugs.gnu.org, monnier@iro.umontreal.ca, Yuan Fu > > Date: Thu, 08 Dec 2022 20:15:37 +0100 > > Ok, will do. In preparation for that function, we need that variable on > the emacs-29 branch, right? Why? Why cannot we introduce the variable only on master? From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 16:22:03 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 21:22:03 +0000 Received: from localhost ([127.0.0.1]:59188 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3OLD-0003qU-0k for submit@debbugs.gnu.org; Thu, 08 Dec 2022 16:22:03 -0500 Received: from out2.migadu.com ([188.165.223.204]:45075) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3OLA-0003q7-Up for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 16:22:01 -0500 Date: Thu, 08 Dec 2022 22:21:35 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1670534519; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WTCC7u0n+ABWJPEdzGwUdXQZf7KjOWlATCaHrFjOdnQ=; b=dqNPkHIEH2EheuGIQ73hACjMoWmWTv4jnz4zAV0RVK/SxJNGsyiTL91fwMoV0Kmn7i7/6n c2qZJDr3//bWEYVPrOSDiPieqOaQXPE1rEhY/sndjcFzcze7FDPQf0uoOPWznCWxTjugK8 vUytblbdKhkv+pFa3gVM/kovBsyfXHDwZH2EcS3TN7QDdkIsNU+x3jWTJi53lJBJMeun/D SWI9+OGHNUq7hFXrzAELMbIo9xkrNqthSKSjqAc9MjYnjIB4gK6qb1M8HqXK2ccXZtN2vc lv55pf9/IFYpRSafxhIWrByPO63hGv2KAaN8WnWLaOZsXu0yhoBKFmr2al9HHg== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Theodor Thornhill To: Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <83ilil1wot.fsf@gnu.org> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> Message-ID: <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 8 December 2022 21:12:50 CET, Eli Zaretskii wrote: >> From: Theodor Thornhill >> Cc: larsi@gnus=2Eorg, 59662@debbugs=2Egnu=2Eorg, monnier@iro=2Eumontrea= l=2Eca, Yuan Fu >> >> Date: Thu, 08 Dec 2022 20:15:37 +0100 >>=20 >> Ok, will do=2E In preparation for that function, we need that variable= on >> the emacs-29 branch, right? > >Why? Why cannot we introduce the variable only on master? Mostly because I want to use it for other stuff, and for merge conflict re= asons, but you decide! I can revise the patch to go on master and introduce the function there=2E By the way, what is the deciding factor for what goes where wrt treesit go= ing forward? Theo From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 17:04:08 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 22:04:08 +0000 Received: from localhost ([127.0.0.1]:59406 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3Ozw-0006XO-FN for submit@debbugs.gnu.org; Thu, 08 Dec 2022 17:04:08 -0500 Received: from mail-wr1-f48.google.com ([209.85.221.48]:34544) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3Ozu-0006X1-HK for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 17:04:07 -0500 Received: by mail-wr1-f48.google.com with SMTP id o5so3357929wrm.1 for <59662@debbugs.gnu.org>; Thu, 08 Dec 2022 14:04:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=CUiVxH19yfsj9am+mUj/QeWLlEMNM+BEzA7vqaMELfA=; b=oBd1Yc5gCsT9U9dNgYot0t3RFa6ESWkQLAV+YNK7xYJ7HlEKPBI/f7WK9/VsFxsNm8 Ghb+gnxAjWEqxrOPtZqnN5tXyJviWVQEDOs6nSXjvv3VcJqplKTirNIOQyOBQ1xjMxm0 egfwyaQ6i0jFvyJyKA/qsayIyBCaKS6BCe7zKWs6qPW64/hjmuWcvpF+N0eZjEnrVYF6 xQAuTYch4HtcDw+gSD+AUTXrPPLctmtFpv+voMUGLrBxVm8bbBbK0pZ+YUlVICG+2G3Q YCLYBpxFd0JFCnOikr1rX9AC5jgvtjZ1sv38+3plVUifNZFC/PtFiTTZ9A2JRmvt0q0G ljSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CUiVxH19yfsj9am+mUj/QeWLlEMNM+BEzA7vqaMELfA=; b=qPzgdxM/SfO8HJW3LgsUU9DkV8q67BRWc4qwwepZ3FP5coTI7lxVmuQQbkpNjNm5vg I3vD8SSchY0IrunJSeLOxSV2xf9nisTNSIp4x9jBir4awO+VoDApoq85uT9/JJzYuV0j Pu9xs4JHdCnoaCacwIF9DB2eFJc3vIMtZJQKnW1UBQ/vovh0X/D+06ZeX0VaxcyamcUz r+o/jo8A55+D6SFHR9VowchABwyeltvsK2/HBlwh0kic4D1wBn7XBjRqYSle1OAnFCq3 P0Ewxe+fh667esr88UpxqtHJHirrskrTRkXj1yEuDqTvCAtzLu/ScSXLlybce8SQegB2 9pnA== X-Gm-Message-State: ANoB5pmkyS+kXYndlZs0k7VVZ4nsirNQH8D89WD6L1Rq4/UPRw6KJM9E 1PKe+PjiBzejG7BdBOIHdLA= X-Google-Smtp-Source: AA0mqf4FCfnIx66SOTC9vpxIVU1bftUdvdH8aJZUzc2F3O+by0xtI0DZeOLIRGGUz2ZpmgBUwLITgA== X-Received: by 2002:adf:ebc8:0:b0:236:5e35:7b1a with SMTP id v8-20020adfebc8000000b002365e357b1amr2404801wrn.60.1670537040447; Thu, 08 Dec 2022 14:04:00 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id z4-20020a5d4d04000000b0022ae0965a8asm22734452wrt.24.2022.12.08.14.03.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Dec 2022 14:03:59 -0800 (PST) Message-ID: <4215c43c-ee75-ddbe-85da-7fed0129a30b@yandex.ru> Date: Fri, 9 Dec 2022 00:03:57 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US To: Theodor Thornhill , Eli Zaretskii References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <83o7se2n89.fsf@gnu.org> <87tu269mox.fsf@thornhill.no> <34c2b5b5-3312-066e-50f4-2aa776d0273f@yandex.ru> <87k032c577.fsf@thornhill.no> <617cb890-b622-4f76-c446-f4c95c377cc5@yandex.ru> From: Dmitry Gutov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 08/12/2022 18:33, Theodor Thornhill wrote: > > > On 8 December 2022 17:06:26 CET, Dmitry Gutov wrote: >> On 08/12/2022 16:58, Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: >>> Dmitry Gutov writes: >>> >>>> On 08/12/2022 13:09, Theodor Thornhill wrote: >>>>> What about this? I changed it to make a point that we should fill if >>>>> inside of a string or comment, and indent if inside a code block. We >>>>> one such variable for each type, or in both as suggested below. >>>> Could you rephrase maybe? I'm not seeing the difference. >>> In the first example I made the variable specific to comments. But >>> filling should work on everything that's considered text, IIUC. So if >>> the variable refers to both the regex needs to accommodate strings and >>> comments. That will in turn make it less useful if we want to find >>> comments specifically, or strings specifically. so we could have both >>> 'treesit-comment-regexp' and 'treesit-string-regexp' and match on '(or >>> treesit-comment-regexp treesit-string-regexp)' in this particular case. >>> >>> Not really sure if that made more sense. >> >> Ah. So that was about the name of the variable. Looks good. >> > > Yeah, and thus what nodes it should capture > > >> Note that if the improvement which I described ever comes to life (hopefully), then the variable will probably need to be renamed/moved/multiplied again. > > Why is that? Suppose we have a thingy called tree-sitter-parse-state, or tsps in short. As a general purpose thigy, it would have the means to check whether the state corresponds to a string, or to a comment, at least. Maybe it would be able to signal different kinds of strings and comments as well, but let's put that aside for now. For clients to get that info, it can have a general function that would return the current node (or maybe a derivative of it) -- call it tree-sitter-parse-state, and helpers like tsps-string-p and tsps-comment-p, as well as, possibly, tsps-comment-or-string-start. Maybe other helpers similar to the fields in the ppss defstruct. And it seems to me that to implement tsps-string-p and tsps-comment-p you will need two different constants like that. Then, in turn, prog-fill-or-reindent-defun could be implemented in terms of tsps-string-p and tsps-comment-p. It could also call tsps-comment-or-string[-start], if such helper will be defined, which will internally be implemented either in terms of tsps-*-p functions, or use the two corresponding new constants anyway. From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 17:05:47 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 22:05:47 +0000 Received: from localhost ([127.0.0.1]:59416 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3P1W-0006YG-Um for submit@debbugs.gnu.org; Thu, 08 Dec 2022 17:05:47 -0500 Received: from mail-wm1-f45.google.com ([209.85.128.45]:40746) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3P1U-0006Y6-Md for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 17:05:45 -0500 Received: by mail-wm1-f45.google.com with SMTP id v124-20020a1cac82000000b003cf7a4ea2caso4502399wme.5 for <59662@debbugs.gnu.org>; Thu, 08 Dec 2022 14:05:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=pfzLx7Nv8PEhoCnjQKA/iX361aCXXXc2f/uBbyrBrn8=; b=JqnazWg5Z03KWozsF3hCaXw5HVhlejTVN+Q/4zScmnY/Q9A2Tt7/SRhQ4lWVThh4xB WHP53A9UuuLjxb3LiY/5SuT0TGn9NsSw/CIKaCBRnS+/P5+PiBMnNT+DuxWsalNgsnGO GVfjPNsfvQKhxxp6nnTeSn1zstn7zLLMqpCm91laL7FXAAw8UrMYyEVmy1iv8AGGVyhQ SfmyIy5vPjlp6CHITrJ/uOVW4+eMUFu4iSHDF3OG2M/cVfCo/Jq6U6zmWpX6A/ThV4U/ uJc1czmgzJ4/QdPOJrpbUb9VgvRDsTcmxaiWawa1uDcNix8eXP+QchrF3TkCYFJLWzbx d62w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pfzLx7Nv8PEhoCnjQKA/iX361aCXXXc2f/uBbyrBrn8=; b=StCiNs2mZxFKDJ6lK/SwcSX0Xb0Rib1/1JleoQTt9lsg7Mjilc8maynPC5Jz3iZiOv 92cnDZC1HuI+gO69IoLuVQM1Fs5OjKAUxq9svcr0Jxxsyy07VJQihLXuN5Mpjkr8wq6l Tznte+AD/RhGFKN/VVpzE8zEFVPAatiNbmg6lF10VN7T5jAOlafTyTs11G26wTbpO9qa yuQfK/9R8w5nb5AFiz+gbQcOfbdXkG0gVdgIm74+SFgGAwyXLZP/23Jr5ohCmqZ4KItV G4E9/4t2+UCiplrCQkNgJ2SSuSkzAY48vz5Fi2A2S1bhN56WgujSp7WRlwj9OJU58q4g F6aQ== X-Gm-Message-State: ANoB5pmj3C5LxI+sSRnBS5CnCVhzabnYCYOPeHluPIkzHVImYbuEhGRI vCGHk6Ex7oF5nLrcBeailXM= X-Google-Smtp-Source: AA0mqf7701b5wDYsYN27oXI0p94rWLyLuWwBzrQ/eJ7S37qmfR2jF73+HtO0DjMS3aaWozU1hHHsNw== X-Received: by 2002:a05:600c:ad5:b0:3cf:eaf5:77c1 with SMTP id c21-20020a05600c0ad500b003cfeaf577c1mr3171281wmr.13.1670537139040; Thu, 08 Dec 2022 14:05:39 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id k32-20020a05600c1ca000b003b4ff30e566sm13291191wms.3.2022.12.08.14.05.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Dec 2022 14:05:38 -0800 (PST) Message-ID: Date: Fri, 9 Dec 2022 00:05:37 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US To: Theodor Thornhill , Eli Zaretskii References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> From: Dmitry Gutov In-Reply-To: <877cz1d7vq.fsf@thornhill.no> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, Yuan Fu , monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 08/12/2022 21:15, Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > Ok, will do. In preparation for that function, we need that variable on > the emacs-29 branch, right? If the variable will be soon substituted with something else, it seems unwise to define it on the release branch. But then again, if we declare the whole tree-sitter feature as experimental, maybe it'll be okay. Depends on what else you want to do with it in emacs-29. From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 17:11:12 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 22:11:12 +0000 Received: from localhost ([127.0.0.1]:59442 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3P6l-0006ax-NM for submit@debbugs.gnu.org; Thu, 08 Dec 2022 17:11:11 -0500 Received: from out-112.mta0.migadu.com ([91.218.175.112]:60297) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3P6k-0006ar-2e for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 17:11:10 -0500 Date: Thu, 08 Dec 2022 23:10:25 +0100 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Theodor Thornhill To: Dmitry Gutov , Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> Message-ID: <5F5BFAAE-EA12-4752-824E-55FF69C49E7F@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, Yuan Fu , monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 8 December 2022 23:05:37 CET, Dmitry Gutov wrote: >On 08/12/2022 21:15, Theodor Thornhill via Bug reports for GNU Emacs, the= Swiss army knife of text editors wrote: >> Ok, will do=2E In preparation for that function, we need that variable= on >> the emacs-29 branch, right? > >If the variable will be soon substituted with something else, it seems un= wise to define it on the release branch=2E But then again, if we declare th= e whole tree-sitter feature as experimental, maybe it'll be okay=2E > >Depends on what else you want to do with it in emacs-29=2E I was thinking in line of what you wrote in your other mail, but that migh= t be too big to go to emacs-29=2E From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 08 17:49:13 2022 Received: (at 59662) by debbugs.gnu.org; 8 Dec 2022 22:49:13 +0000 Received: from localhost ([127.0.0.1]:59614 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3PhZ-0006tz-3x for submit@debbugs.gnu.org; Thu, 08 Dec 2022 17:49:13 -0500 Received: from mail-wr1-f45.google.com ([209.85.221.45]:44682) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3PhW-0006tt-V1 for 59662@debbugs.gnu.org; Thu, 08 Dec 2022 17:49:11 -0500 Received: by mail-wr1-f45.google.com with SMTP id u12so3423356wrr.11 for <59662@debbugs.gnu.org>; Thu, 08 Dec 2022 14:49:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=wJO8Py0saYi8nPa2MVqyaVWUHyUCkSx24yDk+J7BYqw=; b=Gv2aomlq2LBIggjFU8hIf9hOGNisteKiakmVOx0+/Dl3oaUsNj9//65ToXFCbOlnOq PFquyU+jq7TCVlYe03P9ZDrPxklxWMJCEHrcXff6F4XQAQf+l8hFnnXnwyyiCOeODf6h rO7icuXmlaOJ0HZK4wRCL2dNTlpr7wnsChQ9fQuYMvL0ih/D0VCXnYHmDM1g+ME7SMqU SYWctk9uQcNadNsB+KvFl5RRNDIVzk+Vc6AdAcKyd2d49n6NKmJuCfzLWupXdwL+q2Ef G0Lqplet6ucgMQ9oDl6RCVJ62FLqWtOObAzWhXd+5mM8EJHeQH4WALg2ybxGGqZewaas xleA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wJO8Py0saYi8nPa2MVqyaVWUHyUCkSx24yDk+J7BYqw=; b=kZ0SHxF2mHfvVffJYb382oj3em7Q1KRLqRK3aBDNcgMWcVlC8WKFqamagUakgBQd+y +j0vcs4JgeqHXOudlBI/f9ZQ2GfrGI8C9lCBbnxxf27QxaAP/EV2bmtdSPSmD0W1COKx k5xpA0mcDuR44kyS673ZDVXROd3jN7r2y5aj8ER5+CxOEPSTdNpa9yLnHYrqKrYo5GwY 49Z1KqIYa4G/u8bebRpFiqNtKjpbvqPGaHcXaAPkdLlyzQ7IMIMM/8GJlsCgmzyv9ABw HcwyNZ5w2XE+c5bO6VfnpzEaCqU8L+nz4Vl823+wwHszn+DAacGzY2PRno0puhqQHx6x Z3gw== X-Gm-Message-State: ANoB5pnB6oPZM6pxRgFNbntkYf5ffku6L9tlS/+BuL1LKS3KQH686Yo1 NkT9O51caQjIKlYZAMu9PTY= X-Google-Smtp-Source: AA0mqf4YmkDoYw6NsDGTCLNbqNxkK5ryVhea8WLZvsJLY8eOQ6d9Bv4Cp2DNLBgFP9ZF4T58bo0idA== X-Received: by 2002:a05:6000:1290:b0:242:29e9:184c with SMTP id f16-20020a056000129000b0024229e9184cmr2525684wrx.29.1670539744879; Thu, 08 Dec 2022 14:49:04 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id y15-20020a5d4acf000000b00241e5b917d0sm27909026wrs.36.2022.12.08.14.49.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Dec 2022 14:49:04 -0800 (PST) Message-ID: <9ebcd4a9-865f-291a-c986-2687d1b69610@yandex.ru> Date: Fri, 9 Dec 2022 00:49:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US To: Theodor Thornhill , Eli Zaretskii References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <5F5BFAAE-EA12-4752-824E-55FF69C49E7F@thornhill.no> From: Dmitry Gutov In-Reply-To: <5F5BFAAE-EA12-4752-824E-55FF69C49E7F@thornhill.no> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, Yuan Fu , monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 09/12/2022 00:10, Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > > On 8 December 2022 23:05:37 CET, Dmitry Gutov wrote: >> On 08/12/2022 21:15, Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: >>> Ok, will do. In preparation for that function, we need that variable on >>> the emacs-29 branch, right? >> If the variable will be soon substituted with something else, it seems unwise to define it on the release branch. But then again, if we declare the whole tree-sitter feature as experimental, maybe it'll be okay. >> >> Depends on what else you want to do with it in emacs-29. > I was thinking in line of what you wrote in your other mail, but that might be too big to go to emacs-29. My gut feeling is it will require some time to stabilize, grow the required features and whatnot, with associated churn. Then it's better to put into master. But I can just as well be wrong on this subject, and being able to take advantage of this feature will be pretty nice. Speaking of improvements for release, though, have you thought about the other idea, the "faster syntax-ppss"? It shouldn't require changes to public-facing infrastructure (or very little; like un-obsoleting syntax-begin-function). Though whether it will require new constants or not, I cannot say. From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 09 00:07:01 2022 Received: (at 59662) by debbugs.gnu.org; 9 Dec 2022 05:07:01 +0000 Received: from localhost ([127.0.0.1]:33101 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3VbA-0001zM-Pg for submit@debbugs.gnu.org; Fri, 09 Dec 2022 00:07:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54530) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3Vb4-0001z7-QU for 59662@debbugs.gnu.org; Fri, 09 Dec 2022 00:06:58 -0500 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 1p3Vax-0007zv-SE; Fri, 09 Dec 2022 00:06:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=lVXg2CsFB1T8LS47eBfmV+wXpUWoRjMZGEWiEtJwLyc=; b=TexhpVWjY9LL 0FRlFrxdVZpBQc6JN/y7P4cA41aOyG1B4HoQAdu7Rc7ABxXWi1sgmjt5KtxNEcvC5sJ3mnrmSoCef +k29ft9zvGYpJ4kiW+c3K8oMb5sf4Zbv17fXfTSHttqvsfth319+1d4Pu2kL+a4Kic8UH7RUzhBNS Pnc/76Mm2APiplyF3bpPOmuBQW8OzyiAeKFH6Rd+kHkanzWW0hfQ27JIYW2keH9St5kWQCkwsR8zX 5tFs/1LZINED6ssfPh/huAfrUb1jc2PauVES0GIgDgZct1jfKn+z1tO5sg3hcf6lO3IQRwYtGl9wt +Y9vOJAYixYsRH9bW7ppWg==; 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 1p3Vaw-0002ln-Cy; Fri, 09 Dec 2022 00:06:47 -0500 Date: Fri, 09 Dec 2022 07:06:38 +0200 Message-Id: <83edt917z5.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> (message from Theodor Thornhill on Thu, 08 Dec 2022 22:21:35 +0100) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83o7sniokt.fsf@gnu.org> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Thu, 08 Dec 2022 22:21:35 +0100 > From: Theodor Thornhill > CC: dgutov@yandex.ru, larsi@gnus.org, 59662@debbugs.gnu.org, > monnier@iro.umontreal.ca, casouri@gmail.com > > >> Ok, will do. In preparation for that function, we need that variable on > >> the emacs-29 branch, right? > > > >Why? Why cannot we introduce the variable only on master? > > Mostly because I want to use it for other stuff, and for merge conflict reasons, but you decide! > > I can revise the patch to go on master and introduce the function there. Yes, please do that on master. > By the way, what is the deciding factor for what goes where wrt treesit going forward? In general, anything that doesn't need to support the minimal treesit modes we have now on emacs-29 should go to master. That includes any new features, even if they are supported by treesit. IOW, mot everything related to tree-sitter should automatically go to the release branch. And when in doubt, ask, as always. From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 09 08:24:17 2022 Received: (at 59662) by debbugs.gnu.org; 9 Dec 2022 13:24:17 +0000 Received: from localhost ([127.0.0.1]:36097 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3dMO-0001cj-LD for submit@debbugs.gnu.org; Fri, 09 Dec 2022 08:24:17 -0500 Received: from out-3.mta0.migadu.com ([91.218.175.3]:41516) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3dMK-0001cY-UH for 59662@debbugs.gnu.org; Fri, 09 Dec 2022 08:24:14 -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=1670592251; 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=yaom2QAwMp68SDrUkLExRb+KpOMK4G2t6ER11S1MZlA=; b=kyPD9z8UJZeMlipP6jfjmxMQJp1oZxpKVHh0GF4DZ6uGupQlFrBJ6wjb4UGcAxIBlkag9q 777B3mW2FYI01mhFEAB0987y4jd+vAwGaD2heFWASxqlIYboXAla9/vrroLRZv4MTl4lXQ Ki/kGc6qfRFaaYV6SX1u2du4bRU9Fj4u40oVwEv2zR03N6tnZcYA7ghIB5xD1UNuRg/izO clwmZ02IkihBi8KbGbFyjkSHQhlN8ipDh4Qy4JJjkrFBKJeancA7Qpoo38HQoXPxl4oXuv bBi5DFn5K9fyh9NLogwgZikelhHOt29WUqNtSiRpy7kf9uGirHDcwtuK/9wscg== From: Theodor Thornhill To: Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <83edt917z5.fsf@gnu.org> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> Date: Fri, 09 Dec 2022 14:24:08 +0100 Message-ID: <87o7scww07.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> Date: Thu, 08 Dec 2022 22:21:35 +0100 >> From: Theodor Thornhill >> CC: dgutov@yandex.ru, larsi@gnus.org, 59662@debbugs.gnu.org, >> monnier@iro.umontreal.ca, casouri@gmail.com >> >> >> Ok, will do. In preparation for that function, we need that variable on >> >> the emacs-29 branch, right? >> > >> >Why? Why cannot we introduce the variable only on master? >> >> Mostly because I want to use it for other stuff, and for merge conflict reasons, but you decide! >> >> I can revise the patch to go on master and introduce the function there. > > Yes, please do that on master. > >> By the way, what is the deciding factor for what goes where wrt treesit going forward? > > In general, anything that doesn't need to support the minimal treesit > modes we have now on emacs-29 should go to master. That includes any > new features, even if they are supported by treesit. IOW, mot > everything related to tree-sitter should automatically go to the > release branch. > > And when in doubt, ask, as always. Ok! Here's the patch. What do you all think? Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-prog-fill-reindent-defun-bug-59664.patch >From 6ee9c0caa6677b1047f07235682f948e123f740e Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Thu, 8 Dec 2022 20:06:09 +0100 Subject: [PATCH] Add prog-fill-reindent-defun (bug#59664) Introduce a new command that aims to reindent code in a defun, or fill a paragraph of text. The command uses treesit.el when available, otherwise falls back to using syntax-ppss and regexps. Treesit.el needs a new variable that is intended to be set by the major modes so that this and other future functions can know what kind of node we are looking at. * doc/emacs/programs.texi: Mention the new command. * etc/NEWS: Mention the new command. * lisp/progmodes/c-ts-mode.el (c-ts-mode--font-lock-settings): Add raw_string_literal for C++. (c-ts-mode, c++-ts-mode): Add regexp for the new variable. * lisp/progmodes/csharp-mode.el (csharp-ts-mode): Add regexp for the new variable. * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Add text_block as no-indent. (java-ts-mode--font-lock-settings): Add text_block font-lock-rule. (java-ts-mode): Add regexp for the new variable. * lisp/progmodes/js.el (js-ts-mode): Add regexp for the new variable. * lisp/progmodes/json-ts-mode.el (json-ts-mode--font-lock-settings): Add comment font-lock-rule. (json-ts-mode): Add regexp for the new variable, and use the new comment feature. * list/progmodes/prog-mode.el (prog-mode-map): Bind the new command by default. (prog-fill-reindent-defun): New command. * lisp/progmodes/python.el (python-ts-mode): Add regexp for the new variable. * lisp/progmodes/sh-script.el (bash-ts-mode): Add regexp for the new variable. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-base-mode): Add regexp for the new variable. (typescript-ts-mode--indent-rules): Add class_body. * lisp/textmodes/css-mode.el (css-ts-mode): Add regexp for the new variable. * lisp/treesit.el (treesit-text-type-regexp): New variable. --- doc/emacs/programs.texi | 6 +++++ etc/NEWS | 7 ++++++ lisp/progmodes/c-ts-mode.el | 12 +++++++++- lisp/progmodes/csharp-mode.el | 5 ++++ lisp/progmodes/java-ts-mode.el | 19 +++++++++++++-- lisp/progmodes/js.el | 6 +++++ lisp/progmodes/json-ts-mode.el | 8 ++++++- lisp/progmodes/prog-mode.el | 35 ++++++++++++++++++++++++++-- lisp/progmodes/python.el | 2 ++ lisp/progmodes/sh-script.el | 4 ++++ lisp/progmodes/typescript-ts-mode.el | 6 +++++ lisp/textmodes/css-mode.el | 2 ++ lisp/treesit.el | 9 +++++++ 13 files changed, 115 insertions(+), 6 deletions(-) diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index ba8475e86a..f9a15e819b 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -409,6 +409,12 @@ Multi-line Indent @table @kbd @item C-M-q Reindent all the lines within one parenthetical grouping. +@item M-q +Major modes that derive from @code{prog-mode} can reindent all the +lines within a defun at point using the command @kbd{M-q} +(@code{prog-mode-fill-reindent-defun}). The bounds of of a defun is +decided by @code{beginning-of-defun-function} and +@code{end-of-defun-function}. @item C-u @key{TAB} Shift an entire parenthetical grouping rigidly sideways so that its first line is properly indented. diff --git a/etc/NEWS b/etc/NEWS index 61f813568f..db1ed2a474 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -61,6 +61,13 @@ using this new option. (Or set 'display-buffer-alist' directly.) After manually editing 'eshell-aliases-file', you can use 'M-x eshell-read-aliases-list' to load the edited aliases. +** Prog Mode ++++ +*** New command 'prog-fill-reindent-defun' +This command uses treesit and syntax-ppss to either fill a textual +element in a defun, such as a doc-string or a comment. If point is +inside normal code, it (re)indents the surrounding defun. Bound by +default in 'prog-mode-map' to 'M-q'. * New Modes and Packages in Emacs 30.1 diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 08b03d5666..f0728f6fda 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -248,7 +248,9 @@ c-ts-mode--font-lock-settings :language mode :feature 'string `((string_literal) @font-lock-string-face - (system_lib_string) @font-lock-string-face) + (system_lib_string) @font-lock-string-face + ,@(when (eq mode 'cpp) + '((raw_string_literal) @font-lock-string-face))) :language mode :feature 'literal @@ -567,6 +569,10 @@ c-ts-mode (setq-local comment-start-skip (rx (or (seq "/" (+ "/")) (seq "/" (+ "*"))) (* (syntax whitespace)))) + + (setq-local treesit-text-type-regexp + (regexp-opt '("comment"))) + (setq-local comment-end-skip (rx (* (syntax whitespace)) (group (or (syntax comment-end) @@ -603,6 +609,10 @@ c++-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "raw_string_literal"))) + (treesit-parser-create 'cpp) (setq-local treesit-simple-indent-rules diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index 8ab5fbc91d..3faeb54fc5 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el @@ -911,6 +911,11 @@ csharp-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "verbatim_string-literal" + "interpolated_verbatim_string-text"))) + ;; Indent. (setq-local treesit-simple-indent-rules csharp-ts-mode--indent-rules) diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 96e0d5244c..f29445195a 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -68,6 +68,7 @@ java-ts-mode--indent-rules ((node-is "]") parent-bol 0) ((and (parent-is "comment") comment-end) comment-start -1) ((parent-is "comment") comment-start-skip 0) + ((parent-is "text_block") no-indent) ((parent-is "class_body") parent-bol java-ts-mode-indent-offset) ((parent-is "interface_body") parent-bol java-ts-mode-indent-offset) ((parent-is "constructor_body") parent-bol java-ts-mode-indent-offset) @@ -157,7 +158,8 @@ java-ts-mode--font-lock-settings :language 'java :override t :feature 'string - `((string_literal) @font-lock-string-face) + `((string_literal) @font-lock-string-face + (text_block) @font-lock-string-face) :language 'java :override t :feature 'literal @@ -308,6 +310,11 @@ java-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("line_comment" + "block_comment" + "text_block"))) + ;; Indent. (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) @@ -316,7 +323,15 @@ java-ts-mode (append "{}():;," electric-indent-chars)) ;; Navigation. - (setq-local treesit-defun-type-regexp "declaration") + (setq-local treesit-defun-type-regexp + (regexp-opt '("method_declaration" + "class_declaration" + "record_declaration" + "interface_declaration" + "enum_declaration" + "import_declaration" + "package_declaration" + "module_declaration"))) ;; Font-lock. (setq-local treesit-font-lock-settings java-ts-mode--font-lock-settings) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 45dfef372c..02cc558366 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3857,6 +3857,11 @@ js-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) (setq-local comment-multi-line t) + + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "template_string"))) + ;; Electric-indent. (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) ;FIXME: js2-mode adds "[]*". @@ -3868,6 +3873,7 @@ js-ts-mode ;; Indent. (setq-local treesit-simple-indent-rules js--treesit-indent-rules) ;; Navigation. + (setq-local treesit-defun-prefer-top-level t) (setq-local treesit-defun-type-regexp (rx (or "class_declaration" "method_definition" diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index 0a0113d1d8..441e25c287 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -72,6 +72,9 @@ json-ts--indent-rules (defvar json-ts-mode--font-lock-settings (treesit-font-lock-rules + :language 'json + :feature 'comment + '((comment) @font-lock-comment-face) :language 'json :feature 'bracket '((["[" "]" "{" "}"]) @font-lock-bracket-face) @@ -156,10 +159,13 @@ json-ts-mode (setq-local treesit-defun-type-regexp (rx (or "pair" "object"))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment"))) + ;; Font-lock. (setq-local treesit-font-lock-settings json-ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list - '((constant number pair string) + '((comment constant number pair string) (escape-sequence) (bracket delimiter error))) diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index 58cb48f182..c29efa3a21 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -30,7 +30,11 @@ ;;; Code: (eval-when-compile (require 'cl-lib) - (require 'subr-x)) + (require 'subr-x) + (require 'treesit)) + +(declare-function treesit-parser-list "treesit.c") +(declare-function treesit-node-type "treesit.c") (defgroup prog-mode nil "Generic programming mode, from which others derive." @@ -102,7 +106,8 @@ prog-context-menu (defvar-keymap prog-mode-map :doc "Keymap used for programming modes." - "C-M-q" #'prog-indent-sexp) + "C-M-q" #'prog-indent-sexp + "M-q" #'prog-fill-reindent-defun) (defvar prog-indentation-context nil "When non-nil, provides context for indenting embedded code chunks. @@ -140,6 +145,32 @@ prog-indent-sexp (end (progn (forward-sexp 1) (point)))) (indent-region start end nil)))) +(defun prog-fill-reindent-defun (&optional argument) + "Refill paragraph or reindent the definition that the point is on. + +If the point is in a string, or in a comment, or there is a +comment on the current line, fill the paragraph that the point is +in or is on the same line. + +Otherwise, reindent the definition around or below point." + (interactive "P") + (save-excursion + (let ((treesit-text-node + (and (treesit-parser-list) + (string-match-p + treesit-text-type-regexp + (treesit-node-type (treesit-node-at (point))))))) + (if (or treesit-text-node + (nth 8 (syntax-ppss)) + (re-search-forward comment-start-skip (line-end-position) t)) + (if (memq fill-paragraph-function '(t nil)) + (lisp-fill-paragraph argument) + (funcall fill-paragraph-function argument)) + (beginning-of-defun) + (let ((start (point))) + (end-of-defun) + (indent-region start (point) nil)))))) + (defun prog-first-column () "Return the indentation column normally used for top-level constructs." (or (car prog-indentation-context) 0)) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index ebee703499..f678e10fdf 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -6631,6 +6631,8 @@ python-ts-mode #'python-imenu-treesit-create-index) (setq-local treesit-defun-type-regexp (rx (or "function" "class") "_definition")) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment"))) (treesit-major-mode-setup) (when python-indent-guess-indent-offset diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index e170d18afe..1605e40347 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1619,6 +1619,10 @@ bash-ts-mode ( bracket delimiter misc-punctuation operator))) (setq-local treesit-font-lock-settings sh-mode--treesit-settings) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "heredoc_start" + "heredoc_body"))) (treesit-major-mode-setup))) (advice-add 'bash-ts-mode :around #'sh--redirect-bash-ts-mode diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 20916eaf37..74462bd232 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -74,6 +74,7 @@ typescript-ts-mode--indent-rules ((parent-is "member_expression") parent-bol typescript-ts-mode-indent-offset) ((parent-is "named_imports") parent-bol typescript-ts-mode-indent-offset) ((parent-is "statement_block") parent-bol typescript-ts-mode-indent-offset) + ((parent-is "class_body") parent-bol typescript-ts-mode-indent-offset) ((parent-is "type_arguments") parent-bol typescript-ts-mode-indent-offset) ((parent-is "variable_declarator") parent-bol typescript-ts-mode-indent-offset) ((parent-is "arguments") parent-bol typescript-ts-mode-indent-offset) @@ -323,6 +324,11 @@ typescript-ts-base-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-defun-prefer-top-level t) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "template_string"))) + ;; Electric (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 8a66986dc6..f5b7c3ce3d 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1834,6 +1834,8 @@ css-ts-mode (treesit-parser-create 'css) (setq-local treesit-simple-indent-rules css--treesit-indent-rules) (setq-local treesit-defun-type-regexp "rule_set") + (setq-local treesit-text-type-regexp + (regexp-opt '("comment"))) (setq-local treesit-font-lock-settings css--treesit-settings) (setq-local treesit-font-lock-feature-list '((selector comment query keyword) diff --git a/lisp/treesit.el b/lisp/treesit.el index dbbf7ec18c..11fb699180 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1626,6 +1626,15 @@ treesit-end-of-defun (when top (goto-char (treesit-node-end top))))) +(defvar-local treesit-text-type-regexp nil + "A regexp that matches the node type of textual nodes. + +A textual node is a node that is not normal code, such as +comments and multiline string literals. For example, +\"(line|block)_comment\" in the case of a comment, or +\"text_block\" in the case of a string. This is used by +`prog-fill-reindent-defun' and friends.") + ;;; Activating tree-sitter (defun treesit-ready-p (language &optional quiet) -- 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 09 08:38:39 2022 Received: (at 59662) by debbugs.gnu.org; 9 Dec 2022 13:38:39 +0000 Received: from localhost ([127.0.0.1]:36156 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3daI-0001wy-QY for submit@debbugs.gnu.org; Fri, 09 Dec 2022 08:38:39 -0500 Received: from mail-wm1-f50.google.com ([209.85.128.50]:54914) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3da2-0001wf-Pv for 59662@debbugs.gnu.org; Fri, 09 Dec 2022 08:38:37 -0500 Received: by mail-wm1-f50.google.com with SMTP id o15so3263102wmr.4 for <59662@debbugs.gnu.org>; Fri, 09 Dec 2022 05:38:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=VETmO8MHn+pA0JPcqLEeYQ9PlzmTC/pE1Mru63p0q1k=; b=EvagWhOUas++CqZDFrCTrg0otYLxyII/CMXiHvEvPletI06zeFvioMa8g2z9coMaBd PsObgRuDgk3m2F/WWyvAdtKKS6YyivaHI1C3pXissQqPc8p93Eg0jYG5lnwpyHilXnw+ NNbU2r1Wo6WFLHwvrxMWwvvr2/vE/f0qXUCcR3KZr1uUVH3Y83mhSItZniahp/tBOdtC nz+yUiE4fMjivNeGkX1RuW6Dx1NzhWbioOaB0lQLd/NimD13h/aWSe9yeuejrpqAdJD+ t82T+H74Ek8bVPnyZxtARvCn+uv8TP9Bz519Yqhyi31HEwMN78WImcb5d/LoCtl9t8kx uO/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VETmO8MHn+pA0JPcqLEeYQ9PlzmTC/pE1Mru63p0q1k=; b=bjdoj3QMFkejGhVp6ZLQiw4MRrcR5sswmU6lo2dFs3vVmY7LiZrf20zVSIH6Wap3g8 ZvKQRopbwEn/S8o95wS2VqfBcQhGvrbJjcIrW1X2N4tpjk4GaL6soTnrkc/zfItImLS2 /4VDxyI6gq+larnPY48Wwjleeni/jDNPmuiwZFmm+26oY1pop47L4+ynn0EPY8sJdXQe xMJMS/9ZjXszOFNduMVUu9ihpKlnfB+Kjs0gzrDbB0gZ56jYrb8ixMiSvDElQYJStJ/1 JGZWgVD/dMy5LuYaTLlY7UFV8Kb9MmiqQ5y7rQzFIMGanFAgR8bMMCx/g+TqgqCv5cMF rawQ== X-Gm-Message-State: ANoB5pkTxtLlRY0ALldEoe6Ybi01PJe7/E3vXgOq27uZAxLQ8mHLEf3I iELT82hbN1IZuaNfb+UWN2k= X-Google-Smtp-Source: AA0mqf61BSXdRBPDhX9foZa195N5d2sr7H89b9O34h8LNe+a3smsV3amRdFCOcUrOniGkaHopN7lYw== X-Received: by 2002:a05:600c:34cb:b0:3d1:f16d:5848 with SMTP id d11-20020a05600c34cb00b003d1f16d5848mr4579652wmq.26.1670593096842; Fri, 09 Dec 2022 05:38:16 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id n13-20020a05600c4f8d00b003cfd64b6be1sm11719485wmq.27.2022.12.09.05.38.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Dec 2022 05:38:16 -0800 (PST) Message-ID: <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> Date: Fri, 9 Dec 2022 15:38:14 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US To: Theodor Thornhill , Eli Zaretskii References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <4D5A1640-4F0F-4C21-8ED6-770B88A870EA@thornhill.no> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> From: Dmitry Gutov In-Reply-To: <87o7scww07.fsf@thornhill.no> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 09/12/2022 15:24, Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > Ok! Here's the patch. What do you all think? - The NEWS entry probably doesn't need to mention syntax-ppss or tree-sitter. Those are just implementation details. - treesit-text-type-regexp could have a default value. (regexp-opt '("comment")) seems popular enough. Looks good overall. From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 09 09:46:58 2022 Received: (at 59662) by debbugs.gnu.org; 9 Dec 2022 14:46:58 +0000 Received: from localhost ([127.0.0.1]:36501 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3eeP-0005IZ-UM for submit@debbugs.gnu.org; Fri, 09 Dec 2022 09:46:58 -0500 Received: from out-200.mta0.migadu.com ([91.218.175.200]:17962) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3eeN-0005IS-T5 for 59662@debbugs.gnu.org; Fri, 09 Dec 2022 09:46:57 -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=1670597214; 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=VWQMA47TMoVldDUNpf6WJf3PI1R5fsjRgo0Gn1VbTYE=; b=FXGqtZ4kFExbrcqpCL/TCflSdlhO7drE8ksyH7pjrTJJAhsvD5d7baGPrfHREt2UwHWD1D 62UCyNBh0klijl6cj4VSzCIxZa/GLKqkaM2QqGrmYcz17/ldmM3BsVfPwzwyxhOnZIQxRd /GZrAGDUJKk9YpK18SLoyOmJKBlypKBwjApXhU/30JyqA5oX1sei/4KJOw8wy5vnhFfoSs vOFAqDX9RmOAGoUKWi0+IpK5KwjuTzA/TXwOydVilSj1zXCP+HvZaIQzccZX5GyIVR83TD QbvFmb03D8pZy09NU2fOcTw1tUmrj61RKQkDpuCBUwQYb8MQkXVGtHvChVZ6nQ== From: Theodor Thornhill To: Dmitry Gutov , Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> Date: Fri, 09 Dec 2022 15:46:53 +0100 Message-ID: <87ilikws6a.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Dmitry Gutov writes: > On 09/12/2022 15:24, Theodor Thornhill via Bug reports for GNU Emacs, > the Swiss army knife of text editors wrote: >> Ok! Here's the patch. What do you all think? > > - The NEWS entry probably doesn't need to mention syntax-ppss or > tree-sitter. Those are just implementation details. > > - treesit-text-type-regexp could have a default value. (regexp-opt > '("comment")) seems popular enough. > Something like this? > Looks good overall. Thanks! --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-prog-fill-reindent-defun-bug-59664.patch >From eb5d05795129ddd0a9aa3f8959e15cb54a9030bc Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Thu, 8 Dec 2022 20:06:09 +0100 Subject: [PATCH] Add prog-fill-reindent-defun (bug#59664) Introduce a new command that aims to reindent code in a defun, or fill a paragraph of text. The command uses treesit.el when available, otherwise falls back to using syntax-ppss and regexps. Treesit.el needs a new variable that is intended to be set by the major modes so that this and other future functions can know what kind of node we are looking at. * doc/emacs/programs.texi: Mention the new command. * etc/NEWS: Mention the new command. * lisp/progmodes/c-ts-mode.el (c-ts-mode--font-lock-settings): Add raw_string_literal for C++. (c++-ts-mode): Add regexp for the new variable. * lisp/progmodes/csharp-mode.el (csharp-ts-mode): Add regexp for the new variable. * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Add text_block as no-indent. (java-ts-mode--font-lock-settings): Add text_block font-lock-rule. (java-ts-mode): Add regexp for the new variable. * lisp/progmodes/js.el (js-ts-mode): Add regexp for the new variable. * lisp/progmodes/json-ts-mode.el (json-ts-mode--font-lock-settings): Add comment font-lock-rule. (json-ts-mode): Use the new comment feature. * list/progmodes/prog-mode.el (prog-mode-map): Bind the new command by default. (prog-fill-reindent-defun): New command. * lisp/progmodes/sh-script.el (bash-ts-mode): Add regexp for the new variable. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-base-mode): Add regexp for the new variable. (typescript-ts-mode--indent-rules): Add class_body. * lisp/treesit.el (treesit-text-type-regexp): New variable. --- doc/emacs/programs.texi | 6 +++++ etc/NEWS | 7 ++++++ lisp/progmodes/c-ts-mode.el | 8 ++++++- lisp/progmodes/csharp-mode.el | 5 ++++ lisp/progmodes/java-ts-mode.el | 19 +++++++++++++-- lisp/progmodes/js.el | 6 +++++ lisp/progmodes/json-ts-mode.el | 5 +++- lisp/progmodes/prog-mode.el | 35 ++++++++++++++++++++++++++-- lisp/progmodes/sh-script.el | 4 ++++ lisp/progmodes/typescript-ts-mode.el | 6 +++++ lisp/treesit.el | 9 +++++++ 11 files changed, 104 insertions(+), 6 deletions(-) diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index ba8475e86a..f9a15e819b 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -409,6 +409,12 @@ Multi-line Indent @table @kbd @item C-M-q Reindent all the lines within one parenthetical grouping. +@item M-q +Major modes that derive from @code{prog-mode} can reindent all the +lines within a defun at point using the command @kbd{M-q} +(@code{prog-mode-fill-reindent-defun}). The bounds of of a defun is +decided by @code{beginning-of-defun-function} and +@code{end-of-defun-function}. @item C-u @key{TAB} Shift an entire parenthetical grouping rigidly sideways so that its first line is properly indented. diff --git a/etc/NEWS b/etc/NEWS index 61f813568f..6216fd3681 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -61,6 +61,13 @@ using this new option. (Or set 'display-buffer-alist' directly.) After manually editing 'eshell-aliases-file', you can use 'M-x eshell-read-aliases-list' to load the edited aliases. +** Prog Mode ++++ +*** New command 'prog-fill-reindent-defun' +This command either fills a textual element in a defun, such as a +doc-string, or a comment. If point is inside normal code, it +(re)indents the surrounding defun. Bound by default in +'prog-mode-map' to 'M-q'. * New Modes and Packages in Emacs 30.1 diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 08b03d5666..f7285e8dd6 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -248,7 +248,9 @@ c-ts-mode--font-lock-settings :language mode :feature 'string `((string_literal) @font-lock-string-face - (system_lib_string) @font-lock-string-face) + (system_lib_string) @font-lock-string-face + ,@(when (eq mode 'cpp) + '((raw_string_literal) @font-lock-string-face))) :language mode :feature 'literal @@ -603,6 +605,10 @@ c++-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "raw_string_literal"))) + (treesit-parser-create 'cpp) (setq-local treesit-simple-indent-rules diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index 8ab5fbc91d..3faeb54fc5 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el @@ -911,6 +911,11 @@ csharp-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "verbatim_string-literal" + "interpolated_verbatim_string-text"))) + ;; Indent. (setq-local treesit-simple-indent-rules csharp-ts-mode--indent-rules) diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 96e0d5244c..f29445195a 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -68,6 +68,7 @@ java-ts-mode--indent-rules ((node-is "]") parent-bol 0) ((and (parent-is "comment") comment-end) comment-start -1) ((parent-is "comment") comment-start-skip 0) + ((parent-is "text_block") no-indent) ((parent-is "class_body") parent-bol java-ts-mode-indent-offset) ((parent-is "interface_body") parent-bol java-ts-mode-indent-offset) ((parent-is "constructor_body") parent-bol java-ts-mode-indent-offset) @@ -157,7 +158,8 @@ java-ts-mode--font-lock-settings :language 'java :override t :feature 'string - `((string_literal) @font-lock-string-face) + `((string_literal) @font-lock-string-face + (text_block) @font-lock-string-face) :language 'java :override t :feature 'literal @@ -308,6 +310,11 @@ java-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("line_comment" + "block_comment" + "text_block"))) + ;; Indent. (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) @@ -316,7 +323,15 @@ java-ts-mode (append "{}():;," electric-indent-chars)) ;; Navigation. - (setq-local treesit-defun-type-regexp "declaration") + (setq-local treesit-defun-type-regexp + (regexp-opt '("method_declaration" + "class_declaration" + "record_declaration" + "interface_declaration" + "enum_declaration" + "import_declaration" + "package_declaration" + "module_declaration"))) ;; Font-lock. (setq-local treesit-font-lock-settings java-ts-mode--font-lock-settings) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 45dfef372c..02cc558366 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3857,6 +3857,11 @@ js-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) (setq-local comment-multi-line t) + + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "template_string"))) + ;; Electric-indent. (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) ;FIXME: js2-mode adds "[]*". @@ -3868,6 +3873,7 @@ js-ts-mode ;; Indent. (setq-local treesit-simple-indent-rules js--treesit-indent-rules) ;; Navigation. + (setq-local treesit-defun-prefer-top-level t) (setq-local treesit-defun-type-regexp (rx (or "class_declaration" "method_definition" diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index 0a0113d1d8..736ff7f3cd 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -72,6 +72,9 @@ json-ts--indent-rules (defvar json-ts-mode--font-lock-settings (treesit-font-lock-rules + :language 'json + :feature 'comment + '((comment) @font-lock-comment-face) :language 'json :feature 'bracket '((["[" "]" "{" "}"]) @font-lock-bracket-face) @@ -159,7 +162,7 @@ json-ts-mode ;; Font-lock. (setq-local treesit-font-lock-settings json-ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list - '((constant number pair string) + '((comment constant number pair string) (escape-sequence) (bracket delimiter error))) diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index 58cb48f182..c29efa3a21 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -30,7 +30,11 @@ ;;; Code: (eval-when-compile (require 'cl-lib) - (require 'subr-x)) + (require 'subr-x) + (require 'treesit)) + +(declare-function treesit-parser-list "treesit.c") +(declare-function treesit-node-type "treesit.c") (defgroup prog-mode nil "Generic programming mode, from which others derive." @@ -102,7 +106,8 @@ prog-context-menu (defvar-keymap prog-mode-map :doc "Keymap used for programming modes." - "C-M-q" #'prog-indent-sexp) + "C-M-q" #'prog-indent-sexp + "M-q" #'prog-fill-reindent-defun) (defvar prog-indentation-context nil "When non-nil, provides context for indenting embedded code chunks. @@ -140,6 +145,32 @@ prog-indent-sexp (end (progn (forward-sexp 1) (point)))) (indent-region start end nil)))) +(defun prog-fill-reindent-defun (&optional argument) + "Refill paragraph or reindent the definition that the point is on. + +If the point is in a string, or in a comment, or there is a +comment on the current line, fill the paragraph that the point is +in or is on the same line. + +Otherwise, reindent the definition around or below point." + (interactive "P") + (save-excursion + (let ((treesit-text-node + (and (treesit-parser-list) + (string-match-p + treesit-text-type-regexp + (treesit-node-type (treesit-node-at (point))))))) + (if (or treesit-text-node + (nth 8 (syntax-ppss)) + (re-search-forward comment-start-skip (line-end-position) t)) + (if (memq fill-paragraph-function '(t nil)) + (lisp-fill-paragraph argument) + (funcall fill-paragraph-function argument)) + (beginning-of-defun) + (let ((start (point))) + (end-of-defun) + (indent-region start (point) nil)))))) + (defun prog-first-column () "Return the indentation column normally used for top-level constructs." (or (car prog-indentation-context) 0)) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index e170d18afe..1605e40347 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1619,6 +1619,10 @@ bash-ts-mode ( bracket delimiter misc-punctuation operator))) (setq-local treesit-font-lock-settings sh-mode--treesit-settings) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "heredoc_start" + "heredoc_body"))) (treesit-major-mode-setup))) (advice-add 'bash-ts-mode :around #'sh--redirect-bash-ts-mode diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 20916eaf37..74462bd232 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -74,6 +74,7 @@ typescript-ts-mode--indent-rules ((parent-is "member_expression") parent-bol typescript-ts-mode-indent-offset) ((parent-is "named_imports") parent-bol typescript-ts-mode-indent-offset) ((parent-is "statement_block") parent-bol typescript-ts-mode-indent-offset) + ((parent-is "class_body") parent-bol typescript-ts-mode-indent-offset) ((parent-is "type_arguments") parent-bol typescript-ts-mode-indent-offset) ((parent-is "variable_declarator") parent-bol typescript-ts-mode-indent-offset) ((parent-is "arguments") parent-bol typescript-ts-mode-indent-offset) @@ -323,6 +324,11 @@ typescript-ts-base-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-defun-prefer-top-level t) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "template_string"))) + ;; Electric (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) diff --git a/lisp/treesit.el b/lisp/treesit.el index dbbf7ec18c..32ec9ce92f 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1626,6 +1626,15 @@ treesit-end-of-defun (when top (goto-char (treesit-node-end top))))) +(defvar-local treesit-text-type-regexp (regexp-opt '("comment")) + "A regexp that matches the node type of textual nodes. + +A textual node is a node that is not normal code, such as +comments and multiline string literals. For example, +\"(line|block)_comment\" in the case of a comment, or +\"text_block\" in the case of a string. This is used by +`prog-fill-reindent-defun' and friends.") + ;;; Activating tree-sitter (defun treesit-ready-p (language &optional quiet) -- 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 09 09:56:47 2022 Received: (at 59662) by debbugs.gnu.org; 9 Dec 2022 14:56:47 +0000 Received: from localhost ([127.0.0.1]:36555 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3env-0005Sp-1V for submit@debbugs.gnu.org; Fri, 09 Dec 2022 09:56:47 -0500 Received: from mail-wr1-f43.google.com ([209.85.221.43]:33647) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3ent-0005Si-PN for 59662@debbugs.gnu.org; Fri, 09 Dec 2022 09:56:46 -0500 Received: by mail-wr1-f43.google.com with SMTP id bx10so5484037wrb.0 for <59662@debbugs.gnu.org>; Fri, 09 Dec 2022 06:56:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=j0UMZVtoIrM7NpOAWTv/tmgRekK2GfSo3T82j9lTvAI=; b=gm7DxCqpL2aM/REF+tNMvGqEJGFoayJNlWwGJ7yD8FBLsQbzcvVH7bxD+Ft2np7Wg7 Vo38Dnh//ml46KSqGG1E/32anTfcOdcXcIBqUPEHs1YA0g35d3PtOrNHzWqarxhRnOnP rmZHEAnZRqPKr9eR1c4T9EqI/y8gFLmhLfLqnYqdE/4Ho+bRlTKAqMfJWuY48ZdhXMhb soKS3lCqSsNFunx6p5V9vjxB7NvzrMmesb3HLMivVUyKoO4SRyM2S35mR639pM/th29a GHvBd+IB5giGF+/AxbVjfm4zqp6nY4+ydIht9MqHDK7N2Xi5YSFD1f407z2kqLW2E1zy iTWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=j0UMZVtoIrM7NpOAWTv/tmgRekK2GfSo3T82j9lTvAI=; b=1m+1+ZXhMTTJTnXur6KoSqVRCE1q0TK/08VTKoGS9VN271yoSBVpBVBwfH/cXRBw9i X/J9S00NoBzP0linWtzXrOsnQ3fHnc67vtyxkPHCx864lc7LsGcbc8I6Nu0KkCVwvz/6 oX5DmkJoFldK7xxKrWbXkbKttr3KMVW7sVH9/mJcpcpSX36tKAdi60gZB6tyfv1ZtK43 xk9Kn+NR4gDxslTiMPHgjR7mis3W848t12tHlMumLmPm+2dv0EOQCHcrYStfLTWy1hJL R6Wbzf90/RLSHlgLukeHmnxooDtO6BOM9fxLSLsekUb+/yy/Ye76uw+A8XVmrNR8Um7A bOtQ== X-Gm-Message-State: ANoB5pkW/IJ46WNMzrbrUVf8UKBUPyMEKQhA66vsu6SucY2BJ9OUM8sG KDhfNUk49sg1OtwbZa5nE2g= X-Google-Smtp-Source: AA0mqf7lpAe+niXTWAOJSLRGEsj2rQXEO2A/i6+9S+lXXyL2mNCG1dFMWeMKeZrbocc7mwjfix1GeQ== X-Received: by 2002:adf:eb4e:0:b0:232:be5c:bff6 with SMTP id u14-20020adfeb4e000000b00232be5cbff6mr4050852wrn.41.1670597799675; Fri, 09 Dec 2022 06:56:39 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id g4-20020a5d46c4000000b00228d52b935asm1601880wrs.71.2022.12.09.06.56.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Dec 2022 06:56:38 -0800 (PST) Message-ID: Date: Fri, 9 Dec 2022 16:56:37 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US To: Theodor Thornhill , Eli Zaretskii References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83r0xhdluq.fsf@gnu.org> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> From: Dmitry Gutov In-Reply-To: <87ilikws6a.fsf@thornhill.no> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 09/12/2022 16:46, Theodor Thornhill wrote: > Dmitry Gutov writes: > >> On 09/12/2022 15:24, Theodor Thornhill via Bug reports for GNU Emacs, >> the Swiss army knife of text editors wrote: >>> Ok! Here's the patch. What do you all think? >> >> - The NEWS entry probably doesn't need to mention syntax-ppss or >> tree-sitter. Those are just implementation details. >> >> - treesit-text-type-regexp could have a default value. (regexp-opt >> '("comment")) seems popular enough. >> > > Something like this? Yes. But... :-) I guess you can replace (regexp-opt '("comment")) with just "comment"? Both regexps are equivalent, and neither uses anchoring (like \` and \'). Should they have anchoring? The programs.texi addition should probably mention refilling too. And I see some additional changes in this patch, including ones that improve defun navigation, font-lock and indentation, in particular in java-ts-mode (but also json and typescript). These changes should probably go to emacs-29. From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 09 10:13:09 2022 Received: (at 59662) by debbugs.gnu.org; 9 Dec 2022 15:13:09 +0000 Received: from localhost ([127.0.0.1]:36727 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3f3k-0005if-9t for submit@debbugs.gnu.org; Fri, 09 Dec 2022 10:13:09 -0500 Received: from out-107.mta0.migadu.com ([91.218.175.107]:46258) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3f3h-0005iX-Oe for 59662@debbugs.gnu.org; Fri, 09 Dec 2022 10:13:07 -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=1670598784; 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=zX8wtr++0T0+Ieb4RqEA6lOT/Hn8goT9aw76K6pB9Vg=; b=B9qluPz0tip29k0v9ah9bc5iVcWtxtFyrr5LkqtWtJKhjhFK+2/FC7+iM8gUSBHknYxiNj ZF4Das8A/5XqGaI7qM5koAWDp/mkbmWFlYBVj/XQmM+0BY9aAZx9iO5+bQ1kZH5PyvVfhs 5vebjRSet/AC1M/9XGiYohhOQpYY1/HwqgxT7KCLF8+W2zekLwv/unQM7Odd900/0Vxvpi XQfzizC8CkKiz2+eDkKGRzUVKvrUuOSURljIHLEraqbhvfWdRIORkK/qMJQaIWTRfMOotK 0MUaYKXWNjZka7uxF0QNqLyoPEHcIXoW0pTspnd1Nr2oFdP1s0yDWdWgfeUfsg== From: Theodor Thornhill To: Dmitry Gutov , Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> Date: Fri, 09 Dec 2022 16:13:03 +0100 Message-ID: <87edt8wqyo.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Dmitry Gutov writes: > On 09/12/2022 16:46, Theodor Thornhill wrote: >> Dmitry Gutov writes: >> >>> On 09/12/2022 15:24, Theodor Thornhill via Bug reports for GNU Emacs, >>> the Swiss army knife of text editors wrote: >>>> Ok! Here's the patch. What do you all think? >>> >>> - The NEWS entry probably doesn't need to mention syntax-ppss or >>> tree-sitter. Those are just implementation details. >>> >>> - treesit-text-type-regexp could have a default value. (regexp-opt >>> '("comment")) seems popular enough. >>> >> >> Something like this? > > Yes. But... :-) > > I guess you can replace (regexp-opt '("comment")) with just "comment"? > Both regexps are equivalent, and neither uses anchoring (like \` and > \'). Should they have anchoring? > Hehe, I did that first, but I trusted you knew some secret about that expression. No, we get the names, so I think it's good. > The programs.texi addition should probably mention refilling too. > Good point. Will fix that. > And I see some additional changes in this patch, including ones that > improve defun navigation, font-lock and indentation, in particular in > java-ts-mode (but also json and typescript). These changes should > probably go to emacs-29. Yeah, I agree. Some of them are needed for this function to work properly, but the patches I've submitted for them have been lingering for a while. See below patch - I guess we can decide on that last remark later :-) --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-prog-fill-reindent-defun-bug-59664.patch >From fd3fd93b5c7f1340b6cc5d94a5640a999010536d Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Thu, 8 Dec 2022 20:06:09 +0100 Subject: [PATCH] Add prog-fill-reindent-defun (bug#59664) Introduce a new command that aims to reindent code in a defun, or fill a paragraph of text. The command uses treesit.el when available, otherwise falls back to using syntax-ppss and regexps. Treesit.el needs a new variable that is intended to be set by the major modes so that this and other future functions can know what kind of node we are looking at. * doc/emacs/programs.texi: Mention the new command. * etc/NEWS: Mention the new command. * lisp/progmodes/c-ts-mode.el (c-ts-mode--font-lock-settings): Add raw_string_literal for C++. (c++-ts-mode): Add regexp for the new variable. * lisp/progmodes/csharp-mode.el (csharp-ts-mode): Add regexp for the new variable. * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Add text_block as no-indent. (java-ts-mode--font-lock-settings): Add text_block font-lock-rule. (java-ts-mode): Add regexp for the new variable. * lisp/progmodes/js.el (js-ts-mode): Add regexp for the new variable. * lisp/progmodes/json-ts-mode.el (json-ts-mode--font-lock-settings): Add comment font-lock-rule. (json-ts-mode): Use the new comment feature. * list/progmodes/prog-mode.el (prog-mode-map): Bind the new command by default. (prog-fill-reindent-defun): New command. * lisp/progmodes/sh-script.el (bash-ts-mode): Add regexp for the new variable. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-base-mode): Add regexp for the new variable. (typescript-ts-mode--indent-rules): Add class_body. * lisp/treesit.el (treesit-text-type-regexp): New variable. --- doc/emacs/programs.texi | 7 ++++++ etc/NEWS | 7 ++++++ lisp/progmodes/c-ts-mode.el | 8 ++++++- lisp/progmodes/csharp-mode.el | 5 ++++ lisp/progmodes/java-ts-mode.el | 19 +++++++++++++-- lisp/progmodes/js.el | 6 +++++ lisp/progmodes/json-ts-mode.el | 5 +++- lisp/progmodes/prog-mode.el | 35 ++++++++++++++++++++++++++-- lisp/progmodes/sh-script.el | 4 ++++ lisp/progmodes/typescript-ts-mode.el | 6 +++++ lisp/treesit.el | 9 +++++++ 11 files changed, 105 insertions(+), 6 deletions(-) diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index ba8475e86a..5a3d56a228 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -409,6 +409,13 @@ Multi-line Indent @table @kbd @item C-M-q Reindent all the lines within one parenthetical grouping. +@item M-q +Major modes that derive from @code{prog-mode} can reindent or refill +all the lines within a defun at point using the command @kbd{M-q} +(@code{prog-mode-fill-reindent-defun}). The bounds of of a defun is +decided by @code{beginning-of-defun-function} and +@code{end-of-defun-function}. If point is inside a comment or a +doc-string, refill instead. @item C-u @key{TAB} Shift an entire parenthetical grouping rigidly sideways so that its first line is properly indented. diff --git a/etc/NEWS b/etc/NEWS index 61f813568f..6216fd3681 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -61,6 +61,13 @@ using this new option. (Or set 'display-buffer-alist' directly.) After manually editing 'eshell-aliases-file', you can use 'M-x eshell-read-aliases-list' to load the edited aliases. +** Prog Mode ++++ +*** New command 'prog-fill-reindent-defun' +This command either fills a textual element in a defun, such as a +doc-string, or a comment. If point is inside normal code, it +(re)indents the surrounding defun. Bound by default in +'prog-mode-map' to 'M-q'. * New Modes and Packages in Emacs 30.1 diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 08b03d5666..f7285e8dd6 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -248,7 +248,9 @@ c-ts-mode--font-lock-settings :language mode :feature 'string `((string_literal) @font-lock-string-face - (system_lib_string) @font-lock-string-face) + (system_lib_string) @font-lock-string-face + ,@(when (eq mode 'cpp) + '((raw_string_literal) @font-lock-string-face))) :language mode :feature 'literal @@ -603,6 +605,10 @@ c++-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "raw_string_literal"))) + (treesit-parser-create 'cpp) (setq-local treesit-simple-indent-rules diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index 8ab5fbc91d..3faeb54fc5 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el @@ -911,6 +911,11 @@ csharp-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "verbatim_string-literal" + "interpolated_verbatim_string-text"))) + ;; Indent. (setq-local treesit-simple-indent-rules csharp-ts-mode--indent-rules) diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 96e0d5244c..f29445195a 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -68,6 +68,7 @@ java-ts-mode--indent-rules ((node-is "]") parent-bol 0) ((and (parent-is "comment") comment-end) comment-start -1) ((parent-is "comment") comment-start-skip 0) + ((parent-is "text_block") no-indent) ((parent-is "class_body") parent-bol java-ts-mode-indent-offset) ((parent-is "interface_body") parent-bol java-ts-mode-indent-offset) ((parent-is "constructor_body") parent-bol java-ts-mode-indent-offset) @@ -157,7 +158,8 @@ java-ts-mode--font-lock-settings :language 'java :override t :feature 'string - `((string_literal) @font-lock-string-face) + `((string_literal) @font-lock-string-face + (text_block) @font-lock-string-face) :language 'java :override t :feature 'literal @@ -308,6 +310,11 @@ java-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("line_comment" + "block_comment" + "text_block"))) + ;; Indent. (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) @@ -316,7 +323,15 @@ java-ts-mode (append "{}():;," electric-indent-chars)) ;; Navigation. - (setq-local treesit-defun-type-regexp "declaration") + (setq-local treesit-defun-type-regexp + (regexp-opt '("method_declaration" + "class_declaration" + "record_declaration" + "interface_declaration" + "enum_declaration" + "import_declaration" + "package_declaration" + "module_declaration"))) ;; Font-lock. (setq-local treesit-font-lock-settings java-ts-mode--font-lock-settings) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 45dfef372c..02cc558366 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3857,6 +3857,11 @@ js-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) (setq-local comment-multi-line t) + + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "template_string"))) + ;; Electric-indent. (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) ;FIXME: js2-mode adds "[]*". @@ -3868,6 +3873,7 @@ js-ts-mode ;; Indent. (setq-local treesit-simple-indent-rules js--treesit-indent-rules) ;; Navigation. + (setq-local treesit-defun-prefer-top-level t) (setq-local treesit-defun-type-regexp (rx (or "class_declaration" "method_definition" diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index 0a0113d1d8..736ff7f3cd 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -72,6 +72,9 @@ json-ts--indent-rules (defvar json-ts-mode--font-lock-settings (treesit-font-lock-rules + :language 'json + :feature 'comment + '((comment) @font-lock-comment-face) :language 'json :feature 'bracket '((["[" "]" "{" "}"]) @font-lock-bracket-face) @@ -159,7 +162,7 @@ json-ts-mode ;; Font-lock. (setq-local treesit-font-lock-settings json-ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list - '((constant number pair string) + '((comment constant number pair string) (escape-sequence) (bracket delimiter error))) diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index 58cb48f182..c29efa3a21 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -30,7 +30,11 @@ ;;; Code: (eval-when-compile (require 'cl-lib) - (require 'subr-x)) + (require 'subr-x) + (require 'treesit)) + +(declare-function treesit-parser-list "treesit.c") +(declare-function treesit-node-type "treesit.c") (defgroup prog-mode nil "Generic programming mode, from which others derive." @@ -102,7 +106,8 @@ prog-context-menu (defvar-keymap prog-mode-map :doc "Keymap used for programming modes." - "C-M-q" #'prog-indent-sexp) + "C-M-q" #'prog-indent-sexp + "M-q" #'prog-fill-reindent-defun) (defvar prog-indentation-context nil "When non-nil, provides context for indenting embedded code chunks. @@ -140,6 +145,32 @@ prog-indent-sexp (end (progn (forward-sexp 1) (point)))) (indent-region start end nil)))) +(defun prog-fill-reindent-defun (&optional argument) + "Refill paragraph or reindent the definition that the point is on. + +If the point is in a string, or in a comment, or there is a +comment on the current line, fill the paragraph that the point is +in or is on the same line. + +Otherwise, reindent the definition around or below point." + (interactive "P") + (save-excursion + (let ((treesit-text-node + (and (treesit-parser-list) + (string-match-p + treesit-text-type-regexp + (treesit-node-type (treesit-node-at (point))))))) + (if (or treesit-text-node + (nth 8 (syntax-ppss)) + (re-search-forward comment-start-skip (line-end-position) t)) + (if (memq fill-paragraph-function '(t nil)) + (lisp-fill-paragraph argument) + (funcall fill-paragraph-function argument)) + (beginning-of-defun) + (let ((start (point))) + (end-of-defun) + (indent-region start (point) nil)))))) + (defun prog-first-column () "Return the indentation column normally used for top-level constructs." (or (car prog-indentation-context) 0)) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index e170d18afe..1605e40347 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1619,6 +1619,10 @@ bash-ts-mode ( bracket delimiter misc-punctuation operator))) (setq-local treesit-font-lock-settings sh-mode--treesit-settings) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "heredoc_start" + "heredoc_body"))) (treesit-major-mode-setup))) (advice-add 'bash-ts-mode :around #'sh--redirect-bash-ts-mode diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 20916eaf37..74462bd232 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -74,6 +74,7 @@ typescript-ts-mode--indent-rules ((parent-is "member_expression") parent-bol typescript-ts-mode-indent-offset) ((parent-is "named_imports") parent-bol typescript-ts-mode-indent-offset) ((parent-is "statement_block") parent-bol typescript-ts-mode-indent-offset) + ((parent-is "class_body") parent-bol typescript-ts-mode-indent-offset) ((parent-is "type_arguments") parent-bol typescript-ts-mode-indent-offset) ((parent-is "variable_declarator") parent-bol typescript-ts-mode-indent-offset) ((parent-is "arguments") parent-bol typescript-ts-mode-indent-offset) @@ -323,6 +324,11 @@ typescript-ts-base-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-defun-prefer-top-level t) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "template_string"))) + ;; Electric (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) diff --git a/lisp/treesit.el b/lisp/treesit.el index dbbf7ec18c..a7b4ae1591 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1626,6 +1626,15 @@ treesit-end-of-defun (when top (goto-char (treesit-node-end top))))) +(defvar-local treesit-text-type-regexp "comment" + "A regexp that matches the node type of textual nodes. + +A textual node is a node that is not normal code, such as +comments and multiline string literals. For example, +\"(line|block)_comment\" in the case of a comment, or +\"text_block\" in the case of a string. This is used by +`prog-fill-reindent-defun' and friends.") + ;;; Activating tree-sitter (defun treesit-ready-p (language &optional quiet) -- 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 09 10:27:28 2022 Received: (at 59662) by debbugs.gnu.org; 9 Dec 2022 15:27:28 +0000 Received: from localhost ([127.0.0.1]:36804 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3fHc-0005sd-DN for submit@debbugs.gnu.org; Fri, 09 Dec 2022 10:27:28 -0500 Received: from mail-wm1-f53.google.com ([209.85.128.53]:44761) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3fHZ-0005sX-Vp for 59662@debbugs.gnu.org; Fri, 09 Dec 2022 10:27:26 -0500 Received: by mail-wm1-f53.google.com with SMTP id j5-20020a05600c410500b003cfa9c0ea76so70660wmi.3 for <59662@debbugs.gnu.org>; Fri, 09 Dec 2022 07:27:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=y3p0XtoicVOu7ldFKlEa8OlumkPanQdYKOtxwmAzPWE=; b=QfIzZJXjnbEqzLNh3t+DlZul0JI7hpjMuNCbDcCK6pF1QyX3S6dYkfqzwtvUUey3Gh GeLSUhCyQt2/8iNv/rBtrHUYQ6kLyjAhGGBvdZDnbSB4dJRtk5yfAPpJy12it1OWPyNZ ueb7eqyOTEQ9eQsT2CKbA/gE6DEaXb15YyvMq6oYR9t5TSXwMJYr7sQC5GBXi0mYvVRB wA4K0/cdtjdnCyM5l8vveePcGF0S7rtWjdNUAm05ck+4tLfP6gYyLSmNjxZcrq3TW0ps 7Vxc9IHbnTh7Cjhb5wqhKAK5FFFuEjgeiGD6L2fsk1b/Xjk2NPSc1Es63lxJqwsluN7M rebw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=y3p0XtoicVOu7ldFKlEa8OlumkPanQdYKOtxwmAzPWE=; b=pX2CctPfYOIpqPw+ElZC8q3PZYjIToky50jMpIfB1+p65VyQ/jpuIKbb7EfFXuhmjt mpZ3E9+bkKZ7Ca1p2/SSx/k1Ab3Mi06IFnE3C8oQ1y1EGUKRuCXYrX9hjaGIu3yN5nor CrqbnoqQtaRuaXzvKwU/CjMka2ph8eZA7gnLXOl694GIyho2gPN790UzxZV7j/X38abD 1psQfZg7ITuNsaNiiwcJhAilcjz52EjZuOglJHKRSoDGa7WGODfJn2FAqgz9ueHLeTXW G6SqbFMSBr/wP8RvihbRxIiGczpTXui26j56WhM3Op26OfZVTs7soY/tB4IwQaVtlnlD 7FQA== X-Gm-Message-State: ANoB5plGp0fbuENFTaEUFWxKa6cNTnLtCej9BzMGf0AvANmNzen4PDKH Ukk00iF8l9v9Ih2l0JJOtIY= X-Google-Smtp-Source: AA0mqf71FIi5tHN3HWP0TW+sxw8f1jRh/LWsQpDucFbj/VcTUNd/pL2GZa5y+SyIGTLCK2qI0lWr/w== X-Received: by 2002:a05:600c:4f93:b0:3cf:6e85:eda7 with SMTP id n19-20020a05600c4f9300b003cf6e85eda7mr5339516wmq.14.1670599638781; Fri, 09 Dec 2022 07:27:18 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id iv15-20020a05600c548f00b003d1f3e9df3csm123932wmb.7.2022.12.09.07.27.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Dec 2022 07:27:17 -0800 (PST) Message-ID: <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> Date: Fri, 9 Dec 2022 17:27:16 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US To: Theodor Thornhill , Eli Zaretskii References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> From: Dmitry Gutov In-Reply-To: <87edt8wqyo.fsf@thornhill.no> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 09/12/2022 17:13, Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: >>> Something like this? >> >> Yes. But... :-) >> >> I guess you can replace (regexp-opt '("comment")) with just "comment"? >> Both regexps are equivalent, and neither uses anchoring (like \` and >> \'). Should they have anchoring? >> > > Hehe, I did that first, but I trusted you knew some secret about that > expression. No, we get the names, so I think it's good. Shouldn't trust me that much ;-) It could be a problem if some grammar somewhere will have a node type called "not_comment", and the regexp will still match it. Or "pseudo_string", etc. Not sure how realistic that scenario is, up to you. The authors of such major modes could opt for a stricted regexp individually, too. >> The programs.texi addition should probably mention refilling too. >> > > Good point. Will fix that. Still not ideal: it says "refill all the lines within a defun", but the refilling step only touches the paragraph around point. Also about NEWS: "textual element" is a little value; it really refills a single paragraph. That distinction is meaningful when a string or a comment are long, containing several paragraphs inside. From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 09 10:29:59 2022 Received: (at 59662) by debbugs.gnu.org; 9 Dec 2022 15:29:59 +0000 Received: from localhost ([127.0.0.1]:36821 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3fK3-0005ts-Im for submit@debbugs.gnu.org; Fri, 09 Dec 2022 10:29:59 -0500 Received: from mail-wr1-f50.google.com ([209.85.221.50]:43769) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3fK1-0005tW-Tk for 59662@debbugs.gnu.org; Fri, 09 Dec 2022 10:29:58 -0500 Received: by mail-wr1-f50.google.com with SMTP id h12so5539949wrv.10 for <59662@debbugs.gnu.org>; Fri, 09 Dec 2022 07:29:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=81/LO1tSWmT7138LfegSoOkkpeiiJ3+QYCYt9SkiCUc=; b=mRV/iZAJoL4vxOBRzPkQMxe13V8boZd4L8phzDcvxQeDCy7S3p2C2pWtJaX61h1rIn RtBTYlhsqRBIOGKXfD9Ke010Hv5dCI7sC3xfysuHEQ52XcSO4vnILZWIeJqdjfF967kA 6dS7AGqVreSVC5/S0AMS0enmdOTLPBt8K/GgovD9SHLrZa0jAcREDP+9GsBlUI4s9Ksd MZPvM+ERyjDjOGMenh9AzhHoTvuN0KlrZHmennnKqHiNPuoOt735S9b3a+oVfyCihz+R wd56YBaNR1X+0TPEMbohOVX2P7BtU9EMJKF2/c/yjOdJdlkPC3kwqFESYgz5GgPpeuax lbGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=81/LO1tSWmT7138LfegSoOkkpeiiJ3+QYCYt9SkiCUc=; b=S4Um3WOIWbGAAdlTrBFrUNJ1+92l2qKQyxBYDlHAxISmIL3wmloEYlJ8KgWV1+7MjU pT8PZgSccCzbNJrpC14J+L0UbcmC8HLZ3ZCx3qba2KKYJrnjzHhUO4mYqMPVtOWRFmPj 2DnfZ4X3J7uQrfNrSB+nuf6HC4ciUMnqoJ9rVHpaA/VJAruVu7Oik+VFa5GWCAS2SKru 9s2aZPov4bEm5MKRNkAfJWyMTtUdAbG5XH5/8/colbcK5ZJll7mRqg1TM+SoB3DDIOqZ 9eFC8nA0mJzwWS0PX9GhaY5Lpt85qdgFuNh32hRHWWD2xrEWzYe0UERHzbrckIznuUX8 YCAw== X-Gm-Message-State: ANoB5plBblXXzzmtOkY2tiQ1Naeo6S9ral7bMIPyBuExLwRs0uz6loiT sLUZPligdNjzLDkUZUkcIOc= X-Google-Smtp-Source: AA0mqf642I1qnMyaHX3kmdyEwP+zhdGAhTMkxbKy/x1zeqcFxmJw77MXf30uyp9SWORe1TJ5HAiVVA== X-Received: by 2002:adf:f550:0:b0:242:1f22:df35 with SMTP id j16-20020adff550000000b002421f22df35mr4394607wrp.22.1670599792123; Fri, 09 Dec 2022 07:29:52 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id b14-20020adff24e000000b002421db5f279sm1692237wrp.78.2022.12.09.07.29.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Dec 2022 07:29:51 -0800 (PST) Message-ID: Date: Fri, 9 Dec 2022 17:29:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US From: Dmitry Gutov To: Theodor Thornhill , Eli Zaretskii References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <3e25eadb-3f2b-f92d-8b18-bf1daca91b64@yandex.ru> <83wn78cqz4.fsf@gnu.org> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> In-Reply-To: <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) Sorry: On 09/12/2022 17:27, Dmitry Gutov wrote: > "textual element" is a little value; ^ vague From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 09 10:50:33 2022 Received: (at 59662) by debbugs.gnu.org; 9 Dec 2022 15:50:33 +0000 Received: from localhost ([127.0.0.1]:36926 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3fdw-00069B-Rb for submit@debbugs.gnu.org; Fri, 09 Dec 2022 10:50:33 -0500 Received: from out2.migadu.com ([188.165.223.204]:32206) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3fdt-000694-GR for 59662@debbugs.gnu.org; Fri, 09 Dec 2022 10:50:31 -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=1670601027; 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=vMvMGmNJrb+FEq9+YTblI2/6GOY74vCCOLTsLnKOLxY=; b=LtK9QCShkzEcYenrRTZ2O3ZsSUo0mzT4eIurThcmUysaYGkVLIxU7oVNSvhz09GAyvh98w OOGY2Xs6KUIBY+zNVqzQKIrKlCAZ81ZVyGCNUoWMFbO2LO+yuBGI8fLQtPjtZIoaXAdnQx PrMKfblh8wAME+QCzXs7nTEP4O25Bda3/GQAKs7wkym6fLSP+ze687M3wPCSYp4dnd7q0z UFKr4dENYyojT+0XL9LB4508dNzZ3xpx8CNBb+jNbGPRWb0hlnv4oJfx0DZz+rJyFFGPid J/mb4UdgqUZh7DpVqmCdKdTh69nur5SxADhsCZu5EeG3hoioLJwoRGFVoBKPow== From: Theodor Thornhill To: Dmitry Gutov , Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> Date: Fri, 09 Dec 2022 16:50:25 +0100 Message-ID: <87wn70injy.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Dmitry Gutov writes: > On 09/12/2022 17:13, Theodor Thornhill via Bug reports for GNU Emacs, > the Swiss army knife of text editors wrote: >>>> Something like this? >>> >>> Yes. But... :-) >>> >>> I guess you can replace (regexp-opt '("comment")) with just "comment"? >>> Both regexps are equivalent, and neither uses anchoring (like \` and >>> \'). Should they have anchoring? >>> >> >> Hehe, I did that first, but I trusted you knew some secret about that >> expression. No, we get the names, so I think it's good. > > Shouldn't trust me that much ;-) > :-) > It could be a problem if some grammar somewhere will have a node type > called "not_comment", and the regexp will still match it. Or > "pseudo_string", etc. > > Not sure how realistic that scenario is, up to you. The authors of such > major modes could opt for a stricted regexp individually, too. > Right. Yeah, I don't think it'll be a problem, but better to be on the safe side. Tweaked the regexp a little >>> The programs.texi addition should probably mention refilling too. >>> >> >> Good point. Will fix that. > > Still not ideal: it says "refill all the lines within a defun", but the > refilling step only touches the paragraph around point. > > Also about NEWS: "textual element" is a little value; it really refills > a single paragraph. That distinction is meaningful when a string or a > comment are long, containing several paragraphs inside. Something like this? Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-prog-fill-reindent-defun-bug-59664.patch >From 8e8e045423f6aba96d660f30a7a4e96073d2ad75 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Thu, 8 Dec 2022 20:06:09 +0100 Subject: [PATCH] Add prog-fill-reindent-defun (bug#59664) Introduce a new command that aims to reindent code in a defun, or fill a paragraph of text. The command uses treesit.el when available, otherwise falls back to using syntax-ppss and regexps. Treesit.el needs a new variable that is intended to be set by the major modes so that this and other future functions can know what kind of node we are looking at. * doc/emacs/programs.texi: Mention the new command. * etc/NEWS: Mention the new command. * lisp/progmodes/c-ts-mode.el (c-ts-mode--font-lock-settings): Add raw_string_literal for C++. (c++-ts-mode): Add regexp for the new variable. * lisp/progmodes/csharp-mode.el (csharp-ts-mode): Add regexp for the new variable. * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Add text_block as no-indent. (java-ts-mode--font-lock-settings): Add text_block font-lock-rule. (java-ts-mode): Add regexp for the new variable. * lisp/progmodes/js.el (js-ts-mode): Add regexp for the new variable. * lisp/progmodes/json-ts-mode.el (json-ts-mode--font-lock-settings): Add comment font-lock-rule. (json-ts-mode): Use the new comment feature. * list/progmodes/prog-mode.el (prog-mode-map): Bind the new command by default. (prog-fill-reindent-defun): New command. * lisp/progmodes/sh-script.el (bash-ts-mode): Add regexp for the new variable. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-base-mode): Add regexp for the new variable. (typescript-ts-mode--indent-rules): Add class_body. * lisp/treesit.el (treesit-text-type-regexp): New variable. --- doc/emacs/programs.texi | 8 +++++++ etc/NEWS | 7 ++++++ lisp/progmodes/c-ts-mode.el | 8 ++++++- lisp/progmodes/csharp-mode.el | 5 ++++ lisp/progmodes/java-ts-mode.el | 19 +++++++++++++-- lisp/progmodes/js.el | 6 +++++ lisp/progmodes/json-ts-mode.el | 5 +++- lisp/progmodes/prog-mode.el | 35 ++++++++++++++++++++++++++-- lisp/progmodes/sh-script.el | 4 ++++ lisp/progmodes/typescript-ts-mode.el | 6 +++++ lisp/treesit.el | 9 +++++++ 11 files changed, 106 insertions(+), 6 deletions(-) diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index ba8475e86a..cc06a003e2 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -409,6 +409,14 @@ Multi-line Indent @table @kbd @item C-M-q Reindent all the lines within one parenthetical grouping. +@item M-q +Major modes that derive from @code{prog-mode} can reindent all the +lines within a defun around point using +@code{prog-mode-fill-reindent-defun}. The bounds of of a defun is +decided by @code{beginning-of-defun-function} and +@code{end-of-defun-function}. If point is inside a comment or a +doc-string, refill that paragraph instead, using +@code{fill-paragraph-function}. @item C-u @key{TAB} Shift an entire parenthetical grouping rigidly sideways so that its first line is properly indented. diff --git a/etc/NEWS b/etc/NEWS index 61f813568f..659ee39faf 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -61,6 +61,13 @@ using this new option. (Or set 'display-buffer-alist' directly.) After manually editing 'eshell-aliases-file', you can use 'M-x eshell-read-aliases-list' to load the edited aliases. +** Prog Mode ++++ +*** New command 'prog-fill-reindent-defun' +This command either fills a single paragraph in a defun, such as a +doc-string, or a comment. If point is inside normal code, it +(re)indents the surrounding defun. Bound by default in +'prog-mode-map' to 'M-q'. * New Modes and Packages in Emacs 30.1 diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 08b03d5666..f7285e8dd6 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -248,7 +248,9 @@ c-ts-mode--font-lock-settings :language mode :feature 'string `((string_literal) @font-lock-string-face - (system_lib_string) @font-lock-string-face) + (system_lib_string) @font-lock-string-face + ,@(when (eq mode 'cpp) + '((raw_string_literal) @font-lock-string-face))) :language mode :feature 'literal @@ -603,6 +605,10 @@ c++-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "raw_string_literal"))) + (treesit-parser-create 'cpp) (setq-local treesit-simple-indent-rules diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index 8ab5fbc91d..3faeb54fc5 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el @@ -911,6 +911,11 @@ csharp-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "verbatim_string-literal" + "interpolated_verbatim_string-text"))) + ;; Indent. (setq-local treesit-simple-indent-rules csharp-ts-mode--indent-rules) diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 96e0d5244c..f29445195a 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -68,6 +68,7 @@ java-ts-mode--indent-rules ((node-is "]") parent-bol 0) ((and (parent-is "comment") comment-end) comment-start -1) ((parent-is "comment") comment-start-skip 0) + ((parent-is "text_block") no-indent) ((parent-is "class_body") parent-bol java-ts-mode-indent-offset) ((parent-is "interface_body") parent-bol java-ts-mode-indent-offset) ((parent-is "constructor_body") parent-bol java-ts-mode-indent-offset) @@ -157,7 +158,8 @@ java-ts-mode--font-lock-settings :language 'java :override t :feature 'string - `((string_literal) @font-lock-string-face) + `((string_literal) @font-lock-string-face + (text_block) @font-lock-string-face) :language 'java :override t :feature 'literal @@ -308,6 +310,11 @@ java-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("line_comment" + "block_comment" + "text_block"))) + ;; Indent. (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) @@ -316,7 +323,15 @@ java-ts-mode (append "{}():;," electric-indent-chars)) ;; Navigation. - (setq-local treesit-defun-type-regexp "declaration") + (setq-local treesit-defun-type-regexp + (regexp-opt '("method_declaration" + "class_declaration" + "record_declaration" + "interface_declaration" + "enum_declaration" + "import_declaration" + "package_declaration" + "module_declaration"))) ;; Font-lock. (setq-local treesit-font-lock-settings java-ts-mode--font-lock-settings) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 45dfef372c..02cc558366 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3857,6 +3857,11 @@ js-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) (setq-local comment-multi-line t) + + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "template_string"))) + ;; Electric-indent. (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) ;FIXME: js2-mode adds "[]*". @@ -3868,6 +3873,7 @@ js-ts-mode ;; Indent. (setq-local treesit-simple-indent-rules js--treesit-indent-rules) ;; Navigation. + (setq-local treesit-defun-prefer-top-level t) (setq-local treesit-defun-type-regexp (rx (or "class_declaration" "method_definition" diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index 0a0113d1d8..736ff7f3cd 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -72,6 +72,9 @@ json-ts--indent-rules (defvar json-ts-mode--font-lock-settings (treesit-font-lock-rules + :language 'json + :feature 'comment + '((comment) @font-lock-comment-face) :language 'json :feature 'bracket '((["[" "]" "{" "}"]) @font-lock-bracket-face) @@ -159,7 +162,7 @@ json-ts-mode ;; Font-lock. (setq-local treesit-font-lock-settings json-ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list - '((constant number pair string) + '((comment constant number pair string) (escape-sequence) (bracket delimiter error))) diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index 58cb48f182..c29efa3a21 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -30,7 +30,11 @@ ;;; Code: (eval-when-compile (require 'cl-lib) - (require 'subr-x)) + (require 'subr-x) + (require 'treesit)) + +(declare-function treesit-parser-list "treesit.c") +(declare-function treesit-node-type "treesit.c") (defgroup prog-mode nil "Generic programming mode, from which others derive." @@ -102,7 +106,8 @@ prog-context-menu (defvar-keymap prog-mode-map :doc "Keymap used for programming modes." - "C-M-q" #'prog-indent-sexp) + "C-M-q" #'prog-indent-sexp + "M-q" #'prog-fill-reindent-defun) (defvar prog-indentation-context nil "When non-nil, provides context for indenting embedded code chunks. @@ -140,6 +145,32 @@ prog-indent-sexp (end (progn (forward-sexp 1) (point)))) (indent-region start end nil)))) +(defun prog-fill-reindent-defun (&optional argument) + "Refill paragraph or reindent the definition that the point is on. + +If the point is in a string, or in a comment, or there is a +comment on the current line, fill the paragraph that the point is +in or is on the same line. + +Otherwise, reindent the definition around or below point." + (interactive "P") + (save-excursion + (let ((treesit-text-node + (and (treesit-parser-list) + (string-match-p + treesit-text-type-regexp + (treesit-node-type (treesit-node-at (point))))))) + (if (or treesit-text-node + (nth 8 (syntax-ppss)) + (re-search-forward comment-start-skip (line-end-position) t)) + (if (memq fill-paragraph-function '(t nil)) + (lisp-fill-paragraph argument) + (funcall fill-paragraph-function argument)) + (beginning-of-defun) + (let ((start (point))) + (end-of-defun) + (indent-region start (point) nil)))))) + (defun prog-first-column () "Return the indentation column normally used for top-level constructs." (or (car prog-indentation-context) 0)) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index e170d18afe..1605e40347 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1619,6 +1619,10 @@ bash-ts-mode ( bracket delimiter misc-punctuation operator))) (setq-local treesit-font-lock-settings sh-mode--treesit-settings) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "heredoc_start" + "heredoc_body"))) (treesit-major-mode-setup))) (advice-add 'bash-ts-mode :around #'sh--redirect-bash-ts-mode diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 20916eaf37..74462bd232 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -74,6 +74,7 @@ typescript-ts-mode--indent-rules ((parent-is "member_expression") parent-bol typescript-ts-mode-indent-offset) ((parent-is "named_imports") parent-bol typescript-ts-mode-indent-offset) ((parent-is "statement_block") parent-bol typescript-ts-mode-indent-offset) + ((parent-is "class_body") parent-bol typescript-ts-mode-indent-offset) ((parent-is "type_arguments") parent-bol typescript-ts-mode-indent-offset) ((parent-is "variable_declarator") parent-bol typescript-ts-mode-indent-offset) ((parent-is "arguments") parent-bol typescript-ts-mode-indent-offset) @@ -323,6 +324,11 @@ typescript-ts-base-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-defun-prefer-top-level t) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "template_string"))) + ;; Electric (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) diff --git a/lisp/treesit.el b/lisp/treesit.el index dbbf7ec18c..41feac35c2 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1626,6 +1626,15 @@ treesit-end-of-defun (when top (goto-char (treesit-node-end top))))) +(defvar-local treesit-text-type-regexp "\\`comment\\'" + "A regexp that matches the node type of textual nodes. + +A textual node is a node that is not normal code, such as +comments and multiline string literals. For example, +\"(line|block)_comment\" in the case of a comment, or +\"text_block\" in the case of a string. This is used by +`prog-fill-reindent-defun' and friends.") + ;;; Activating tree-sitter (defun treesit-ready-p (language &optional quiet) -- 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 09 11:05:31 2022 Received: (at 59662) by debbugs.gnu.org; 9 Dec 2022 16:05:31 +0000 Received: from localhost ([127.0.0.1]:37004 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3fsR-0006J4-GU for submit@debbugs.gnu.org; Fri, 09 Dec 2022 11:05:31 -0500 Received: from mail-wr1-f44.google.com ([209.85.221.44]:37883) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3fsP-0006It-MI for 59662@debbugs.gnu.org; Fri, 09 Dec 2022 11:05:29 -0500 Received: by mail-wr1-f44.google.com with SMTP id co23so5673297wrb.4 for <59662@debbugs.gnu.org>; Fri, 09 Dec 2022 08:05:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=2eo/vMWawsBtCOtF+Me8ozseVfU9luxT/LiM+Mdn9gs=; b=M4Ous2/+SZlRfxaRWyNQLF+uT08Ygby6uvfVNujWYOFxHq6gSn49yPH8Dvq5C4xx9A M6h+APssej5tRfJI3zwUkhk3UlwUbczhAqrfgo/qO+9wuZffWDNnGjqq28YidLKAy+Zb n25rxXpAR5UPm8HbEILk/1oYBTPRcNVSl0nBikifSL/teDoqCsY8eODYRaI87b2maMCv cXlGojD1dEj8jCYO5DZR4oZpvopdxYTcMfRvmdvwAMxAH5eH6dmVISbPITXhITvngdpS blU5VfIGhSy9HNE17IAE8GkxeCFjuA12kh2AJLlwsxh+xWR5yz2Xt0MqVI0Br62GvFS5 ZXZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2eo/vMWawsBtCOtF+Me8ozseVfU9luxT/LiM+Mdn9gs=; b=DLrrLwjGGHGt360twPib1LnYy00W2kXVeyXjg3OzEkICT1MbvoHUsJSawSJv2CJT9u m+otIS/N6i/m43073gXy4uoMrV6aTVf5qVWOsdyhHo7bnhxxwt4ZgqzntwwLvmx+YZUo vknRfVlclQ74xsf7xyirmcUyf7iAQH0zQo/BQsZy25+AHB5MgP7T6zrEt0xoEhU1Pcg5 TEQ1J9/JiCbau6Que7j+I2qJ67NyQ0DydLm/e6/fmfCmspImQWpENgn0LK14H5NXVrGK 1jomdDCNsqTZ3dwxPAav2cQ0tmYo6r5cVilVHLr7z4OjG5NKTHlukwQ7oqnFjvb+IzbT aNGg== X-Gm-Message-State: ANoB5pl8wLGKT3ES73KAxChqjhDHVMzJebwi8DGidw4gNbXJgfGOnKSa adGmu8mzRbMcc8fdjbDG7Mk= X-Google-Smtp-Source: AA0mqf7m/GRVsiK/QSsUZctiHO3aUHn5hn0y+GQg3DeNp6Ac+OpbwBzBpG+pBGxVVasOeaI9/YkruQ== X-Received: by 2002:adf:e405:0:b0:24a:9a21:c9e with SMTP id g5-20020adfe405000000b0024a9a210c9emr1358750wrm.59.1670601923703; Fri, 09 Dec 2022 08:05:23 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id v3-20020a5d6103000000b002423edd7e50sm1757200wrt.32.2022.12.09.08.05.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Dec 2022 08:05:23 -0800 (PST) Message-ID: Date: Fri, 9 Dec 2022 18:05:21 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US To: Theodor Thornhill , Eli Zaretskii References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> <87wn70injy.fsf@thornhill.no> From: Dmitry Gutov In-Reply-To: <87wn70injy.fsf@thornhill.no> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 09/12/2022 17:50, Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > Something like this? Looking good, thanks! From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 09 14:15:52 2022 Received: (at 59662) by debbugs.gnu.org; 9 Dec 2022 19:15:52 +0000 Received: from localhost ([127.0.0.1]:37914 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3iqd-00025C-D3 for submit@debbugs.gnu.org; Fri, 09 Dec 2022 14:15:52 -0500 Received: from out2.migadu.com ([188.165.223.204]:53711) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3iqa-000253-Qz for 59662@debbugs.gnu.org; Fri, 09 Dec 2022 14:15:50 -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=1670613347; 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=uQasnKLyO/SH322RqoT6NY5raCg3COyDFcJeAD+ho70=; b=grSKk8NokNQNCXY6fhG7+t69pVh8CgOVrSpd8mqqJW4Fpv49bQ+A+SV1FsrqeQVI9kKIwt pMqqDGls8FfwTmJoT2Qk4zi51BmcKEWttWVh81zLQO4+DCUpSG8gr5AanXXN/jr6ApTCx5 bs+W7IEzW0TaxF1+CA7A+WKHkyPabsc5F0E4uxsHMpq7GAdEWBX4QtUydqPZX+SwTyTrkA /aqtw/z0MBy+k10DmA18pol9PMzpbWdwRXVXgikQU27F2Vz04kezfpDYG0L/gdLmis2MHf 09Y7uoDKkD7NTmraj5lr7GVLba5ifQh6SEcRblhwSyf4rIo1Qf/HWM6IZFkb0w== From: Theodor Thornhill To: Dmitry Gutov , Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> <87wn70injy.fsf@thornhill.no> Date: Fri, 09 Dec 2022 20:15:45 +0100 Message-ID: <87r0x8ie1q.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Dmitry Gutov writes: > On 09/12/2022 17:50, Theodor Thornhill via Bug reports for GNU Emacs, > the Swiss army knife of text editors wrote: >> Something like this? > > Looking good, thanks! My pleasure. I removed the code that should go to emacs-29. Can you install if you agree with this patch, Dmitry? Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-prog-fill-reindent-defun-bug-59664.patch >From 6f5e1c917ce49245ad40f12ed6789e6cb33e51fd Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Fri, 9 Dec 2022 20:12:51 +0100 Subject: [PATCH] Add prog-fill-reindent-defun (bug#59664) Introduce a new command that aims to reindent code in a defun, or fill a paragraph of text. The command uses treesit.el when available, otherwise falls back to using syntax-ppss and regexps. Treesit.el needs a new variable that is intended to be set by the major modes so that this and other future functions can know what kind of node we are looking at. * doc/emacs/programs.texi: Mention the new command. * etc/NEWS: Mention the new command. * lisp/progmodes/c-ts-mode.el (c++-ts-mode): Add regexp for the new variable. * lisp/progmodes/csharp-mode.el (csharp-ts-mode): Add regexp for the new variable. * lisp/progmodes/java-ts-mode.el (java-ts-mode): Add regexp for the new variable. * lisp/progmodes/js.el (js-ts-mode): Add regexp for the new variable. * list/progmodes/prog-mode.el (prog-mode-map): Bind the new command by default. (prog-fill-reindent-defun): New command. * lisp/progmodes/sh-script.el (bash-ts-mode): Add regexp for the new variable. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-base-mode): Add regexp for the new variable. * lisp/treesit.el (treesit-text-type-regexp): New variable. --- doc/emacs/programs.texi | 8 +++++++ etc/NEWS | 7 ++++++ lisp/progmodes/c-ts-mode.el | 4 ++++ lisp/progmodes/csharp-mode.el | 5 ++++ lisp/progmodes/java-ts-mode.el | 5 ++++ lisp/progmodes/js.el | 5 ++++ lisp/progmodes/prog-mode.el | 35 ++++++++++++++++++++++++++-- lisp/progmodes/sh-script.el | 4 ++++ lisp/progmodes/typescript-ts-mode.el | 4 ++++ lisp/treesit.el | 9 +++++++ 10 files changed, 84 insertions(+), 2 deletions(-) diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index ba8475e86a..cc06a003e2 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -409,6 +409,14 @@ Multi-line Indent @table @kbd @item C-M-q Reindent all the lines within one parenthetical grouping. +@item M-q +Major modes that derive from @code{prog-mode} can reindent all the +lines within a defun around point using +@code{prog-mode-fill-reindent-defun}. The bounds of of a defun is +decided by @code{beginning-of-defun-function} and +@code{end-of-defun-function}. If point is inside a comment or a +doc-string, refill that paragraph instead, using +@code{fill-paragraph-function}. @item C-u @key{TAB} Shift an entire parenthetical grouping rigidly sideways so that its first line is properly indented. diff --git a/etc/NEWS b/etc/NEWS index 61f813568f..659ee39faf 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -61,6 +61,13 @@ using this new option. (Or set 'display-buffer-alist' directly.) After manually editing 'eshell-aliases-file', you can use 'M-x eshell-read-aliases-list' to load the edited aliases. +** Prog Mode ++++ +*** New command 'prog-fill-reindent-defun' +This command either fills a single paragraph in a defun, such as a +doc-string, or a comment. If point is inside normal code, it +(re)indents the surrounding defun. Bound by default in +'prog-mode-map' to 'M-q'. * New Modes and Packages in Emacs 30.1 diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 08b03d5666..114ffc0b03 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -603,6 +603,10 @@ c++-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "raw_string_literal"))) + (treesit-parser-create 'cpp) (setq-local treesit-simple-indent-rules diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index 8ab5fbc91d..3faeb54fc5 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el @@ -911,6 +911,11 @@ csharp-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "verbatim_string-literal" + "interpolated_verbatim_string-text"))) + ;; Indent. (setq-local treesit-simple-indent-rules csharp-ts-mode--indent-rules) diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 96e0d5244c..b1bf965e4f 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -308,6 +308,11 @@ java-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("line_comment" + "block_comment" + "text_block"))) + ;; Indent. (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 45dfef372c..d0b243a22f 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3857,6 +3857,11 @@ js-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) (setq-local comment-multi-line t) + + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "template_string"))) + ;; Electric-indent. (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) ;FIXME: js2-mode adds "[]*". diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index 58cb48f182..c29efa3a21 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -30,7 +30,11 @@ ;;; Code: (eval-when-compile (require 'cl-lib) - (require 'subr-x)) + (require 'subr-x) + (require 'treesit)) + +(declare-function treesit-parser-list "treesit.c") +(declare-function treesit-node-type "treesit.c") (defgroup prog-mode nil "Generic programming mode, from which others derive." @@ -102,7 +106,8 @@ prog-context-menu (defvar-keymap prog-mode-map :doc "Keymap used for programming modes." - "C-M-q" #'prog-indent-sexp) + "C-M-q" #'prog-indent-sexp + "M-q" #'prog-fill-reindent-defun) (defvar prog-indentation-context nil "When non-nil, provides context for indenting embedded code chunks. @@ -140,6 +145,32 @@ prog-indent-sexp (end (progn (forward-sexp 1) (point)))) (indent-region start end nil)))) +(defun prog-fill-reindent-defun (&optional argument) + "Refill paragraph or reindent the definition that the point is on. + +If the point is in a string, or in a comment, or there is a +comment on the current line, fill the paragraph that the point is +in or is on the same line. + +Otherwise, reindent the definition around or below point." + (interactive "P") + (save-excursion + (let ((treesit-text-node + (and (treesit-parser-list) + (string-match-p + treesit-text-type-regexp + (treesit-node-type (treesit-node-at (point))))))) + (if (or treesit-text-node + (nth 8 (syntax-ppss)) + (re-search-forward comment-start-skip (line-end-position) t)) + (if (memq fill-paragraph-function '(t nil)) + (lisp-fill-paragraph argument) + (funcall fill-paragraph-function argument)) + (beginning-of-defun) + (let ((start (point))) + (end-of-defun) + (indent-region start (point) nil)))))) + (defun prog-first-column () "Return the indentation column normally used for top-level constructs." (or (car prog-indentation-context) 0)) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index e170d18afe..1605e40347 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1619,6 +1619,10 @@ bash-ts-mode ( bracket delimiter misc-punctuation operator))) (setq-local treesit-font-lock-settings sh-mode--treesit-settings) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "heredoc_start" + "heredoc_body"))) (treesit-major-mode-setup))) (advice-add 'bash-ts-mode :around #'sh--redirect-bash-ts-mode diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 20916eaf37..59598b4c63 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -323,6 +323,10 @@ typescript-ts-base-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "template_string"))) + ;; Electric (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) diff --git a/lisp/treesit.el b/lisp/treesit.el index dbbf7ec18c..41feac35c2 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1626,6 +1626,15 @@ treesit-end-of-defun (when top (goto-char (treesit-node-end top))))) +(defvar-local treesit-text-type-regexp "\\`comment\\'" + "A regexp that matches the node type of textual nodes. + +A textual node is a node that is not normal code, such as +comments and multiline string literals. For example, +\"(line|block)_comment\" in the case of a comment, or +\"text_block\" in the case of a string. This is used by +`prog-fill-reindent-defun' and friends.") + ;;; Activating tree-sitter (defun treesit-ready-p (language &optional quiet) -- 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 09 15:20:25 2022 Received: (at 59662) by debbugs.gnu.org; 9 Dec 2022 20:20:25 +0000 Received: from localhost ([127.0.0.1]:38257 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3jr4-0002pT-2S for submit@debbugs.gnu.org; Fri, 09 Dec 2022 15:20:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54652) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3jr1-0002pL-3s for 59662@debbugs.gnu.org; Fri, 09 Dec 2022 15:20:20 -0500 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 1p3jqu-00061G-9e; Fri, 09 Dec 2022 15:20:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=+TEHDMR29P3j/lXVP6JAme/rkgtIHT1PjVdNN6WrywQ=; b=Q7fmUdGhFzk7 QvsdjbMnhkCHEQF+giwEhCFjlEjkypdz6afEyYuFZs5wTNYIFtqVvl0XbMMFOPyoOGWaQftZyiqCc dL4PbkYnUzwdV4A3icBVHZyQA+fbxT6Ur0V3pe6dX/uthq+a+q15rLZciuUZzlFeXvuf81yABOw1q 5bi9PUBOmLU4ouwSLfDfZ3+D6tnOlRtua2eMsBXCOGlzGQoIC0oAYDArcUKgwmTVGm+SIqsaJ+L6T SuCFarVWrvUbpiAPj3jj5QFGFEHtGeJvBFzRi5DM+HDNtF+5AJEPP2Kqdi8Abxe+3z2Uzr2uqM7cv Yc42DWwAH17LGaOR7XUbrw==; 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 1p3jqt-0004bQ-Of; Fri, 09 Dec 2022 15:20:12 -0500 Date: Fri, 09 Dec 2022 22:20:05 +0200 Message-Id: <834ju4z5vu.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: <87wn70injy.fsf@thornhill.no> (message from Theodor Thornhill on Fri, 09 Dec 2022 16:50:25 +0100) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> <87wn70injy.fsf@thornhill.no> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Theodor Thornhill > Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, > monnier@iro.umontreal.ca > Date: Fri, 09 Dec 2022 16:50:25 +0100 > > diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi > index ba8475e86a..cc06a003e2 100644 > --- a/doc/emacs/programs.texi > +++ b/doc/emacs/programs.texi > @@ -409,6 +409,14 @@ Multi-line Indent > @table @kbd > @item C-M-q > Reindent all the lines within one parenthetical grouping. > +@item M-q > +Major modes that derive from @code{prog-mode} can reindent all the > +lines within a defun around point using > +@code{prog-mode-fill-reindent-defun}. The bounds of of a defun is > +decided by @code{beginning-of-defun-function} and > +@code{end-of-defun-function}. If point is inside a comment or a > +doc-string, refill that paragraph instead, using > +@code{fill-paragraph-function}. The 2 variables you mention should have @vindex entries. Also, please add a cross-reference to the mode in elisp manual where these two variables are described. > +*** New command 'prog-fill-reindent-defun' > +This command either fills a single paragraph in a defun, such as a > +doc-string, or a comment. If point is inside normal code, it > +(re)indents the surrounding defun. These two sentences should be one sentence, otherwise that 'either" is out of place. Something like This command either fills a single paragraph in a defun, such as a doc-string, or a comment, or (re)indents the surrounding defun if point is not in a comment or a string. > Bound by default in > +'prog-mode-map' to 'M-q'. "It is by default bound to 'M-q' in 'prog-mode' and all its descendants." > +(defun prog-fill-reindent-defun (&optional argument) > + "Refill paragraph or reindent the definition that the point is on. > + > +If the point is in a string, or in a comment, or there is a > +comment on the current line, fill the paragraph that the point is > +in or is on the same line. I don't understand the difference between "point is in a string, or in a comment" and "there is a comment on the current line". > +Otherwise, reindent the definition around or below point." Likewise this one is confusing. From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 09 15:28:11 2022 Received: (at 59662) by debbugs.gnu.org; 9 Dec 2022 20:28:11 +0000 Received: from localhost ([127.0.0.1]:38299 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3jyd-0002uV-HC for submit@debbugs.gnu.org; Fri, 09 Dec 2022 15:28:11 -0500 Received: from mail-wr1-f49.google.com ([209.85.221.49]:38511) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3jyb-0002uP-1w for 59662@debbugs.gnu.org; Fri, 09 Dec 2022 15:28:09 -0500 Received: by mail-wr1-f49.google.com with SMTP id f18so6292396wrj.5 for <59662@debbugs.gnu.org>; Fri, 09 Dec 2022 12:28:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=K+3Ar9TJE0cDJSDb1uVci1KTJ6UVtbJJUTx3bXVI66c=; b=IgrHb/9LCOdr3rsDIrQ127ePpibGuhsttTv4fcAg7VeoTG7bgI5cI0gWvBu3TGgu9w 30Ga9fUrykcRgk4bMI41I8rXrdGxFuLlfeHjh/bMPOyI6QRVXJgGuJ35b8gpkmzH2nOK BibQp1HC5STeOysOfRLbv3nP4nUK6w5bjXn4hz9ZhPWWjuH2fLnO4QWT7hSO3lKk2nmT K+2ja2OpSIT5Q7tJ/tI/GOTj8uY63B4zFO9Wn+NdB8oW3+mtLoKT5iu84cQLFZVAfL2C Z1ASb7CM3Rjkt9IV524T25vzdu5voMcCvn/qVDUuZexNmdndjEeNaXlphCk07Uhkvzia S/mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=K+3Ar9TJE0cDJSDb1uVci1KTJ6UVtbJJUTx3bXVI66c=; b=xahqbeoKhb8dnAnOagdHK271kLNRAl4tRzTdNTYnZX65vY798p67iy3QzPpRLzgpIc QYb9hZS17B5d1hslNl1sEh7qNtj48meLcYqnbJJho1q9IGHcdrEPtpoCENbxbZd3poRZ ge6dJSW2WXvRIZHR0Rr16qkxPqm2SUL4+J1Jpw2XjLHcKwj71xcHYDCv/xuhx9hvrhEy tj96alWs4BAozdfN9H3oxP7g5XO4b+8T/q55ejILea3No3ZmPjbHKTdqRmONqB60B91w z+mbBJWeLhPvKMr2Op/VNpM/0pI4zCQBxj1V6oDdJws2JoNDun3Py8i9JbR1SoYOleY3 4Ifw== X-Gm-Message-State: ANoB5pk7kQNo/RF2pd1VFY7uPMFAyrehCf1HdYhM2+qWyyQbS5Q4urMo YbSiF5xoxxPSlHOmI1C3cRI= X-Google-Smtp-Source: AA0mqf6Mxe7sTxc/Wf2YS6cRcCoWRHWkNT9Nwu9bwhCtg+vsL9jZ+zoVNILzlTbMZRmsNj/y1t6U5Q== X-Received: by 2002:a5d:5d0b:0:b0:23a:5a31:29f5 with SMTP id ch11-20020a5d5d0b000000b0023a5a3129f5mr5403927wrb.23.1670617683194; Fri, 09 Dec 2022 12:28:03 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id w8-20020a5d5448000000b0022584c82c80sm2167825wrv.19.2022.12.09.12.28.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Dec 2022 12:28:02 -0800 (PST) Message-ID: <926a57f1-6288-3785-6028-ed8a9b973b8e@yandex.ru> Date: Fri, 9 Dec 2022 22:28:00 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US To: Theodor Thornhill , Eli Zaretskii References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> <87wn70injy.fsf@thornhill.no> <87r0x8ie1q.fsf@thornhill.no> From: Dmitry Gutov In-Reply-To: <87r0x8ie1q.fsf@thornhill.no> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 09/12/2022 21:15, Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > Dmitry Gutov writes: > >> On 09/12/2022 17:50, Theodor Thornhill via Bug reports for GNU Emacs, >> the Swiss army knife of text editors wrote: >>> Something like this? >> >> Looking good, thanks! > > My pleasure. I removed the code that should go to emacs-29. Can you > install if you agree with this patch, Dmitry? LGTM. I expected Eli would also take a look, but since it's for master, I suppose we don't have to wait for his sign-off. From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 09 15:31:04 2022 Received: (at 59662) by debbugs.gnu.org; 9 Dec 2022 20:31:04 +0000 Received: from localhost ([127.0.0.1]:38318 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3k1Q-0002xl-Em for submit@debbugs.gnu.org; Fri, 09 Dec 2022 15:31:04 -0500 Received: from mail-wr1-f44.google.com ([209.85.221.44]:42615) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3k1P-0002xO-C5 for 59662@debbugs.gnu.org; Fri, 09 Dec 2022 15:31:03 -0500 Received: by mail-wr1-f44.google.com with SMTP id w15so6282367wrl.9 for <59662@debbugs.gnu.org>; Fri, 09 Dec 2022 12:31:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=GoTdKGacXqxFRyDiDoPBaSFirSAb8wLfqempj3t90us=; b=epjtZRnsBl0L6vU08UYa9ceNQIEk1Hr+rZJvIdyK9SuvMRRJwMazrHt2IzmqjKAiKu /UiZjQSQinEYmJjQlRkrqFIJ5ICckUhzErbOw+aqRUl7OMGf1Ysc0wLETNPhmkHT4MyL CNhlFYRUAHA9BZerxh9B7qi+NYSSMFy82/bcM2nHYQ7DMq0bUWF0l5hCqTUPNo8QSMY9 xP7NKRwGyV/720YqJGWkEijByzGF/F2AnWY5I3lFiCj/wnZF2rdGHN3hvsYkAbMnCkAB zP1Nu/PKxNfDL/GvCMlUOBKAIz67UDle/f1HHVa25pJEVwSNe+IWwZgRctOxi/kS71bK PWcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GoTdKGacXqxFRyDiDoPBaSFirSAb8wLfqempj3t90us=; b=YC1LD1XwnLwElNup2pf+VTli4CROAbsEwRx0VPN/aoRrcTsPE2phzpheSoiO/090ta vAoZMvmxeqvinY9GghJpFWbB4B16ScYjQp3fAC+N9BbihPpEGOOXxKISsQuHxMGvaOTl jhtu03hNaOHW/WgUzMDwLiYpx9lzvzDZ4EANqXze/Tn478KMvpd0JzX6u6il4VkxScii 1HMsmLIdUEOK2w4Eckw/9qn+jnQt+xvDvzyTez1rO6h4ueLgbxdqM7SR9fIdW2z9deVz pXcPDbbwoo4zWUMIEwnuGmqWD801LMMnSzdjFuNjkkW4Cpwi3AuqI+m9Fnrv/nHkB3je aF2A== X-Gm-Message-State: ANoB5plZ+NmLdiYQ/26WJZn0mBiYAR99qTSRdIx3pryP1978D/NaFJw/ QGnVi9/nFRK0/aFFaPvO5Jk= X-Google-Smtp-Source: AA0mqf69lIrbNdYpEcbfph1wvX+U5s7zv7gQOPPlFWTaayCBDK8/iuJ7+05fWM2GpAcVNuh+r2dyQg== X-Received: by 2002:adf:eb83:0:b0:232:be5c:c009 with SMTP id t3-20020adfeb83000000b00232be5cc009mr4887707wrn.60.1670617857680; Fri, 09 Dec 2022 12:30:57 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id ay9-20020a5d6f09000000b0022ae0965a8asm2234737wrb.24.2022.12.09.12.30.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Dec 2022 12:30:57 -0800 (PST) Message-ID: <9e327f59-15d2-4af1-837c-53e8a793754e@yandex.ru> Date: Fri, 9 Dec 2022 22:30:55 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US To: Eli Zaretskii , Theodor Thornhill References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> <87wn70injy.fsf@thornhill.no> <834ju4z5vu.fsf@gnu.org> From: Dmitry Gutov In-Reply-To: <834ju4z5vu.fsf@gnu.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 09/12/2022 22:20, Eli Zaretskii wrote: >> +(defun prog-fill-reindent-defun (&optional argument) >> + "Refill paragraph or reindent the definition that the point is on. >> + >> +If the point is in a string, or in a comment, or there is a >> +comment on the current line, fill the paragraph that the point is >> +in or is on the same line. > > I don't understand the difference between "point is in a string, or in > a comment" and "there is a comment on the current line". The comment may start after point. >> +Otherwise, reindent the definition around or below point." > > Likewise this one is confusing. The intent was to describe the behavior that follows 'mark-defun'. Which has this in its docstring: Put mark at end of this defun, point at beginning. The defun marked is the one that contains point or follows point. From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 09 15:31:51 2022 Received: (at 59662) by debbugs.gnu.org; 9 Dec 2022 20:31:51 +0000 Received: from localhost ([127.0.0.1]:38325 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3k2A-0002y0-RW for submit@debbugs.gnu.org; Fri, 09 Dec 2022 15:31:51 -0500 Received: from mail-wm1-f49.google.com ([209.85.128.49]:34560) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3k29-0002xu-Go for 59662@debbugs.gnu.org; Fri, 09 Dec 2022 15:31:49 -0500 Received: by mail-wm1-f49.google.com with SMTP id ay8-20020a05600c1e0800b003d0808d2826so6303729wmb.1 for <59662@debbugs.gnu.org>; Fri, 09 Dec 2022 12:31:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=/1lYPw2mrPHW1LFUttmWkfGOOZ8KAe8CcVnFrdvCvlQ=; b=JYNYQKEVpBzvGBKlnzxWkSM5nu23b8nkC+/JqqRtSdjI8yhYf6csvunwkZmmjILiiK OkTOug4FpDE4JJ5KP3iK3Pk5pjSekwQKX1Xv7Uy7cqF4UE/TQg0/rvguuVGhTIY6ww4y PcT3cB4/eF/hzOymLKSehd+lT4d8UQRPDRcbxYcYBePFA7aVwfHAhYXqzvtmLxyOyJtx N3jwh7V3WohiiUshAewzmocfbn47JhP0l9iDVgKK2zzJAsYWv1vALHAScebEz9n/V8L5 8YFh7rYyS6y4I/HEeynDIV2Lzwz1hdUF4d2joky6VOUMK+/I/f04ABUNeqUBn2Qvnzcg ABoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/1lYPw2mrPHW1LFUttmWkfGOOZ8KAe8CcVnFrdvCvlQ=; b=sFwkkoPzu2tszD3Mw4IUHoY7JsWEe6FfyMFHWmHdsEXW4ESAcKmlIiiaEJDKgRhQtu j9fGbE2jAkDYgabAkC8owIrCwGMafw/4c/3DoDBHE2xsUzm3Wa8kIZnekvkkR52+zWvk AEc7iUo11cqKEF/kUeq+L1XhmY2Is78US+DoZ5Dc9zm3zqV2nIt6R13YWF0twiMRrAUR 4pvSx3Z7aUpeBSzegTipnDuXNqshU540mHa4O7MROKC7YUVokA5WU8BVoQcRmYXlGRQB Q23WyqDl72VE/N0MuZYCEBO29RdbJ68S4meJIV8hr46mzuSpKX/l8zYqnkya/DwEMVbu btMg== X-Gm-Message-State: ANoB5plmHFwY/bpSF2DIgWK//RoRSTZ81gTUa7VGZMr0yfdIS1M+naDd e5O7T9kxg9uayZj4Hrq4A2I= X-Google-Smtp-Source: AA0mqf6ANCXrUy3KHQ0bkQ1xJ4zW4crNmEGM+RsX7BPFltFkHa/yx/GA5npqEiBVGIeO+wZ45EHPiQ== X-Received: by 2002:a05:600c:1d12:b0:3cf:6132:7645 with SMTP id l18-20020a05600c1d1200b003cf61327645mr6088516wms.40.1670617903779; Fri, 09 Dec 2022 12:31:43 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id g11-20020a05600c310b00b003b47e75b401sm778590wmo.37.2022.12.09.12.31.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Dec 2022 12:31:43 -0800 (PST) Message-ID: <33366e99-51ae-f333-43ac-ad4ec0fe769a@yandex.ru> Date: Fri, 9 Dec 2022 22:31:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US From: Dmitry Gutov To: Theodor Thornhill , Eli Zaretskii References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> <87wn70injy.fsf@thornhill.no> <87r0x8ie1q.fsf@thornhill.no> <926a57f1-6288-3785-6028-ed8a9b973b8e@yandex.ru> In-Reply-To: <926a57f1-6288-3785-6028-ed8a9b973b8e@yandex.ru> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 09/12/2022 22:28, Dmitry Gutov wrote: > I expected Eli would also take a look, but since it's for master, I > suppose we don't have to wait for his sign-off. And scratch that. From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 09 16:09:19 2022 Received: (at 59662) by debbugs.gnu.org; 9 Dec 2022 21:09:19 +0000 Received: from localhost ([127.0.0.1]:38523 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3kcQ-0005hH-Fd for submit@debbugs.gnu.org; Fri, 09 Dec 2022 16:09:19 -0500 Received: from out2.migadu.com ([188.165.223.204]:17081) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3kcN-0005hB-Pm for 59662@debbugs.gnu.org; Fri, 09 Dec 2022 16:09:17 -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=1670620154; 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=TLij24IrJymcN2AoVznijEzaWs4TMJpu78QMbepYk+c=; b=HNCCwtGQQoBGTb3GhyApQzHHT+/Rnp/aURAOgdyu1DGPYz0XiTy3uHsJwX6B2I+kuHVlb4 D6OQo98JD7Lkn1k3Uv20MvGYbqd//3iGNSFgaYhOmX54LeRW1ZKqUrdkRjVZIBjMIHaqr0 oiRELoXxLdo2rjiQ8aEm+93JDqgH5xWvkGis87/mGYMRs41cyXpsU1+VQSRhH9cCq+5J2J V+GO85LmCBHyMV07ktQEWStEfruX4bSnHVvATSLPe97Q6mWBbaRZyoE8epcgMQp6x8zLyk b1o+95qJ8XwWsLwO1vuyOlrTmYVwtUAduW5Icdw/yZb5s3Up8rJe8T5kUyNYtw== From: Theodor Thornhill To: Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <834ju4z5vu.fsf@gnu.org> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> <87wn70injy.fsf@thornhill.no> <834ju4z5vu.fsf@gnu.org> Date: Fri, 09 Dec 2022 22:09:10 +0100 Message-ID: <87mt7wi8sp.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Theodor Thornhill >> Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, >> monnier@iro.umontreal.ca >> Date: Fri, 09 Dec 2022 16:50:25 +0100 >> >> diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi >> index ba8475e86a..cc06a003e2 100644 >> --- a/doc/emacs/programs.texi >> +++ b/doc/emacs/programs.texi >> @@ -409,6 +409,14 @@ Multi-line Indent >> @table @kbd >> @item C-M-q >> Reindent all the lines within one parenthetical grouping. >> +@item M-q >> +Major modes that derive from @code{prog-mode} can reindent all the >> +lines within a defun around point using >> +@code{prog-mode-fill-reindent-defun}. The bounds of of a defun is >> +decided by @code{beginning-of-defun-function} and >> +@code{end-of-defun-function}. If point is inside a comment or a >> +doc-string, refill that paragraph instead, using >> +@code{fill-paragraph-function}. > > The 2 variables you mention should have @vindex entries. Also, please > add a cross-reference to the mode in elisp manual where these two > variables are described. > >> +*** New command 'prog-fill-reindent-defun' >> +This command either fills a single paragraph in a defun, such as a >> +doc-string, or a comment. If point is inside normal code, it >> +(re)indents the surrounding defun. > > These two sentences should be one sentence, otherwise that 'either" is > out of place. Something like > > This command either fills a single paragraph in a defun, such as a > doc-string, or a comment, or (re)indents the surrounding defun if > point is not in a comment or a string. > >> Bound by default in >> +'prog-mode-map' to 'M-q'. Something like the patch below? Forgive me, but my texinfo-fu is limited. I'm a little unsure if I xrefed to the correct nodes. Maybe it is better to just mention 'beginning-of-defun' rather than the variable 'beginning-of-defun-function'? > > "It is by default bound to 'M-q' in 'prog-mode' and all its > descendants." > >> +(defun prog-fill-reindent-defun (&optional argument) >> + "Refill paragraph or reindent the definition that the point is on. >> + >> +If the point is in a string, or in a comment, or there is a >> +comment on the current line, fill the paragraph that the point is >> +in or is on the same line. > > I don't understand the difference between "point is in a string, or in > a comment" and "there is a comment on the current line". > >> +Otherwise, reindent the definition around or below point." > > Likewise this one is confusing. I'm not sure how to word this differently, but I agree it's a mouthful. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-prog-fill-reindent-defun-bug-59664.patch >From 7d2ae8eb9bcfd1409d7ee3c79f1a98663eac9832 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Fri, 9 Dec 2022 20:12:51 +0100 Subject: [PATCH] Add prog-fill-reindent-defun (bug#59664) Introduce a new command that aims to reindent code in a defun, or fill a paragraph of text. The command uses treesit.el when available, otherwise falls back to using syntax-ppss and regexps. Treesit.el needs a new variable that is intended to be set by the major modes so that this and other future functions can know what kind of node we are looking at. * doc/emacs/programs.texi: Mention the new command. * etc/NEWS: Mention the new command. * lisp/progmodes/c-ts-mode.el (c++-ts-mode): Add regexp for the new variable. * lisp/progmodes/csharp-mode.el (csharp-ts-mode): Add regexp for the new variable. * lisp/progmodes/java-ts-mode.el (java-ts-mode): Add regexp for the new variable. * lisp/progmodes/js.el (js-ts-mode): Add regexp for the new variable. * list/progmodes/prog-mode.el (prog-mode-map): Bind the new command by default. (prog-fill-reindent-defun): New command. * lisp/progmodes/sh-script.el (bash-ts-mode): Add regexp for the new variable. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-base-mode): Add regexp for the new variable. * lisp/treesit.el (treesit-text-type-regexp): New variable. --- doc/emacs/programs.texi | 13 +++++++++++ etc/NEWS | 7 ++++++ lisp/progmodes/c-ts-mode.el | 4 ++++ lisp/progmodes/csharp-mode.el | 5 ++++ lisp/progmodes/java-ts-mode.el | 5 ++++ lisp/progmodes/js.el | 5 ++++ lisp/progmodes/prog-mode.el | 35 ++++++++++++++++++++++++++-- lisp/progmodes/sh-script.el | 4 ++++ lisp/progmodes/typescript-ts-mode.el | 4 ++++ lisp/treesit.el | 9 +++++++ 10 files changed, 89 insertions(+), 2 deletions(-) diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index ba8475e86a..d981ef6b49 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -409,6 +409,19 @@ Multi-line Indent @table @kbd @item C-M-q Reindent all the lines within one parenthetical grouping. +@item M-q +@vindex beginning-of-defun-function +@vindex end-of-defun-function +@vindex fill-paragraph-function +@findex prog-mode-fill-reindent-defun +Major modes that derive from @code{prog-mode} can reindent all the +lines within a defun around point using +@code{prog-mode-fill-reindent-defun}. The bounds of a defun is +decided by @code{beginning-of-defun-function} and +@code{end-of-defun-function} (@pxref{Moving by Defuns}). If point is +inside a comment or a doc-string, refill that paragraph instead, using +@code{fill-paragraph-function} (@xref{Filling}, for more information +on @kbd{M-q}.) @item C-u @key{TAB} Shift an entire parenthetical grouping rigidly sideways so that its first line is properly indented. diff --git a/etc/NEWS b/etc/NEWS index 61f813568f..a5eb7f332d 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -61,6 +61,13 @@ using this new option. (Or set 'display-buffer-alist' directly.) After manually editing 'eshell-aliases-file', you can use 'M-x eshell-read-aliases-list' to load the edited aliases. +** Prog Mode ++++ +*** New command 'prog-fill-reindent-defun' +This command either fills a single paragraph in a defun, such as a +doc-string, or a comment, or (re)indents the surrounding defun if +point is not in a comment or a string. It is by default bound to +'M-q' in 'prog-mode' and all its descendants. * New Modes and Packages in Emacs 30.1 diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 08b03d5666..114ffc0b03 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -603,6 +603,10 @@ c++-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "raw_string_literal"))) + (treesit-parser-create 'cpp) (setq-local treesit-simple-indent-rules diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index 8ab5fbc91d..3faeb54fc5 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el @@ -911,6 +911,11 @@ csharp-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "verbatim_string-literal" + "interpolated_verbatim_string-text"))) + ;; Indent. (setq-local treesit-simple-indent-rules csharp-ts-mode--indent-rules) diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 96e0d5244c..b1bf965e4f 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -308,6 +308,11 @@ java-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("line_comment" + "block_comment" + "text_block"))) + ;; Indent. (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 45dfef372c..d0b243a22f 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3857,6 +3857,11 @@ js-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) (setq-local comment-multi-line t) + + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "template_string"))) + ;; Electric-indent. (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) ;FIXME: js2-mode adds "[]*". diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index 58cb48f182..c29efa3a21 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -30,7 +30,11 @@ ;;; Code: (eval-when-compile (require 'cl-lib) - (require 'subr-x)) + (require 'subr-x) + (require 'treesit)) + +(declare-function treesit-parser-list "treesit.c") +(declare-function treesit-node-type "treesit.c") (defgroup prog-mode nil "Generic programming mode, from which others derive." @@ -102,7 +106,8 @@ prog-context-menu (defvar-keymap prog-mode-map :doc "Keymap used for programming modes." - "C-M-q" #'prog-indent-sexp) + "C-M-q" #'prog-indent-sexp + "M-q" #'prog-fill-reindent-defun) (defvar prog-indentation-context nil "When non-nil, provides context for indenting embedded code chunks. @@ -140,6 +145,32 @@ prog-indent-sexp (end (progn (forward-sexp 1) (point)))) (indent-region start end nil)))) +(defun prog-fill-reindent-defun (&optional argument) + "Refill paragraph or reindent the definition that the point is on. + +If the point is in a string, or in a comment, or there is a +comment on the current line, fill the paragraph that the point is +in or is on the same line. + +Otherwise, reindent the definition around or below point." + (interactive "P") + (save-excursion + (let ((treesit-text-node + (and (treesit-parser-list) + (string-match-p + treesit-text-type-regexp + (treesit-node-type (treesit-node-at (point))))))) + (if (or treesit-text-node + (nth 8 (syntax-ppss)) + (re-search-forward comment-start-skip (line-end-position) t)) + (if (memq fill-paragraph-function '(t nil)) + (lisp-fill-paragraph argument) + (funcall fill-paragraph-function argument)) + (beginning-of-defun) + (let ((start (point))) + (end-of-defun) + (indent-region start (point) nil)))))) + (defun prog-first-column () "Return the indentation column normally used for top-level constructs." (or (car prog-indentation-context) 0)) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index e170d18afe..1605e40347 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1619,6 +1619,10 @@ bash-ts-mode ( bracket delimiter misc-punctuation operator))) (setq-local treesit-font-lock-settings sh-mode--treesit-settings) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "heredoc_start" + "heredoc_body"))) (treesit-major-mode-setup))) (advice-add 'bash-ts-mode :around #'sh--redirect-bash-ts-mode diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 20916eaf37..59598b4c63 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -323,6 +323,10 @@ typescript-ts-base-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "template_string"))) + ;; Electric (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) diff --git a/lisp/treesit.el b/lisp/treesit.el index dbbf7ec18c..41feac35c2 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1626,6 +1626,15 @@ treesit-end-of-defun (when top (goto-char (treesit-node-end top))))) +(defvar-local treesit-text-type-regexp "\\`comment\\'" + "A regexp that matches the node type of textual nodes. + +A textual node is a node that is not normal code, such as +comments and multiline string literals. For example, +\"(line|block)_comment\" in the case of a comment, or +\"text_block\" in the case of a string. This is used by +`prog-fill-reindent-defun' and friends.") + ;;; Activating tree-sitter (defun treesit-ready-p (language &optional quiet) -- 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 10 07:02:20 2022 Received: (at 59662) by debbugs.gnu.org; 10 Dec 2022 12:02:20 +0000 Received: from localhost ([127.0.0.1]:42381 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3yYd-0001AG-O4 for submit@debbugs.gnu.org; Sat, 10 Dec 2022 07:02:20 -0500 Received: from out2.migadu.com ([188.165.223.204]:64212) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3yYa-0001AA-CD for 59662@debbugs.gnu.org; Sat, 10 Dec 2022 07:02:17 -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=1670673734; 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=+amqr9MPlIBOXyvGHCVqf7YbgdS4wWJYOyT6MHlANCw=; b=muAZfW0K8u2YMgkgOgshTk1HJ+4F4scV0uXevbLSAP9JswtgySAPmPo45bGRVqQuR9kfsm 4/OOx4P0OT0PQto5EJUMPy4HEyXpK8VKvrSdNN0GEKU/popt5y18qO8oBnnG3nMnU7F52n UrwrUDg7wywjk2lm+4rUNuN0IV6gWVC9aumxIDOZ+7QCoQSFEPXYFNi9mdqrCT/ApEJo3J slQDM+Ht1B2tgq6/+zoD8bnXRDY5JmYqyNTrHBAlHFmiQkh0sUb4ChCXCx9mdZ9jAJNkA0 oTyBePHlR/QvsOxCOVWRj9p8WBZrIMKkneCLEggYg11XZVWKi/naKFiXRib65w== From: Theodor Thornhill To: Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <87mt7wi8sp.fsf@thornhill.no> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> <87wn70injy.fsf@thornhill.no> <834ju4z5vu.fsf@gnu.org> <87mt7wi8sp.fsf@thornhill.no> Date: Sat, 10 Dec 2022 13:02:09 +0100 Message-ID: <87bkobii0u.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Theodor Thornhill writes: > Eli Zaretskii writes: > >>> From: Theodor Thornhill >>> Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, >>> monnier@iro.umontreal.ca >>> Date: Fri, 09 Dec 2022 16:50:25 +0100 >>> >>> diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi >>> index ba8475e86a..cc06a003e2 100644 >>> --- a/doc/emacs/programs.texi >>> +++ b/doc/emacs/programs.texi >>> @@ -409,6 +409,14 @@ Multi-line Indent >>> @table @kbd >>> @item C-M-q >>> Reindent all the lines within one parenthetical grouping. >>> +@item M-q >>> +Major modes that derive from @code{prog-mode} can reindent all the >>> +lines within a defun around point using >>> +@code{prog-mode-fill-reindent-defun}. The bounds of of a defun is >>> +decided by @code{beginning-of-defun-function} and >>> +@code{end-of-defun-function}. If point is inside a comment or a >>> +doc-string, refill that paragraph instead, using >>> +@code{fill-paragraph-function}. >> >> The 2 variables you mention should have @vindex entries. Also, please >> add a cross-reference to the mode in elisp manual where these two >> variables are described. >> Is this worded a little better? Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-prog-fill-reindent-defun-bug-59664.patch >From 5b160b3e45371b35919e29e2152737feca10e8cf Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Fri, 9 Dec 2022 20:12:51 +0100 Subject: [PATCH] Add prog-fill-reindent-defun (bug#59664) Introduce a new command that aims to reindent code in a defun, or fill a paragraph of text. The command uses treesit.el when available, otherwise falls back to using syntax-ppss and regexps. Treesit.el needs a new variable that is intended to be set by the major modes so that this and other future functions can know what kind of node we are looking at. * doc/emacs/programs.texi: Mention the new command. * etc/NEWS: Mention the new command. * lisp/progmodes/c-ts-mode.el (c++-ts-mode): Add regexp for the new variable. * lisp/progmodes/csharp-mode.el (csharp-ts-mode): Add regexp for the new variable. * lisp/progmodes/java-ts-mode.el (java-ts-mode): Add regexp for the new variable. * lisp/progmodes/js.el (js-ts-mode): Add regexp for the new variable. * list/progmodes/prog-mode.el (prog-mode-map): Bind the new command by default. (prog-fill-reindent-defun): New command. * lisp/progmodes/sh-script.el (bash-ts-mode): Add regexp for the new variable. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-base-mode): Add regexp for the new variable. * lisp/treesit.el (treesit-text-type-regexp): New variable. --- doc/emacs/programs.texi | 8 +++++++ etc/NEWS | 7 ++++++ lisp/progmodes/c-ts-mode.el | 4 ++++ lisp/progmodes/csharp-mode.el | 5 ++++ lisp/progmodes/java-ts-mode.el | 5 ++++ lisp/progmodes/js.el | 5 ++++ lisp/progmodes/prog-mode.el | 35 ++++++++++++++++++++++++++-- lisp/progmodes/sh-script.el | 4 ++++ lisp/progmodes/typescript-ts-mode.el | 4 ++++ lisp/treesit.el | 9 +++++++ 10 files changed, 84 insertions(+), 2 deletions(-) diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index ba8475e86a..06bff21a48 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -409,6 +409,14 @@ Multi-line Indent @table @kbd @item C-M-q Reindent all the lines within one parenthetical grouping. +@item M-q +@findex prog-mode-fill-reindent-defun +Major modes that derive from @code{prog-mode} can reindent all the +lines within a defun around point using +@code{prog-mode-fill-reindent-defun} (@pxref{Defuns}, for more +information about defuns). If point is inside a comment or a +doc-string, refill that paragraph instead, using @code{fill-paragraph} +(@pxref{Fill Commands}, for more information on @kbd{M-q}.) @item C-u @key{TAB} Shift an entire parenthetical grouping rigidly sideways so that its first line is properly indented. diff --git a/etc/NEWS b/etc/NEWS index 61f813568f..a5eb7f332d 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -61,6 +61,13 @@ using this new option. (Or set 'display-buffer-alist' directly.) After manually editing 'eshell-aliases-file', you can use 'M-x eshell-read-aliases-list' to load the edited aliases. +** Prog Mode ++++ +*** New command 'prog-fill-reindent-defun' +This command either fills a single paragraph in a defun, such as a +doc-string, or a comment, or (re)indents the surrounding defun if +point is not in a comment or a string. It is by default bound to +'M-q' in 'prog-mode' and all its descendants. * New Modes and Packages in Emacs 30.1 diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 08b03d5666..114ffc0b03 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -603,6 +603,10 @@ c++-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "raw_string_literal"))) + (treesit-parser-create 'cpp) (setq-local treesit-simple-indent-rules diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index 8ab5fbc91d..3faeb54fc5 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el @@ -911,6 +911,11 @@ csharp-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "verbatim_string-literal" + "interpolated_verbatim_string-text"))) + ;; Indent. (setq-local treesit-simple-indent-rules csharp-ts-mode--indent-rules) diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 96e0d5244c..b1bf965e4f 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -308,6 +308,11 @@ java-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("line_comment" + "block_comment" + "text_block"))) + ;; Indent. (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 45dfef372c..d0b243a22f 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3857,6 +3857,11 @@ js-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) (setq-local comment-multi-line t) + + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "template_string"))) + ;; Electric-indent. (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) ;FIXME: js2-mode adds "[]*". diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index 58cb48f182..c29efa3a21 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -30,7 +30,11 @@ ;;; Code: (eval-when-compile (require 'cl-lib) - (require 'subr-x)) + (require 'subr-x) + (require 'treesit)) + +(declare-function treesit-parser-list "treesit.c") +(declare-function treesit-node-type "treesit.c") (defgroup prog-mode nil "Generic programming mode, from which others derive." @@ -102,7 +106,8 @@ prog-context-menu (defvar-keymap prog-mode-map :doc "Keymap used for programming modes." - "C-M-q" #'prog-indent-sexp) + "C-M-q" #'prog-indent-sexp + "M-q" #'prog-fill-reindent-defun) (defvar prog-indentation-context nil "When non-nil, provides context for indenting embedded code chunks. @@ -140,6 +145,32 @@ prog-indent-sexp (end (progn (forward-sexp 1) (point)))) (indent-region start end nil)))) +(defun prog-fill-reindent-defun (&optional argument) + "Refill paragraph or reindent the definition that the point is on. + +If the point is in a string, or in a comment, or there is a +comment on the current line, fill the paragraph that the point is +in or is on the same line. + +Otherwise, reindent the definition around or below point." + (interactive "P") + (save-excursion + (let ((treesit-text-node + (and (treesit-parser-list) + (string-match-p + treesit-text-type-regexp + (treesit-node-type (treesit-node-at (point))))))) + (if (or treesit-text-node + (nth 8 (syntax-ppss)) + (re-search-forward comment-start-skip (line-end-position) t)) + (if (memq fill-paragraph-function '(t nil)) + (lisp-fill-paragraph argument) + (funcall fill-paragraph-function argument)) + (beginning-of-defun) + (let ((start (point))) + (end-of-defun) + (indent-region start (point) nil)))))) + (defun prog-first-column () "Return the indentation column normally used for top-level constructs." (or (car prog-indentation-context) 0)) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index e170d18afe..1605e40347 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1619,6 +1619,10 @@ bash-ts-mode ( bracket delimiter misc-punctuation operator))) (setq-local treesit-font-lock-settings sh-mode--treesit-settings) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "heredoc_start" + "heredoc_body"))) (treesit-major-mode-setup))) (advice-add 'bash-ts-mode :around #'sh--redirect-bash-ts-mode diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 20916eaf37..59598b4c63 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -323,6 +323,10 @@ typescript-ts-base-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "template_string"))) + ;; Electric (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) diff --git a/lisp/treesit.el b/lisp/treesit.el index dbbf7ec18c..41feac35c2 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1626,6 +1626,15 @@ treesit-end-of-defun (when top (goto-char (treesit-node-end top))))) +(defvar-local treesit-text-type-regexp "\\`comment\\'" + "A regexp that matches the node type of textual nodes. + +A textual node is a node that is not normal code, such as +comments and multiline string literals. For example, +\"(line|block)_comment\" in the case of a comment, or +\"text_block\" in the case of a string. This is used by +`prog-fill-reindent-defun' and friends.") + ;;; Activating tree-sitter (defun treesit-ready-p (language &optional quiet) -- 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 10 09:04:33 2022 Received: (at 59662) by debbugs.gnu.org; 10 Dec 2022 14:04:34 +0000 Received: from localhost ([127.0.0.1]:42942 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p40Sv-0007R8-Kv for submit@debbugs.gnu.org; Sat, 10 Dec 2022 09:04:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59762) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p40St-0007R2-3m for 59662@debbugs.gnu.org; Sat, 10 Dec 2022 09:04:32 -0500 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 1p40Sk-0002gF-Vq; Sat, 10 Dec 2022 09:04:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=BP6bHHx3MCGZo6a6oA8M+pXQUiwIeZefuClVrN8Sh60=; b=LDdbl4llJ48O 6CRzCBfScFdSdfBweeRZ13nwIMHl7RnBOxWDJ2SwpvlSWOPlU0pyfG6YcHeBA2NiFWsdzs24WYR/T S7Aa8BymzVOFu09YKVGVW+5rORyAMH284Wltex8fmHifm6u0WTg4NKlGxopFrr1hFF4pQ0e5TSjg8 uHE+b5Hho5wVJGE9VCDcghExE+Z8fMThS8CiE5/QpoFTcbCb/yL6Zch5aNtIVKd5O/x/JcGUEtBvD fkzi3BgKi0q39NniRCOJjGpZxLpW95SWv0VCw9ArU6Hfe8fWQX8+HsaL21bphzP3OeOmikuoX3Zfj G2jAn/UrcC5xJDcjzw8s5g==; 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 1p40Sk-0006XT-Ak; Sat, 10 Dec 2022 09:04:22 -0500 Date: Sat, 10 Dec 2022 16:04:18 +0200 Message-Id: <83sfhnwe1p.fsf@gnu.org> From: Eli Zaretskii To: Dmitry Gutov In-Reply-To: <9e327f59-15d2-4af1-837c-53e8a793754e@yandex.ru> (message from Dmitry Gutov on Fri, 9 Dec 2022 22:30:55 +0200) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> <87wn70injy.fsf@thornhill.no> <834ju4z5vu.fsf@gnu.org> <9e327f59-15d2-4af1-837c-53e8a793754e@yandex.ru> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, theo@thornhill.no, casouri@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Fri, 9 Dec 2022 22:30:55 +0200 > Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, > monnier@iro.umontreal.ca > From: Dmitry Gutov > > On 09/12/2022 22:20, Eli Zaretskii wrote: > > >> +(defun prog-fill-reindent-defun (&optional argument) > >> + "Refill paragraph or reindent the definition that the point is on. > >> + > >> +If the point is in a string, or in a comment, or there is a > >> +comment on the current line, fill the paragraph that the point is > >> +in or is on the same line. > > > > I don't understand the difference between "point is in a string, or in > > a comment" and "there is a comment on the current line". > > The comment may start after point. Only after, not before? > >> +Otherwise, reindent the definition around or below point." > > > > Likewise this one is confusing. > > The intent was to describe the behavior that follows 'mark-defun'. Which > has this in its docstring: > > Put mark at end of this defun, point at beginning. > The defun marked is the one that contains point or follows point. That one is clear. Does "below point" means before point (i.e. lower buffer position) or after point (i.e. lower on the screen)? From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 10 09:09:24 2022 Received: (at 59662) by debbugs.gnu.org; 10 Dec 2022 14:09:24 +0000 Received: from localhost ([127.0.0.1]:42964 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p40Xc-0007U5-Bd for submit@debbugs.gnu.org; Sat, 10 Dec 2022 09:09:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42274) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p40XX-0007Ts-MS for 59662@debbugs.gnu.org; Sat, 10 Dec 2022 09:09:23 -0500 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 1p40XS-0005Hd-7f; Sat, 10 Dec 2022 09:09:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=KbVsbxSL9AsHRS5s7TvvQ49kpknW8mrLLYSgV2KE1Fg=; b=iQUkUYoZ6H/T rvJR4c87ym4OSyGjFNqD0cAP5kwnI4yAYvGCrKjdz2Lt9JbBnhgY/s35awLevgPEw6J14eMrgTJuc vIONDzL+tpyM5/DuBBa9ClbMINbDnx2p4XHowpYxury+9Ng8HgK+Idj2/UjqFwWTMu2mSJXKW9kkL Oz29NgeCIIo8VPE4BSr2dO1ztsjIgRpiYU6dO+gvdmeb1qZPwX/MeKKGSgiBA5yo4N5NaDx0VyYPP N/E8CcZnXpsQeuSbF6QJkNMQZofR9Ugc2li/80GuHK9fSFxwm3q4Ta0vQnmDnkkpu8gTFAy9mFxm9 Y3MQ4801w4coxFrhhLBT6g==; 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 1p40XR-00076H-FH; Sat, 10 Dec 2022 09:09:13 -0500 Date: Sat, 10 Dec 2022 16:09:09 +0200 Message-Id: <83r0x7wdtm.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: <87mt7wi8sp.fsf@thornhill.no> (message from Theodor Thornhill on Fri, 09 Dec 2022 22:09:10 +0100) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> <87wn70injy.fsf@thornhill.no> <834ju4z5vu.fsf@gnu.org> <87mt7wi8sp.fsf@thornhill.no> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Theodor Thornhill > Cc: dgutov@yandex.ru, larsi@gnus.org, 59662@debbugs.gnu.org, > casouri@gmail.com, monnier@iro.umontreal.ca > Date: Fri, 09 Dec 2022 22:09:10 +0100 > > Something like the patch below? Forgive me, but my texinfo-fu is > limited. You have nothing to worry in that department. > I'm a little unsure if I xrefed to the correct nodes. Maybe > it is better to just mention 'beginning-of-defun' rather than the > variable 'beginning-of-defun-function'? I meant a reference to where beginning-of-defun-function is mentioned, and that is in the ELisp manual. You can see examples of how to reference another manual in many places in doc/emacs/*.texi; seartch for "elisp". > >> +(defun prog-fill-reindent-defun (&optional argument) > >> + "Refill paragraph or reindent the definition that the point is on. > >> + > >> +If the point is in a string, or in a comment, or there is a > >> +comment on the current line, fill the paragraph that the point is > >> +in or is on the same line. > > > > I don't understand the difference between "point is in a string, or in > > a comment" and "there is a comment on the current line". > > > >> +Otherwise, reindent the definition around or below point." > > > > Likewise this one is confusing. > > I'm not sure how to word this differently, but I agree it's a mouthful. If you explain to me in plain English what you meant, I can suggest a better wording. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 10 09:28:01 2022 Received: (at 59662) by debbugs.gnu.org; 10 Dec 2022 14:28:01 +0000 Received: from localhost ([127.0.0.1]:43064 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p40pc-0007fe-S3 for submit@debbugs.gnu.org; Sat, 10 Dec 2022 09:28:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44260) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p40pa-0007fY-On for 59662@debbugs.gnu.org; Sat, 10 Dec 2022 09:27:59 -0500 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 1p40pS-00082V-IV; Sat, 10 Dec 2022 09:27:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=GKMg63J/OBLj5L7WqKde1enmPT+r8Udk/o/6CFl1A/s=; b=g+Wm4tGrRFGt LsknMMLQvbTK1OUnA6Ew6Uzs1tr/D+wiwMpDywv+fC9cqJcnPKr5ZFnzzL/WfAz1Z/b5Ha8vSf8TZ +pxC+seDZbbtYelXSz4jAnI/p+MjA44otplqL4uAhr+EdQESD6RFnDiwckk2tUoZo+EqqCeGoeKrp 2sZf4WPhoXXtOl+10qRBlXtqmnUw5ScYDOXvFk4yb+o7GpvBQ+2DRf7lgcsW1Z0am1e/AN31KzafV YkXENWpoqOIvKLFcjt8mV7/YDY6wmz8H3Qh6v9d4HOQesm3kGrjI3HlkfEL52KfdHKk86lJWVkbRs mPLg3JtSzDFY5au/0YhCQw==; 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 1p40pR-0003iC-Cp; Sat, 10 Dec 2022 09:27:50 -0500 Date: Sat, 10 Dec 2022 16:27:46 +0200 Message-Id: <83ilijwcyl.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: <87bkobii0u.fsf@thornhill.no> (message from Theodor Thornhill on Sat, 10 Dec 2022 13:02:09 +0100) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> <87wn70injy.fsf@thornhill.no> <834ju4z5vu.fsf@gnu.org> <87mt7wi8sp.fsf@thornhill.no> <87bkobii0u.fsf@thornhill.no> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Theodor Thornhill > Cc: dgutov@yandex.ru, larsi@gnus.org, 59662@debbugs.gnu.org, > casouri@gmail.com, monnier@iro.umontreal.ca > Date: Sat, 10 Dec 2022 13:02:09 +0100 > > Is this worded a little better? I think my last message answers this as well. From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 10 14:25:50 2022 Received: (at 59662) by debbugs.gnu.org; 10 Dec 2022 19:25:50 +0000 Received: from localhost ([127.0.0.1]:44612 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p45Tq-0004ze-30 for submit@debbugs.gnu.org; Sat, 10 Dec 2022 14:25:50 -0500 Received: from mail-wr1-f53.google.com ([209.85.221.53]:35616) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p45To-0004zY-JX for 59662@debbugs.gnu.org; Sat, 10 Dec 2022 14:25:49 -0500 Received: by mail-wr1-f53.google.com with SMTP id y16so8300772wrm.2 for <59662@debbugs.gnu.org>; Sat, 10 Dec 2022 11:25:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=vG7jpIKYI9UzBpybULchDPQ/s2DR5yMcLMvRockL8yQ=; b=fkZW4raSXg/d34JKmabvpNZiv+i9nxlJNKfiS3OmzjfI47HcylyRR24NW+HgbE+TEI GGtKstDiNn8PmavUUOxMzadFKZInuvEGMfZhYVbWA9GvxJwNLu1VpYtOfiB8Cx0UUzDC 7kF4Dw+qL/AoviNzw4qtnN6zFg8PIQbnxK8gvzvVa0efSqeBGtN3lyWsJQvaMCozqNTe EXqxSH/4rs7znSzTvKAyTDQNRnpOtmA6S1ESP1TSMXzweEXsUD5YcjI7c5o7jt2G8YAB 1vRCza4mKmORHjvc1RavLnMyL35vNlnvkoI3yYMwxThpA212U/7etJm+6P64vp+gvZvQ HuQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vG7jpIKYI9UzBpybULchDPQ/s2DR5yMcLMvRockL8yQ=; b=snkzd+0gNFJPZYM6ll5y8+hJo6QIlAnxARmmgapbgf8hjVar4c+NtZmEU6kFxOLSyw KrizN+pn/Dl9FNjymt8/7Ag0fmg0WuH6AZGn9pju149ouHhIjymBx6le6I/CSD+QXidD f6ZiajxEtMQ8lvguVWX04QDTUFSHmktMGhqJHvtMz2ge9GGq42OYHoDwg/8uRn1Je/Md ra3Ul03ftCA2xKFgZepmB2QDu5+RTaI8Ut3EQ/Fyw+JmUaz4eH8C+PiSSJHPogd6mR8g 7dTpcc0mIfYI7Q8ONdOIlS8Hc6inLq2p3tzYDzD1McAoMDD/BjIwzC6vgO5vGCI8RJZK e71g== X-Gm-Message-State: ANoB5pk2IsMLMDt19Yq5JcFajJoSXp0TGal6eUITSyvHkQv5RdypeoJ9 p3E+SSqTiBt8AvE8QRhL7Lg= X-Google-Smtp-Source: AA0mqf6uYPhomPw+WZuXi/Vd0tBaJUqusUSXhT7ekVbsSJCacZB0Ho5Wk3Br4s7nhb1BVZC2BeSiGg== X-Received: by 2002:a5d:4a0e:0:b0:242:643e:6954 with SMTP id m14-20020a5d4a0e000000b00242643e6954mr7003656wrq.14.1670700342951; Sat, 10 Dec 2022 11:25:42 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id j18-20020a5d5652000000b002427bfd17b6sm5364560wrw.63.2022.12.10.11.25.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 10 Dec 2022 11:25:42 -0800 (PST) Message-ID: Date: Sat, 10 Dec 2022 21:25:40 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US To: Eli Zaretskii References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <4d605e69-7df9-6480-c1c5-dcb22abd3bde@yandex.ru> <83y1ri2wnj.fsf@gnu.org> <875yemz55b.fsf@thornhill.no> <83r0xa2tc4.fsf@gnu.org> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> <87wn70injy.fsf@thornhill.no> <834ju4z5vu.fsf@gnu.org> <9e327f59-15d2-4af1-837c-53e8a793754e@yandex.ru> <83sfhnwe1p.fsf@gnu.org> From: Dmitry Gutov In-Reply-To: <83sfhnwe1p.fsf@gnu.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On 10/12/2022 16:04, Eli Zaretskii wrote: >> Date: Fri, 9 Dec 2022 22:30:55 +0200 >> Cc:larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, >> monnier@iro.umontreal.ca >> From: Dmitry Gutov >> >> [...] Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (raaahh[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.221.53 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.221.53 listed in list.dnswl.org] 0.0 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different -0.0 NICE_REPLY_A Looks like a legit reply (A) 1.0 FREEMAIL_REPLY From and body contain different freemails X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, theo@thornhill.no, casouri@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 10/12/2022 16:04, Eli Zaretskii wrote: >> Date: Fri, 9 Dec 2022 22:30:55 +0200 >> Cc:larsi@gnus.org,59662@debbugs.gnu.org,casouri@gmail.com, >> monnier@iro.umontreal.ca >> From: Dmitry Gutov >> >> On 09/12/2022 22:20, Eli Zaretskii wrote: >> >>>> +(defun prog-fill-reindent-defun (&optional argument) >>>> + "Refill paragraph or reindent the definition that the point is on. >>>> + >>>> +If the point is in a string, or in a comment, or there is a >>>> +comment on the current line, fill the paragraph that the point is >>>> +in or is on the same line. >>> I don't understand the difference between "point is in a string, or in >>> a comment" and "there is a comment on the current line". >> The comment may start after point. > Only after, not before? Either point is in a comment (possibly multiline), or the comment starts after point on the same line. >>>> +Otherwise, reindent the definition around or below point." >>> Likewise this one is confusing. >> The intent was to describe the behavior that follows 'mark-defun'. Which >> has this in its docstring: >> >> Put mark at end of this defun, point at beginning. >> The defun marked is the one that contains point or follows point. > That one is clear. Does "below point" means before point (i.e. lower > buffer position) or after point (i.e. lower on the screen)? Same as "after point", yes. From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 10 15:22:03 2022 Received: (at 59662) by debbugs.gnu.org; 10 Dec 2022 20:22:03 +0000 Received: from localhost ([127.0.0.1]:44868 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p46ME-0005c0-Q3 for submit@debbugs.gnu.org; Sat, 10 Dec 2022 15:22:03 -0500 Received: from out2.migadu.com ([188.165.223.204]:15713) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p46M9-0005bc-Mv for 59662@debbugs.gnu.org; Sat, 10 Dec 2022 15:22:01 -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=1670703715; 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=YSisTZG1MXDDaEntyQzZxKFH0GvSXUvOjJy4MjsyrFQ=; b=Y21O/TT1xQMB0zzkIdmwJ5Ry1pTAzhhBiJqLEDYfe0TBESfH2yyYVYiKmn6c/SRsVacZdl pdCYmBX5XgBQI32+gMjP5oN+6SVCM39IDVVmGHerNytWCFiR8IH76W7R/gf8Ko1SLQWtqd KZVEg7u3JfpKi/WXJz+7USrGBnJEK1z0TqWEblVvwPwPE/MvZKo65pW6/dMxnviIusltRF KMi2AVRN5/ep8oN5ZbC226xlGTA1afqDSWvGiSChVVO7CKiD6bNiJpS8Tb0dkygZerXSWy 8bWJbJSLG4lcT2p/BA3b5iBupEQGbsR6iZmXS8s+T11JkpJQ1TxfYjyNZE+CQg== From: Theodor Thornhill To: Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <83r0x7wdtm.fsf@gnu.org> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> <87wn70injy.fsf@thornhill.no> <834ju4z5vu.fsf@gnu.org> <87mt7wi8sp.fsf@thornhill.no> <83r0x7wdtm.fsf@gnu.org> Date: Sat, 10 Dec 2022 21:21:53 +0100 Message-ID: <87y1rfxb4u.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Theodor Thornhill >> Cc: dgutov@yandex.ru, larsi@gnus.org, 59662@debbugs.gnu.org, >> casouri@gmail.com, monnier@iro.umontreal.ca >> Date: Fri, 09 Dec 2022 22:09:10 +0100 >> >> Something like the patch below? Forgive me, but my texinfo-fu is >> limited. > > You have nothing to worry in that department. > >> I'm a little unsure if I xrefed to the correct nodes. Maybe >> it is better to just mention 'beginning-of-defun' rather than the >> variable 'beginning-of-defun-function'? > > I meant a reference to where beginning-of-defun-function is mentioned, > and that is in the ELisp manual. You can see examples of how to > reference another manual in many places in doc/emacs/*.texi; seartch > for "elisp". > Ok, thanks! >> >> +(defun prog-fill-reindent-defun (&optional argument) >> >> + "Refill paragraph or reindent the definition that the point is on. >> >> + >> >> +If the point is in a string, or in a comment, or there is a >> >> +comment on the current line, fill the paragraph that the point is >> >> +in or is on the same line. >> > >> > I don't understand the difference between "point is in a string, or in >> > a comment" and "there is a comment on the current line". >> > >> >> +Otherwise, reindent the definition around or below point." >> > >> > Likewise this one is confusing. >> >> I'm not sure how to word this differently, but I agree it's a mouthful. > > If you explain to me in plain English what you meant, I can suggest a > better wording. > I made another attempt - I think it's a little clearer. What I want to say is something like this (| denotes point): 1. If point is inside a comment, refill the paragraph: // foo bar | baz 2. If point is before a comment, refill the paragraph: | // foo bar baz 3. If point is inside code, reindent the defun: int main(void) { int i; // <-- This will be reindented /* Some very long comment that will _not_ be refilled in this case. */ for(;;) { | int x; } } Anyway, see attached patch: Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-prog-fill-reindent-defun-bug-59664.patch >From aeb709da894d19ec4fe5b05be1eb957861eb3dba Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Fri, 9 Dec 2022 20:12:51 +0100 Subject: [PATCH] Add prog-fill-reindent-defun (bug#59664) Introduce a new command that aims to reindent code in a defun, or fill a paragraph of text. The command uses treesit.el when available, otherwise falls back to using syntax-ppss and regexps. Treesit.el needs a new variable that is intended to be set by the major modes so that this and other future functions can know what kind of node we are looking at. * doc/emacs/programs.texi: Mention the new command. * etc/NEWS: Mention the new command. * lisp/progmodes/c-ts-mode.el (c++-ts-mode): Add regexp for the new variable. * lisp/progmodes/csharp-mode.el (csharp-ts-mode): Add regexp for the new variable. * lisp/progmodes/java-ts-mode.el (java-ts-mode): Add regexp for the new variable. * lisp/progmodes/js.el (js-ts-mode): Add regexp for the new variable. * list/progmodes/prog-mode.el (prog-mode-map): Bind the new command by default. (prog-fill-reindent-defun): New command. * lisp/progmodes/sh-script.el (bash-ts-mode): Add regexp for the new variable. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-base-mode): Add regexp for the new variable. * lisp/treesit.el (treesit-text-type-regexp): New variable. --- doc/emacs/programs.texi | 18 ++++++++++++++ etc/NEWS | 7 ++++++ lisp/progmodes/c-ts-mode.el | 4 ++++ lisp/progmodes/csharp-mode.el | 5 ++++ lisp/progmodes/java-ts-mode.el | 5 ++++ lisp/progmodes/js.el | 5 ++++ lisp/progmodes/prog-mode.el | 35 ++++++++++++++++++++++++++-- lisp/progmodes/sh-script.el | 4 ++++ lisp/progmodes/typescript-ts-mode.el | 4 ++++ lisp/treesit.el | 9 +++++++ 10 files changed, 94 insertions(+), 2 deletions(-) diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index ba8475e86a..d85fcd539c 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -409,6 +409,9 @@ Multi-line Indent @table @kbd @item C-M-q Reindent all the lines within one parenthetical grouping. +@item M-q +Fill a single paragraph in a defun, or reindent all the lines within +that defun. @item C-u @key{TAB} Shift an entire parenthetical grouping rigidly sideways so that its first line is properly indented. @@ -429,6 +432,21 @@ Multi-line Indent etc. To correct the overall indentation as well, type @kbd{@key{TAB}} first. +@kindex M-q +@findex prog-mode-fill-reindent-defun +@vindex beginning-of-defun-function +@vindex end-of-defun-function +@vindex fill-paragraph-function + Major modes that derive from @code{prog-mode} can either fill a +single paragraph in a defun, such as a doc-string, or a comment, or +(re)indent the surrounding defun if point is not in a comment or a +string by typing @kbd{M-q}. The bounds of a defun is decided by the +variable @code{beginning-of-defun-function} and +@code{end-of-defun-function}, and the filling mechanism is decided by +@code{fill-paragraph-function} (@pxref{List Motion,,, elisp, The Emacs +Lisp Reference Manual} or @ref{Filling,,, elisp, The Emacs Lisp +Reference Manual} for more information). + @kindex C-u TAB If you like the relative indentation within a grouping but not the indentation of its first line, move point to that first line and type diff --git a/etc/NEWS b/etc/NEWS index 61f813568f..a5eb7f332d 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -61,6 +61,13 @@ using this new option. (Or set 'display-buffer-alist' directly.) After manually editing 'eshell-aliases-file', you can use 'M-x eshell-read-aliases-list' to load the edited aliases. +** Prog Mode ++++ +*** New command 'prog-fill-reindent-defun' +This command either fills a single paragraph in a defun, such as a +doc-string, or a comment, or (re)indents the surrounding defun if +point is not in a comment or a string. It is by default bound to +'M-q' in 'prog-mode' and all its descendants. * New Modes and Packages in Emacs 30.1 diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 08b03d5666..114ffc0b03 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -603,6 +603,10 @@ c++-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "raw_string_literal"))) + (treesit-parser-create 'cpp) (setq-local treesit-simple-indent-rules diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index 8ab5fbc91d..3faeb54fc5 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el @@ -911,6 +911,11 @@ csharp-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "verbatim_string-literal" + "interpolated_verbatim_string-text"))) + ;; Indent. (setq-local treesit-simple-indent-rules csharp-ts-mode--indent-rules) diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 96e0d5244c..b1bf965e4f 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -308,6 +308,11 @@ java-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("line_comment" + "block_comment" + "text_block"))) + ;; Indent. (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 45dfef372c..d0b243a22f 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3857,6 +3857,11 @@ js-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) (setq-local comment-multi-line t) + + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "template_string"))) + ;; Electric-indent. (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) ;FIXME: js2-mode adds "[]*". diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index 58cb48f182..1bd8234dc9 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -30,7 +30,11 @@ ;;; Code: (eval-when-compile (require 'cl-lib) - (require 'subr-x)) + (require 'subr-x) + (require 'treesit)) + +(declare-function treesit-parser-list "treesit.c") +(declare-function treesit-node-type "treesit.c") (defgroup prog-mode nil "Generic programming mode, from which others derive." @@ -102,7 +106,8 @@ prog-context-menu (defvar-keymap prog-mode-map :doc "Keymap used for programming modes." - "C-M-q" #'prog-indent-sexp) + "C-M-q" #'prog-indent-sexp + "M-q" #'prog-fill-reindent-defun) (defvar prog-indentation-context nil "When non-nil, provides context for indenting embedded code chunks. @@ -140,6 +145,32 @@ prog-indent-sexp (end (progn (forward-sexp 1) (point)))) (indent-region start end nil)))) +(defun prog-fill-reindent-defun (&optional argument) + "Refill or reindent the paragraph or defun that contains point. + +If the point is in a string or a comment, fill the paragraph that +contains point or follows point. + +Otherwise, reindent the definition that contains point or follows +point." + (interactive "P") + (save-excursion + (let ((treesit-text-node + (and (treesit-parser-list) + (string-match-p + treesit-text-type-regexp + (treesit-node-type (treesit-node-at (point))))))) + (if (or treesit-text-node + (nth 8 (syntax-ppss)) + (re-search-forward comment-start-skip (line-end-position) t)) + (if (memq fill-paragraph-function '(t nil)) + (lisp-fill-paragraph argument) + (funcall fill-paragraph-function argument)) + (beginning-of-defun) + (let ((start (point))) + (end-of-defun) + (indent-region start (point) nil)))))) + (defun prog-first-column () "Return the indentation column normally used for top-level constructs." (or (car prog-indentation-context) 0)) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index e170d18afe..1605e40347 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1619,6 +1619,10 @@ bash-ts-mode ( bracket delimiter misc-punctuation operator))) (setq-local treesit-font-lock-settings sh-mode--treesit-settings) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "heredoc_start" + "heredoc_body"))) (treesit-major-mode-setup))) (advice-add 'bash-ts-mode :around #'sh--redirect-bash-ts-mode diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 20916eaf37..59598b4c63 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -323,6 +323,10 @@ typescript-ts-base-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "template_string"))) + ;; Electric (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) diff --git a/lisp/treesit.el b/lisp/treesit.el index dbbf7ec18c..41feac35c2 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1626,6 +1626,15 @@ treesit-end-of-defun (when top (goto-char (treesit-node-end top))))) +(defvar-local treesit-text-type-regexp "\\`comment\\'" + "A regexp that matches the node type of textual nodes. + +A textual node is a node that is not normal code, such as +comments and multiline string literals. For example, +\"(line|block)_comment\" in the case of a comment, or +\"text_block\" in the case of a string. This is used by +`prog-fill-reindent-defun' and friends.") + ;;; Activating tree-sitter (defun treesit-ready-p (language &optional quiet) -- 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 11 03:12:16 2022 Received: (at 59662) by debbugs.gnu.org; 11 Dec 2022 08:12:16 +0000 Received: from localhost ([127.0.0.1]:46200 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4HRY-0006gz-2I for submit@debbugs.gnu.org; Sun, 11 Dec 2022 03:12:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54336) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4HRT-0006gp-4w for 59662@debbugs.gnu.org; Sun, 11 Dec 2022 03:12:14 -0500 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 1p4HRL-0006QA-9O; Sun, 11 Dec 2022 03:12:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=RFJIdSG22gd7sKpGKB5KDmFR4aeeHbeAsRJTh01TggM=; b=CqaKQ8spv56j dQtsWnmWyXKrABG6/+FeyfdlNQjAcF0sNoN9EFSIQcstrnELxwQS4Bc0/mG2VulYC+EnzAoSrGeep 3x0A9VrYBYE7JLFmE75bNm+/asZgrN3yRSaBt4wlMUrrMr9IcDyZqbpo49euKLGc3GC33jkFx2sJj i6smfkiaBf+3s6NLIrgTvhrxw5tfEfXMNP/+r2n/N3/zBU6oeMDv3WlWNhIHo3AH+Oct7f/SS3HjW twjKMDD3wgbEWtsJG1DkFMMVd0Igb4jfiNnjrkevgFkF0UPanLha+NlUfhymJsOKj5UOdKoinWexI fsZKoZxDWiIjohv/cxaH7Q==; 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 1p4HRJ-0003f8-0F; Sun, 11 Dec 2022 03:12:01 -0500 Date: Sun, 11 Dec 2022 10:11:58 +0200 Message-Id: <83edt6uzox.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: <87y1rfxb4u.fsf@thornhill.no> (message from Theodor Thornhill on Sat, 10 Dec 2022 21:21:53 +0100) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <87zgbyxohf.fsf@thornhill.no> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> <87wn70injy.fsf@thornhill.no> <834ju4z5vu.fsf@gnu.org> <87mt7wi8sp.fsf@thornhill.no> <83r0x7wdtm.fsf@gnu.org> <87y1rfxb4u.fsf@thornhill.no> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Theodor Thornhill > Cc: dgutov@yandex.ru, larsi@gnus.org, 59662@debbugs.gnu.org, > casouri@gmail.com, monnier@iro.umontreal.ca > Date: Sat, 10 Dec 2022 21:21:53 +0100 > > I made another attempt - I think it's a little clearer. What I want to > say is something like this (| denotes point): > > 1. If point is inside a comment, refill the paragraph: > // foo bar | baz > > 2. If point is before a comment, refill the paragraph: > | // foo bar baz > > 3. If point is inside code, reindent the defun: > int > main(void) > { > int i; // <-- This will be reindented > /* Some very long comment that will _not_ be refilled in this case. */ > for(;;) > { > | int x; > } > } What if point is after a comment, like this: /* foo bar baz */ | > +@code{fill-paragraph-function} (@pxref{List Motion,,, elisp, The Emacs > +Lisp Reference Manual} or @ref{Filling,,, elisp, The Emacs Lisp > +Reference Manual} for more information). The @pxref should be "see @ref", and please add a comma after the closing brace (some old versions of makeinfo insist on that). @pxref is only appropriate if its closing brace immediately precedes the closing parenthesis. Otherwise LGTM, thanks. From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 11 03:39:56 2022 Received: (at 59662) by debbugs.gnu.org; 11 Dec 2022 08:39:56 +0000 Received: from localhost ([127.0.0.1]:46207 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4HsJ-0006z6-NU for submit@debbugs.gnu.org; Sun, 11 Dec 2022 03:39:56 -0500 Received: from out-46.mta0.migadu.com ([91.218.175.46]:59933) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4HsE-0006yy-Tr for 59662@debbugs.gnu.org; Sun, 11 Dec 2022 03:39:54 -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=1670747989; 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=L3tRj69yKv79SWqJRyBZI5NQp/Um0NQTQxuztHgwV3E=; b=W/WFdgMrnmIB4BJb5J2VHxc9x3RjR+Q1PVIY+3yWa/4j6WjHnFbLYU4azF5xX5GE7gqH1c CNeGCxG9tKrfNauMVHJNCaXG3+lKGEmZQMHMVI9fzGLNgnCxIO0BttUOO40jP3OKBlixXB 2MmziKoYUoDklYRNFasqQVqqrR6jJ7VKJ++o69Wj3QHyPHLLSWz3AaiVfhPDFW41drPPtX 27C5MmJMtHyhxd52NKcwqB8ZFEgQtKDzigjLg3iB1vh+UGstB+LbVTS5JpWEjgZmeIJ/EP 47FvFMPAWhhzVco1DGQJIQYZOp91J47yY9WFFa0rIAnJWFXdclwZzHTYWi0dXg== From: Theodor Thornhill To: Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <83edt6uzox.fsf@gnu.org> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> <87wn70injy.fsf@thornhill.no> <834ju4z5vu.fsf@gnu.org> <87mt7wi8sp.fsf@thornhill.no> <83r0x7wdtm.fsf@gnu.org> <87y1rfxb4u.fsf@thornhill.no> <83edt6uzox.fsf@gnu.org> Date: Sun, 11 Dec 2022 09:39:46 +0100 Message-ID: <87sfhmxrjh.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Theodor Thornhill >> Cc: dgutov@yandex.ru, larsi@gnus.org, 59662@debbugs.gnu.org, >> casouri@gmail.com, monnier@iro.umontreal.ca >> Date: Sat, 10 Dec 2022 21:21:53 +0100 >> >> I made another attempt - I think it's a little clearer. What I want to >> say is something like this (| denotes point): >> >> 1. If point is inside a comment, refill the paragraph: >> // foo bar | baz >> >> 2. If point is before a comment, refill the paragraph: >> | // foo bar baz >> >> 3. If point is inside code, reindent the defun: >> int >> main(void) >> { >> int i; // <-- This will be reindented >> /* Some very long comment that will _not_ be refilled in this case. */ >> for(;;) >> { >> | int x; >> } >> } > > What if point is after a comment, like this: > > /* foo bar baz */ | > Then the defun will be reindented. In one line comments the comment will be filled. >> +@code{fill-paragraph-function} (@pxref{List Motion,,, elisp, The Emacs >> +Lisp Reference Manual} or @ref{Filling,,, elisp, The Emacs Lisp >> +Reference Manual} for more information). > > The @pxref should be "see @ref", and please add a comma after the > closing brace (some old versions of makeinfo insist on that). @pxref > is only appropriate if its closing brace immediately precedes the > closing parenthesis. > > Otherwise LGTM, thanks. Thanks for your patience! What about this? Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-prog-fill-reindent-defun-bug-59664.patch >From f657157b02dd873806d261612bc906f113ea3b89 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Fri, 9 Dec 2022 20:12:51 +0100 Subject: [PATCH] Add prog-fill-reindent-defun (bug#59664) Introduce a new command that aims to reindent code in a defun, or fill a paragraph of text. The command uses treesit.el when available, otherwise falls back to using syntax-ppss and regexps. Treesit.el needs a new variable that is intended to be set by the major modes so that this and other future functions can know what kind of node we are looking at. * doc/emacs/programs.texi: Mention the new command. * etc/NEWS: Mention the new command. * lisp/progmodes/c-ts-mode.el (c++-ts-mode): Add regexp for the new variable. * lisp/progmodes/csharp-mode.el (csharp-ts-mode): Add regexp for the new variable. * lisp/progmodes/java-ts-mode.el (java-ts-mode): Add regexp for the new variable. * lisp/progmodes/js.el (js-ts-mode): Add regexp for the new variable. * list/progmodes/prog-mode.el (prog-mode-map): Bind the new command by default. (prog-fill-reindent-defun): New command. * lisp/progmodes/sh-script.el (bash-ts-mode): Add regexp for the new variable. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-base-mode): Add regexp for the new variable. * lisp/treesit.el (treesit-text-type-regexp): New variable. --- doc/emacs/programs.texi | 19 +++++++++++++++ etc/NEWS | 7 ++++++ lisp/progmodes/c-ts-mode.el | 4 ++++ lisp/progmodes/csharp-mode.el | 5 ++++ lisp/progmodes/java-ts-mode.el | 5 ++++ lisp/progmodes/js.el | 5 ++++ lisp/progmodes/prog-mode.el | 35 ++++++++++++++++++++++++++-- lisp/progmodes/sh-script.el | 4 ++++ lisp/progmodes/typescript-ts-mode.el | 4 ++++ lisp/treesit.el | 9 +++++++ 10 files changed, 95 insertions(+), 2 deletions(-) diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index ba8475e86a..3b60732171 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -409,6 +409,9 @@ Multi-line Indent @table @kbd @item C-M-q Reindent all the lines within one parenthetical grouping. +@item M-q +Fill a single paragraph in a defun, or reindent all the lines within +that defun. @item C-u @key{TAB} Shift an entire parenthetical grouping rigidly sideways so that its first line is properly indented. @@ -429,6 +432,22 @@ Multi-line Indent etc. To correct the overall indentation as well, type @kbd{@key{TAB}} first. +@kindex M-q +@findex prog-fill-reindent-defun +@vindex beginning-of-defun-function +@vindex end-of-defun-function +@vindex fill-paragraph-function + Major modes that derive from @code{prog-mode} can either fill a +single paragraph in a defun, such as a doc-string, or a comment, or +(re)indent the surrounding defun if point is not in a comment or a +string by typing @kbd{M-q} or using the command @kbd{M-x +prog-fill-reindent-defun}. The bounds of a defun is decided by the +variable @code{beginning-of-defun-function} and +@code{end-of-defun-function}, and the filling mechanism is decided by +@code{fill-paragraph-function} (@ref{List Motion,,, elisp, The Emacs +Lisp Reference Manual}, or @ref{Filling,,, elisp, The Emacs Lisp +Reference Manual} for more information). + @kindex C-u TAB If you like the relative indentation within a grouping but not the indentation of its first line, move point to that first line and type diff --git a/etc/NEWS b/etc/NEWS index 61f813568f..a5eb7f332d 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -61,6 +61,13 @@ using this new option. (Or set 'display-buffer-alist' directly.) After manually editing 'eshell-aliases-file', you can use 'M-x eshell-read-aliases-list' to load the edited aliases. +** Prog Mode ++++ +*** New command 'prog-fill-reindent-defun' +This command either fills a single paragraph in a defun, such as a +doc-string, or a comment, or (re)indents the surrounding defun if +point is not in a comment or a string. It is by default bound to +'M-q' in 'prog-mode' and all its descendants. * New Modes and Packages in Emacs 30.1 diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 08b03d5666..114ffc0b03 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -603,6 +603,10 @@ c++-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "raw_string_literal"))) + (treesit-parser-create 'cpp) (setq-local treesit-simple-indent-rules diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index 8ab5fbc91d..3faeb54fc5 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el @@ -911,6 +911,11 @@ csharp-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "verbatim_string-literal" + "interpolated_verbatim_string-text"))) + ;; Indent. (setq-local treesit-simple-indent-rules csharp-ts-mode--indent-rules) diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 96e0d5244c..b1bf965e4f 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -308,6 +308,11 @@ java-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("line_comment" + "block_comment" + "text_block"))) + ;; Indent. (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 45dfef372c..d0b243a22f 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3857,6 +3857,11 @@ js-ts-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) (setq-local comment-multi-line t) + + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "template_string"))) + ;; Electric-indent. (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) ;FIXME: js2-mode adds "[]*". diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index 58cb48f182..1bd8234dc9 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -30,7 +30,11 @@ ;;; Code: (eval-when-compile (require 'cl-lib) - (require 'subr-x)) + (require 'subr-x) + (require 'treesit)) + +(declare-function treesit-parser-list "treesit.c") +(declare-function treesit-node-type "treesit.c") (defgroup prog-mode nil "Generic programming mode, from which others derive." @@ -102,7 +106,8 @@ prog-context-menu (defvar-keymap prog-mode-map :doc "Keymap used for programming modes." - "C-M-q" #'prog-indent-sexp) + "C-M-q" #'prog-indent-sexp + "M-q" #'prog-fill-reindent-defun) (defvar prog-indentation-context nil "When non-nil, provides context for indenting embedded code chunks. @@ -140,6 +145,32 @@ prog-indent-sexp (end (progn (forward-sexp 1) (point)))) (indent-region start end nil)))) +(defun prog-fill-reindent-defun (&optional argument) + "Refill or reindent the paragraph or defun that contains point. + +If the point is in a string or a comment, fill the paragraph that +contains point or follows point. + +Otherwise, reindent the definition that contains point or follows +point." + (interactive "P") + (save-excursion + (let ((treesit-text-node + (and (treesit-parser-list) + (string-match-p + treesit-text-type-regexp + (treesit-node-type (treesit-node-at (point))))))) + (if (or treesit-text-node + (nth 8 (syntax-ppss)) + (re-search-forward comment-start-skip (line-end-position) t)) + (if (memq fill-paragraph-function '(t nil)) + (lisp-fill-paragraph argument) + (funcall fill-paragraph-function argument)) + (beginning-of-defun) + (let ((start (point))) + (end-of-defun) + (indent-region start (point) nil)))))) + (defun prog-first-column () "Return the indentation column normally used for top-level constructs." (or (car prog-indentation-context) 0)) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index e170d18afe..1605e40347 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1619,6 +1619,10 @@ bash-ts-mode ( bracket delimiter misc-punctuation operator))) (setq-local treesit-font-lock-settings sh-mode--treesit-settings) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "heredoc_start" + "heredoc_body"))) (treesit-major-mode-setup))) (advice-add 'bash-ts-mode :around #'sh--redirect-bash-ts-mode diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 20916eaf37..59598b4c63 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -323,6 +323,10 @@ typescript-ts-base-mode (group (or (syntax comment-end) (seq (+ "*") "/"))))) + (setq-local treesit-text-type-regexp + (regexp-opt '("comment" + "template_string"))) + ;; Electric (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) diff --git a/lisp/treesit.el b/lisp/treesit.el index dbbf7ec18c..41feac35c2 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1626,6 +1626,15 @@ treesit-end-of-defun (when top (goto-char (treesit-node-end top))))) +(defvar-local treesit-text-type-regexp "\\`comment\\'" + "A regexp that matches the node type of textual nodes. + +A textual node is a node that is not normal code, such as +comments and multiline string literals. For example, +\"(line|block)_comment\" in the case of a comment, or +\"text_block\" in the case of a string. This is used by +`prog-fill-reindent-defun' and friends.") + ;;; Activating tree-sitter (defun treesit-ready-p (language &optional quiet) -- 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 11 05:03:47 2022 Received: (at 59662) by debbugs.gnu.org; 11 Dec 2022 10:03:47 +0000 Received: from localhost ([127.0.0.1]:46257 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4JBS-0008Ab-Q9 for submit@debbugs.gnu.org; Sun, 11 Dec 2022 05:03:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48322) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4JBQ-0008AU-Tk for 59662@debbugs.gnu.org; Sun, 11 Dec 2022 05:03:45 -0500 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 1p4JBK-0000z2-Qc; Sun, 11 Dec 2022 05:03:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=KqwfoN/O++hBlCI+SCv7qfMFFntj1qDjus1PdeXD8Xk=; b=gQ5Vfpdxut+z D3vw266VdqC0MAap1UXuSvUxxWvokHxgREmQfVCmdQRzHbjHwgq0axRyOap3UYfPBxDcHOk6a/hlp 9al2fQD9nP3kg96Njaiwlj1K/SydetIgiGQ1WHACBzmYccKZBC6qm7Wc8ztznAhKPPOgslJWo3Ccz yKIWb+6UdBS5vCSlXZDGceI3ZDcAEVqIyR1iE3v+mKIpea0bfg5R/2T1x1DHybcTsqnKTB7sMAL5v M9DE9/DRmruBGs09fr2f083r+KfJcFtHfRGUKXtEL5QZ0Pe5vsEVApitLTOrJS9/1kuZ3iW4G9E1S +eMht7kDVuRt0nebkFUwzw==; 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 1p4JBK-0002M3-5V; Sun, 11 Dec 2022 05:03:38 -0500 Date: Sun, 11 Dec 2022 12:03:35 +0200 Message-Id: <83cz8quuiw.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: <87sfhmxrjh.fsf@thornhill.no> (message from Theodor Thornhill on Sun, 11 Dec 2022 09:39:46 +0100) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> <87wn70injy.fsf@thornhill.no> <834ju4z5vu.fsf@gnu.org> <87mt7wi8sp.fsf@thornhill.no> <83r0x7wdtm.fsf@gnu.org> <87y1rfxb4u.fsf@thornhill.no> <83edt6uzox.fsf@gnu.org> <87sfhmxrjh.fsf@thornhill.no> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Theodor Thornhill > Cc: dgutov@yandex.ru, larsi@gnus.org, 59662@debbugs.gnu.org, > casouri@gmail.com, monnier@iro.umontreal.ca > Date: Sun, 11 Dec 2022 09:39:46 +0100 > > What about this? LGTM, thanks. From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 11 09:13:50 2022 Received: (at 59662) by debbugs.gnu.org; 11 Dec 2022 14:13:50 +0000 Received: from localhost ([127.0.0.1]:46441 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4N5R-0004qm-Kr for submit@debbugs.gnu.org; Sun, 11 Dec 2022 09:13:49 -0500 Received: from out2.migadu.com ([188.165.223.204]:44687) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4N5P-0004qg-9C for 59662@debbugs.gnu.org; Sun, 11 Dec 2022 09:13:48 -0500 Date: Sun, 11 Dec 2022 15:13:22 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1670768025; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kvXivcvxNY0vvt0gbh9K/qlfLCD5+g/rbQOXyfet7OY=; b=gNnvDdtwKjE/e3r0l4ZviTc0wDvBT+55J5r8OmxrCl/t6FV9faMIEx9KDi6YQvvm30Q6RA IqZBMPIV2hnjr1WQT5UHYjufVKEXM/vTgGjEPDrkvP44bbAaWKJ2DjTErM4dL3+MyV5kF+ XQYGZ3e2GN/DrAYCvMomQ2bc+YSXrdqN66AfNv3a5FR5PG5Sl4WDCcgzmfD2QY5SEwzmjo TrPnwUBd1YOuMW7EEhhzMgtgshL4HngSb1a/TXE7NtpPZoj+r2ePcxhPs9oxBP3z90t2ij 5CM3jkXLJuDjCnmp+0G+nw4ApeCTY2tmXj3vzS6puCfyL/vvLXnbqk3E3t+aHA== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Theodor Thornhill To: Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <83cz8quuiw.fsf@gnu.org> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> <87wn70injy.fsf@thornhill.no> <834ju4z5vu.fsf@gnu.org> <87mt7wi8sp.fsf@thornhill.no> <83r0x7wdtm.fsf@gnu.org> <87y1rfxb4u.fsf@thornhill.no> <83edt6uzox.fsf@gnu.org> <87sfhmxrjh.fsf@thornhill.no> <83cz8quuiw.fsf@gnu.org> Message-ID: <9DD157C4-14AE-45CD-8A08-4F84D99B2A47@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 11 December 2022 11:03:35 CET, Eli Zaretskii wrote: >> From: Theodor Thornhill >> Cc: dgutov@yandex=2Eru, larsi@gnus=2Eorg, 59662@debbugs=2Egnu=2Eorg, >> casouri@gmail=2Ecom, monnier@iro=2Eumontreal=2Eca >> Date: Sun, 11 Dec 2022 09:39:46 +0100 >>=20 >> What about this? > >LGTM, thanks=2E Nice=2E Will you or Dmitry install? Thanks, Theo From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 11 15:36:35 2022 Received: (at 59662) by debbugs.gnu.org; 11 Dec 2022 20:36:35 +0000 Received: from localhost ([127.0.0.1]:48105 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4T3r-0002oQ-F7 for submit@debbugs.gnu.org; Sun, 11 Dec 2022 15:36:35 -0500 Received: from mail-wm1-f45.google.com ([209.85.128.45]:37788) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4T3p-0002oK-HF for 59662@debbugs.gnu.org; Sun, 11 Dec 2022 15:36:33 -0500 Received: by mail-wm1-f45.google.com with SMTP id ay14-20020a05600c1e0e00b003cf6ab34b61so3589140wmb.2 for <59662@debbugs.gnu.org>; Sun, 11 Dec 2022 12:36:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=3JlyQbP03nfNd5GpUe3T+vWHeXbwEFWSWSXuth0S5Ms=; b=VtQRa6YE1Cp6D0UewDoiBRJuRG+z105/vx7Laj4Oot9xDfsYTr7vnRnAb1c1vJgCPB oE1YkGYnlvPF4F6Q0y69ppTTcTa9A3EfJavMC4iT/T27BHAW2Mt2t4FuOq/CfYnXxofE UzgU2wmWv06+Iaf4QxclAKNRMlgcrtRJelY46Vbwte4nS1BA8AgZyFTxHI8hzsKvj/b/ yu7KyCkaTzr8uUVUqPBc+DBoQvAsRwpItmr7U/Sd4n7DLgoCPPEsevPWpXk+z6KLBT9/ ovf2/Yt2wheKUElThnDhZyqgUUWS9pvTcExD9nQ+RsSKuPY7Rdqcbd+HBzVY+dzWZnWW ZfJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3JlyQbP03nfNd5GpUe3T+vWHeXbwEFWSWSXuth0S5Ms=; b=Pnoe/9ynGZM0JNOM51RnvNjj0n9HDkmGWb2LjGtmRfNoEVKznHkpDYl0HPdgTRGkYe 59P9ZWFOlga5r6cTrlhMwm7UIzdIbjdxBtnTD9XDfyOXZ/QJAicXeSDPfKPWXiQDjbrk zx8VX1nx4/m2tzzS6iHuD1Bj7uO9DAUl/krTQ4NYl3iCegvn4AE+2ySFVqqCH70+H2Ij dNvOv2C6da+jJJizOX5zWuIEAVuYgedFmUc9mEMcv7JAMdM5b7c4xrJhzX4cKZzQeHx0 D0RcD0c1ndw0kEKYazoPH4uX3eJAUlNqNRxdkawEBQnwKRUYcf1yoAHFVIORmyR9fUxR Dcrw== X-Gm-Message-State: ANoB5pnBwRgkDjJ83Ys1s65nu7/07y8CDaMp6u2OHrEPWdYQmKH6ageu 3bifgYZLWGH2Q6kIzpckLYc= X-Google-Smtp-Source: AA0mqf4Yv5CrGWTzg7XR0jNzH22gfA1M/jJ41rPzl4iRjqAOoKPEAukNSdCXvT+G6lMZDfCysI/OQA== X-Received: by 2002:a05:600c:348a:b0:3c6:e63e:89aa with SMTP id a10-20020a05600c348a00b003c6e63e89aamr10814462wmq.6.1670790987556; Sun, 11 Dec 2022 12:36:27 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id bi27-20020a05600c3d9b00b003d225cdb68esm2234968wmb.0.2022.12.11.12.36.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 11 Dec 2022 12:36:27 -0800 (PST) Message-ID: <43201188-a1bf-3e32-fff0-5232ca871029@yandex.ru> Date: Sun, 11 Dec 2022 22:36:25 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Content-Language: en-US To: Theodor Thornhill , Eli Zaretskii References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <837cz22bgd.fsf@gnu.org> <2C2420B5-A0BE-4A81-A924-0F40DD57F211@thornhill.no> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> <87wn70injy.fsf@thornhill.no> <834ju4z5vu.fsf@gnu.org> <87mt7wi8sp.fsf@thornhill.no> <83r0x7wdtm.fsf@gnu.org> <87y1rfxb4u.fsf@thornhill.no> <83edt6uzox.fsf@gnu.org> <87sfhmxrjh.fsf@thornhill.no> <83cz8quuiw.fsf@gnu.org> <9DD157C4-14AE-45CD-8A08-4F84D99B2A47@thornhill.no> From: Dmitry Gutov In-Reply-To: <9DD157C4-14AE-45CD-8A08-4F84D99B2A47@thornhill.no> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 11/12/2022 16:13, Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > Nice. Will you or Dmitry install? Pushed to master, thank you. From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 11 15:40:05 2022 Received: (at 59662) by debbugs.gnu.org; 11 Dec 2022 20:40:05 +0000 Received: from localhost ([127.0.0.1]:48128 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4T7F-0002qp-1Y for submit@debbugs.gnu.org; Sun, 11 Dec 2022 15:40:05 -0500 Received: from out2.migadu.com ([188.165.223.204]:61700) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4T7C-0002qS-2M for 59662@debbugs.gnu.org; Sun, 11 Dec 2022 15:40:03 -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=1670791198; 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=80kPVI174qqlfRW8bn3iUVnzYejJMX5wBgc+GuXiDog=; b=j0vy0BWF/HikQhnuRutsYM73QuDtKljTs+XqpnLvrVXhL+jIc0HTPbpPcvsfRTvpgW+0Ib KNdUtW+Q/sCBNT6hoZTX4N9atFaflrRnDVQmIb9Wh7tMkcutFoWjIly7uXXAVXt4+ITezl qJKgrfoS9Sz+MJdGXcc7SV/sQQxzsagHBifAcstL3eExx851mjqT5iR7vQYMwY8BsNdLiL M883J+BFcRJ47FeIhSAWridgb5dRk83BPWtpg8Zj1UkvtYy9+Ujd4SHvFlqgywBK9tBr6L JNSrKQwu0y2UPaMEUvTob2qAI1QMd6sFcFUBT+hlnQaxQVel7qV8qqj3MJT+/Q== From: Theodor Thornhill To: Dmitry Gutov , Eli Zaretskii Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun In-Reply-To: <43201188-a1bf-3e32-fff0-5232ca871029@yandex.ru> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> <877cz1d7vq.fsf@thornhill.no> <83ilil1wot.fsf@gnu.org> <877E42C0-4FDD-4ED7-933D-AB2199BBCEF3@thornhill.no> <83edt917z5.fsf@gnu.org> <87o7scww07.fsf@thornhill.no> <40acda30-cf00-b419-b726-2794206c96e9@yandex.ru> <87ilikws6a.fsf@thornhill.no> <87edt8wqyo.fsf@thornhill.no> <64801406-62b9-c691-da3e-b8dbcee203be@yandex.ru> <87wn70injy.fsf@thornhill.no> <834ju4z5vu.fsf@gnu.org> <87mt7wi8sp.fsf@thornhill.no> <83r0x7wdtm.fsf@gnu.org> <87y1rfxb4u.fsf@thornhill.no> <83edt6uzox.fsf@gnu.org> <87sfhmxrjh.fsf@thornhill.no> <83cz8quuiw.fsf@gnu.org> <9DD157C4-14AE-45CD-8A08-4F84D99B2A47@thornhill.no> <43201188-a1bf-3e32-fff0-5232ca871029@yandex.ru> Date: Sun, 11 Dec 2022 21:39:56 +0100 Message-ID: <87359lllnn.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59662 Cc: larsi@gnus.org, 59662@debbugs.gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Dmitry Gutov writes: > On 11/12/2022 16:13, Theodor Thornhill via Bug reports for GNU Emacs, > the Swiss army knife of text editors wrote: >> Nice. Will you or Dmitry install? > > Pushed to master, thank you. Thanks! Theo From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 07 18:01:12 2023 Received: (at 59662-done) by debbugs.gnu.org; 7 Jan 2023 23:01:12 +0000 Received: from localhost ([127.0.0.1]:59174 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEIBb-00075p-MS for submit@debbugs.gnu.org; Sat, 07 Jan 2023 18:01:11 -0500 Received: from mail-pj1-f43.google.com ([209.85.216.43]:43969) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEIBZ-00075b-VX for 59662-done@debbugs.gnu.org; Sat, 07 Jan 2023 18:01:10 -0500 Received: by mail-pj1-f43.google.com with SMTP id b9-20020a17090a7ac900b00226ef160dcaso3774885pjl.2 for <59662-done@debbugs.gnu.org>; Sat, 07 Jan 2023 15:01:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=NlocxVyHErPeslVWIdjjlLqewA2s7qZiPpa6e9gBEqU=; b=U67VjB8V/eIVoRbTa7xnzyZK6TH7ohnhgW7zhYiVJJkEIfTvJ5XVqeFNhnCtRu51OP iwGVDhf2XDJ63f8wQtw05sDMUTzYOPD8NKe4qorHtKfdgInK+dpLstsuhmXZ4N+8E0Dm FHlN5rZFYWR2g4nHOw3DxTWiNCSYS741RwZH+mt3s5mds8l+ACW0tpo2rTKZ3ATakVU7 qyWGlEcTwCxqVN6dls+YrnpRhf9h05B4356bQriHZnsPwu0/YDjiu7JLcjqknozsbQTC 7U/PnT5eqL14kd2z2sI1rf4D/JN8pFk2Rz+3qbqnWemNUbzW3yl7rki2EiFwITjZ//5D ETxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NlocxVyHErPeslVWIdjjlLqewA2s7qZiPpa6e9gBEqU=; b=TvB0gbiEHIctxFJibarZ61u3UFW9RICf0oNWztIJzHeP5tGPlQLeOZWkY9WoT6eJW8 NDH+1MUCq735ZzHKM+2I4et1PMh4mcu1WtK1aOUU7LMWWnD8SY3ovHpXinzWphUeSixn AOXAy3qWleOFpJMLHOb3A1Yei6Fr0moTgR0V7USOfTiKSnnjhqbtqZSWueYMtxDAD2lI hI4tLhf8AmgKe8umwGSs/y91LMxKzGm3w7ju1rvsWHDEsyDRh+0m7dCCnugEoRFnYj9r nxvGYyJ4RyE8emGgsvrC9/Z53omF7MFV6tlerGSEBUHOfzYBUokQGxn49/Y64NDWUtrD p8Qw== X-Gm-Message-State: AFqh2krY5ojnEprcpJEgGSWGGIthH2B2x4NUYfdevpxya5ux29WaaRWI K7h7MEU8oN9tb9TyLSnSWec= X-Google-Smtp-Source: AMrXdXvQFD+xnCuyIEaQf5Q2FS2MYHxecJxjFJ9N1IzdFOx0waiZ9gp9TzAM9nal4We7GLI2L7AusA== X-Received: by 2002:a17:903:1c3:b0:192:903f:7ac9 with SMTP id e3-20020a17090301c300b00192903f7ac9mr63581399plh.42.1673132464364; Sat, 07 Jan 2023 15:01:04 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id u5-20020a170902e80500b00189529ed580sm3289886plg.60.2023.01.07.15.01.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Jan 2023 15:01:04 -0800 (PST) From: Yuan Fu Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Message-Id: <8A98A12D-13D8-42E1-8597-46BF90C0670A@gmail.com> Date: Sat, 7 Jan 2023 15:01:03 -0800 To: Theodor Thornhill X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 59662-done Cc: 59662-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Theodor Thornhill writes: > Dmitry Gutov writes: > >> On 11/12/2022 16:13, Theodor Thornhill via Bug reports for GNU Emacs, >> the Swiss army knife of text editors wrote: >>> Nice. Will you or Dmitry install? >> >> Pushed to master, thank you. > > Thanks! > > Theo Closing this :-) Yuan From unknown Sun Jul 13 03:51:05 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 05 Feb 2023 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator