From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun Date: Thu, 01 Dec 2022 09:13:22 +0200 Message-ID: <83o7sniokt.fsf@gnu.org> References: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28641"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59662@debbugs.gnu.org, theo@thornhill.no, casouri@gmail.org To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 01 08:14:20 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 1p0dly-0007FV-RP for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 01 Dec 2022 08:14:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0dlk-0004ag-4i; Thu, 01 Dec 2022 02:14:04 -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 1p0dli-0004a0-Qd for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2022 02:14: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 1p0dli-0006lL-2g for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2022 02:14:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p0dlh-0005Zc-NR for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2022 02:14:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 01 Dec 2022 07:14:01 +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 Original-Received: via spool by 59662-submit@debbugs.gnu.org id=B59662.166987883821411 (code B ref 59662); Thu, 01 Dec 2022 07:14:01 +0000 Original-Received: (at 59662) by debbugs.gnu.org; 1 Dec 2022 07:13:58 +0000 Original-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 Original-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 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 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==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0dlV-0005co-Mc; Thu, 01 Dec 2022 02:13:50 -0500 In-Reply-To: <5B538888-E454-4F75-B3B8-AB20E10B3E89@gmail.com> (message from Yuan Fu on Wed, 30 Nov 2022 15:23:17 -0800) 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:249598 Archived-At: > 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.)