From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel =?UTF-8?Q?Mart=C3=ADn?= via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Date: Fri, 02 Dec 2022 20:02:41 +0100 Message-ID: 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> Reply-To: Daniel =?UTF-8?Q?Mart=C3=ADn?= Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39140"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (darwin) Cc: eliz@gnu.org, theo@thornhill.no, casouri@gmail.com To: 59662@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 02 20:03:19 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p1BJe-0009wv-Op for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 02 Dec 2022 20:03:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p1BJR-0001N1-AL; Fri, 02 Dec 2022 14:03:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p1BJO-0001MR-Pu for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 14:03:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p1BJO-0007Yl-Hf for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 14:03:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p1BJO-00009V-Cx for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 14:03:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Daniel =?UTF-8?Q?Mart=C3=ADn?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 02 Dec 2022 19:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59662 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" X-Debbugs-Original-Cc: Eli Zaretskii , 59662@debbugs.gnu.org, Theodor Thornhill , casouri@gmail.com Original-Received: via spool by submit@debbugs.gnu.org id=B.1670007773567 (code B ref -1); Fri, 02 Dec 2022 19:03:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 2 Dec 2022 19:02:53 +0000 Original-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 Original-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 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p1BJC-0001Lz-My for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 14:02:50 -0500 Original-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/CksAVDO9oMfS8dQqe1VIy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-MF: Original-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 Original-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) In-Reply-To: <875yet975l.fsf@thornhill.no> (Theodor Thornhill via's message of "Fri, 02 Dec 2022 16:06:46 +0100") X-Mailer: WebService/1.1.20926 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:249773 Archived-At: 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).