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 16:06:13 -0700 Message-ID: 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> <21B2ADDF-70BC-46D4-98D6-41C5D0EF7D40@gmail.com> 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="1696"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen , emacs-devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Oct 19 01:08:22 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 1okvh8-0000DA-Ec for ged-emacs-devel@m.gmane-mx.org; Wed, 19 Oct 2022 01:08:22 +0200 Original-Received: from localhost ([::1]:47896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okvh6-0001fN-UR for ged-emacs-devel@m.gmane-mx.org; Tue, 18 Oct 2022 19:08:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42588) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okvfG-0000P1-Qg for emacs-devel@gnu.org; Tue, 18 Oct 2022 19:06:27 -0400 Original-Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]:51825) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1okvf8-0004Kt-DC for emacs-devel@gnu.org; Tue, 18 Oct 2022 19:06:26 -0400 Original-Received: by mail-pj1-x1035.google.com with SMTP id cl1so15337930pjb.1 for ; Tue, 18 Oct 2022 16:06:17 -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=yLzziZ2opf0Jd/0EkiOLRMEgWBCJ2X5EEezfGI+2do8=; b=fxaQn+Q07aCU3owgJHN8sDhoHHG0Di6APEIgFGnu4xMpz4H0cdW2LeRnyXQN2bm11x O7hGg03bkxl0qSiWymPfLYfRwyYX37f26OV/AvSolyC36d1ulws5k2FMdPr2JjLBnz7T EUy2bE9AgYN9orHRf9tpca+jKoQEz86rateOXBy8kEPiuKN2TEa9E071QEkrxdzoRQhM UBt2vpUm16Zz56OyJAw6YrMR67kewTcu4jwpmWTOHXheaEKNMCL4DAdGmycr9bwNu8I8 cd66j0LKpuAbIa2XWUc9cLpyEY12WkF9BJCJqcghCDD7KZgvlVHDnV9rk75+jFjF6kB/ RozA== 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=yLzziZ2opf0Jd/0EkiOLRMEgWBCJ2X5EEezfGI+2do8=; b=iDDYNfkjwPdwlf4t6YgYF7k8S2/Nc4FX6C4jC4fG6KELRgFvwi9d97pLlHnFMlJTP5 6EKplvghMO+jff5CfeQ3wmu/JXof/G1UISwyfXFsY9mQuJg5FFH8OpjS558GFTuFr1mN 8b++tQV3W2Icc/IiDF6+kARJgVx8mtTe1vFDy5VkhntcZy9yBUtw4h+x3Nv49skTfqeO lMM2m7TArSYa1CX9Ej48MyQ5QsAgSbFRK8Mptl5hpZaEOwx4BaK6MZprQEyR7O0eT2jI tb/x+NVUcqAfjL5i41Mu2WFWR3/BKPACati6V4dBcX7dEaNbKWmdb5/a8tozD9GYzoaj 8XsQ== X-Gm-Message-State: ACrzQf1OWo3N9/bZpLyIkPHC4WtqmL8cSB8dfzGM5pynuP86GopVz/L2 oH+2mlUoKANRN5RZ26YAObc= X-Google-Smtp-Source: AMsMyM5OxhankSt5ak7v7DfrYg/Zab+InozriMYjU0YOfOaV6IXsTeNw4ZcdQOq9Aw+Qg8pi+BePcg== X-Received: by 2002:a17:902:c943:b0:184:2f55:e6f4 with SMTP id i3-20020a170902c94300b001842f55e6f4mr5269774pla.55.1666134375832; Tue, 18 Oct 2022 16:06:15 -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 c21-20020a63da15000000b00439c6a4e1ccsm8556514pgh.62.2022.10.18.16.06.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Oct 2022 16:06:15 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=casouri@gmail.com; helo=mail-pj1-x1035.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, T_SPF_HELO_TEMPERROR=0.01, T_SPF_TEMPERROR=0.01 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:298091 Archived-At: > On Oct 18, 2022, at 3:31 PM, Stefan Monnier = wrote: >=20 >>> Too much magic, IMO. Let each case handle it manually, since I = suspect >>> that every case will be different and the best thing to do will vary = (it >>> depends on whether the two modes are still actively maintained, = whether >>> by the same authors or not, the relative age and popularity of the >>> respective modes, =E2=80=A6) >>=20 >> So we don=E2=80=99t do anything in global-treesit-mode? Ie, >>=20 >> (define-globalized-minor-mode global-treesit-mode treesit-mode >> global-treesit-mode--turn-on >> :version "29.1" >> :group 'treesit >> :predicate t >> (when (not global-treesit-mode) >> (dolist (map treesit-remapped-major-mode-alist) >> (setq major-mode-remap-alist >> (remove map major-mode-remap-alist))))) >>=20 >> to >>=20 >> (define-globalized-minor-mode global-treesit-mode treesit-mode >> global-treesit-mode--turn-on >> :version "29.1" >> :group 'treesit >> :predicate t >> ) >>=20 >> And remove treesit-remapped-major-mode-alist? >=20 > That's I'd do, yes. >=20 > It's much easier to add features later (if they prove to satisfy > a common need) than to remove unused features. >=20 > BTW, I see that `global-treesit-mode--turn-on` is currently a (non > official) alias of `treesit-mode`, but I think it should only call > `treesit-mode` in those buffers where there is some indication that = the > major mode provides some treesit-mode support (e.g., currently that > could be if `major-mode-backend-function` is set). I=E2=80=99m changing it to what you described in another email. (So = major-mode-backend-function is goner). I can use = treesit-font-lock-settings as the minimum criterion. >=20 > And then maybe `treesit-mode` should signal an error (and turn itself > off) if it's enabled in a buffer whose major mode does not provide any > support for `treesit-mode`. So currently treesit-mode signals a warning if it can=E2=80=99t activate = tree-sitter and (eq this-command =E2=80=99treesit-mode), but if it is = called in find-file-hook, etc set up by global-treesit-mode, it = doesn=E2=80=99t signal a warning. The idea is that if a user actively = tries to turn on treesit-mode (by M-x treesit-mode), they should know if = it didn=E2=80=99t work, but if they just turns on global-treesit-mode, = they shouldn=E2=80=99t be bothered with warnings-in-the-face. And if one = wants to know if tree-sitter is working for a buffer, they can use M-x = treesit-mode to get a clear answer. Yuan=