From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Average-user-facing interface for tree-sitter Date: Tue, 18 Oct 2022 13:54:50 -0700 Message-ID: <21B2ADDF-70BC-46D4-98D6-41C5D0EF7D40@gmail.com> References: <3A7E7CD1-74A7-4352-9DFE-FC982EAA398E@gmail.com> <87ilko9r9e.fsf@gnus.org> <9794E2EF-4DB5-4A04-90F0-3EB51E6BE008@gmail.com> <87977C2D-844B-4F4E-BEA4-8BCBFC8AE354@gmail.com> <6A0F847F-910D-449B-B461-466493CC9847@gmail.com> <87sfjmg69q.fsf@gnus.org> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="718"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , emacs-devel To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Oct 18 23:05:16 2022 Return-path: Envelope-to: ged-emacs-devel@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 1oktlz-000ATX-Iw for ged-emacs-devel@m.gmane-mx.org; Tue, 18 Oct 2022 23:05:15 +0200 Original-Received: from localhost ([::1]:38462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oktlt-0001XV-PB for ged-emacs-devel@m.gmane-mx.org; Tue, 18 Oct 2022 17:05:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57730) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oktc4-0002Na-HS for emacs-devel@gnu.org; Tue, 18 Oct 2022 16:55:00 -0400 Original-Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:51812) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oktby-0002AX-M7 for emacs-devel@gnu.org; Tue, 18 Oct 2022 16:55:00 -0400 Original-Received: by mail-pj1-x1030.google.com with SMTP id cl1so15077130pjb.1 for ; Tue, 18 Oct 2022 13:54:53 -0700 (PDT) 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=cKn8wWxrwse3ZAQXMUvBEVUkG9QHGkmwDHgcyBC3PeU=; b=WtRvRXuGiFK8UkhwwVgkz7NXH6zn9k+LFG/QbjCdXpAz9bpwxjEGl6TL1iW9c5HjN0 4/M3P6Evk5pkgspVksX+hwE8VErKQv7ZAn/j+dAtDexb0018egmqR+vI0wC3EglgAN4H Ncy12jJ4ZE+EvK+iHfd+a0VwNcj/PqwZPxgGwQXHsjtEpwokkjqJT4Zeae9l7Lb2Uu1L 5rALY1t0XvVuJFy3drcVW51M9T4ThbP7rmjEaRQnnqUzQ5nxu2xfzCWRhvlIZAIBIj91 ZpuRuZtW+NUF4uKhUkiWAd2vYVEmdvjTDZAuJFd1JxwKqnJ+ZPEKiP7hEciUk16sJlN7 ipzQ== 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=cKn8wWxrwse3ZAQXMUvBEVUkG9QHGkmwDHgcyBC3PeU=; b=dLCaYEgJWMB6iGs2WyZsYBR325ACvk9r8fnK6jFlVJj1Ofv5EsugxHXD0tzcaYphmH QmbFylLn3JSjayudvZV3a2vcLrwD1tp7Kfp7yDDZU6IYCHoOTgWj8pVH8m+WSVwOVsiM JU3KFHZKw66mL++ohHiBXk7VAynWR/tfeQz94hCbrsoS5jQx9o/MfBpCwNEzQxsHreOd IJkPlsI/qUve76lTgBE3RZMCLRgFRTporfcKf0MA88ogEuxI3HypBwD7AHe4iwBrTr9L uxxvz+m8Dg0ZRuQC1TNRlNOgkbaUFpu1hSYtzfzIO4LYMr5aDqCK3sTAPsQSukrhnF54 n8sA== X-Gm-Message-State: ACrzQf02hLCfaEVXs9Q47R2vHWzspR3IXZzrtsk3sPaPdlwIq6ldDdp9 cS12FU/nhjocN+Z4DOI4dgc= X-Google-Smtp-Source: AMsMyM5zOXHWBuKL/e1XjkbJm+htpXcoVXWoCRMyt4oKGGrKD4TlV4zNsTwcsanXkFRW1sconw01Zw== X-Received: by 2002:a17:90b:4ad1:b0:20a:b974:19a0 with SMTP id mh17-20020a17090b4ad100b0020ab97419a0mr5550872pjb.178.1666126491683; Tue, 18 Oct 2022 13:54:51 -0700 (PDT) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id a6-20020a170902710600b0016d773aae60sm9105637pll.19.2022.10.18.13.54.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Oct 2022 13:54:51 -0700 (PDT) In-Reply-To: <87sfjmg69q.fsf@gnus.org> X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=casouri@gmail.com; helo=mail-pj1-x1030.google.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, 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-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:298080 Archived-At: > On Oct 17, 2022, at 2:15 AM, Lars Ingebrigtsen wrote: >=20 > Yuan Fu writes: >=20 >> If no one has opinions on this, I=E2=80=99m going to implement the >> central-variable approach, since IMO that one is most fit. >=20 > Well, my opinion is that modes is the right approach, since that's = what > we use for most of these things in Emacs, so people are used to them. > (We've been moving a whole bunch of stuff that used to be variables to > modes over the years.) Ok, I installed the toggle system. Now we have treesit-mode and = global-treesit-mode. Major modes set major-mode-backend-function and = treesit-mode uses that function to turn on/off tree-sitter features. mode-backend-function is pretty straightforward for major modes that = supports both tree-sitter and no-tree-sitter. They just need to set = local variables. For separated major modes, they need to do a bit of a dance. Besides = switching to the new major mode, they need to add (mode . new-mode) to = major-mode-remap-alist if global-treesit-mode is on (so next time we go = straight to new-mode as long as global-treesit-mode is on). They also = need to add (mode . new-mode) to treesit-remapped-major-mode-alist so = global-treesit-mode can remove these entries when it turns off. Yuan=