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#60983: 29.0.60; Tree-sitter user-level control Date: Sun, 29 Jan 2023 15:33:22 +0200 Message-ID: <83y1pl79el.fsf@gnu.org> References: <83tu0kkuqo.fsf@gnu.org> <87tu0k3y6t.fsf@thornhill.no> <83mt6ckqts.fsf@gnu.org> <87zgacgiwe.fsf@thornhill.no> <834jshhvjh.fsf@gnu.org> <806A8560-A675-423F-9CFC-67D50D14E304@thornhill.no> 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="30515"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 60983@debbugs.gnu.org, theo@thornhill.no To: Yuan Fu , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 29 14:34:28 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pM7pD-0007kW-J3 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 29 Jan 2023 14:34:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pM7p2-0007NA-Sx; Sun, 29 Jan 2023 08:34:16 -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 1pM7op-0007Kv-GN for bug-gnu-emacs@gnu.org; Sun, 29 Jan 2023 08:34:07 -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 1pM7oo-0002iF-Pv for bug-gnu-emacs@gnu.org; Sun, 29 Jan 2023 08:34:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pM7oo-0004Bk-EZ for bug-gnu-emacs@gnu.org; Sun, 29 Jan 2023 08:34:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 29 Jan 2023 13:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60983 X-GNU-PR-Package: emacs Original-Received: via spool by 60983-submit@debbugs.gnu.org id=B60983.167499921916067 (code B ref 60983); Sun, 29 Jan 2023 13:34:02 +0000 Original-Received: (at 60983) by debbugs.gnu.org; 29 Jan 2023 13:33:39 +0000 Original-Received: from localhost ([127.0.0.1]:42450 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pM7oR-0004B4-GC for submit@debbugs.gnu.org; Sun, 29 Jan 2023 08:33:39 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33966) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pM7oO-0004An-Tq for 60983@debbugs.gnu.org; Sun, 29 Jan 2023 08:33:37 -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 1pM7oJ-0002fG-Ja; Sun, 29 Jan 2023 08:33:31 -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=A4QgDJFmc06kfMqAHaxtiHiNBkwFc0PGlzxGTt+jrDY=; b=fn5TnwA1O0ew5/6Yl6Sb 6KQ6Jwb2aptGb+x2TbNrcem/ydeS75nD641K2aHYvdlBgR5xE/KBPCRb8jYd2E5AgckuILY2bXkIJ T93RY41KDRykD1VGRbUW7K/X7L99P9g5tTj7lp0XIAOUJ7IHPu+ndCSq+Eaesa3X4EAJxXIeXNqcu c8BL5kw2T+bAQzC5BvRAw2N3SjwAs8B1QKAg6Mhoxr1BFax3W6SVVINxL8A3vEGVPzyKGUcHfogW+ qVrsGcgS1OgH10F4LxkJRoLL2LZ3gHC4ZN0G5bwNyCGpVZVKdgCYU+bU+3tFVe0qJc1QNErFCepnK 9U8tId7gA2W/9Q==; 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 1pM7oJ-0000NL-04; Sun, 29 Jan 2023 08:33:31 -0500 In-Reply-To: (message from Yuan Fu on Mon, 23 Jan 2023 15:55:30 -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:254350 Archived-At: > From: Yuan Fu > Date: Mon, 23 Jan 2023 15:55:30 -0800 > Cc: Eli Zaretskii , > Bug Report Emacs > > >> Thanks. What about the questions I asked regarding indentation > >> features, and specifically about c-ts-mode-indent-style? > > > > I am working on that, but I hit some issues where I cannot make treesit recognize the new settings before the whole treesit-major-mode-setup reruns. Just setting the symbol doesn't work, and reenabling the mode inside of the :set function isn't the best idea maybe? > > > > I'd love some pointers to how other modes do similar stuff, but I didn't really find anything. > > One common approach is to iterate over all live buffer and reset the variable (in this case treesit-simple-indent-rules) on applicate buffers (in this case c/c++-ts-mode buffers). > > It would be nice to also have a command c-ts-mode-set-style (like c-set-style) that takes a style symbol and sets treesit-simple-indent-rules accordingly. And in major-mode setup, ie, c-ts-mode’s body, you call it with c-ts-mode-indent-style. This command now exists, courtesy of Theo, but I see some strange misbehavior with it in c++-ts-mode, related to keymap inheritance: emacs -Q M-x c-ts-mode RET C-h c C-c C-q => C-c C-q runs the command c-ts-mode-indent-defun But M-x c++-ts-mode RET C-h c C-c C-q => C-c C-q is undefined This is strange, since the binding is defined in c-ts-mode-map, which is used in c-ts-base-mode: (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 "C-c ." #'c-ts-mode-set-style) ;;;###autoload (define-derived-mode c-ts-base-mode prog-mode "C" "Major mode for editing C, powered by tree-sitter. \\{c-ts-mode-map}" :syntax-table c-ts-mode--syntax-table and both c-ts-mode and c++-ts-mode derive from c-ts-base-mode: (define-derived-mode c-ts-mode c-ts-base-mode "C" "Major mode for editing C, powered by tree-sitter. (define-derived-mode c++-ts-mode c-ts-base-mode "C++" "Major mode for editing C++, powered by tree-sitter. What's missing here? Stefan, any advice?