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: Fri, 14 Oct 2022 15:51:15 -0700 Message-ID: <87977C2D-844B-4F4E-BEA4-8BCBFC8AE354@gmail.com> References: <3A7E7CD1-74A7-4352-9DFE-FC982EAA398E@gmail.com> <87ilko9r9e.fsf@gnus.org> <9794E2EF-4DB5-4A04-90F0-3EB51E6BE008@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="24967"; 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 Sat Oct 15 00:52:31 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 1ojTXb-0006Hj-2G for ged-emacs-devel@m.gmane-mx.org; Sat, 15 Oct 2022 00:52:31 +0200 Original-Received: from localhost ([::1]:40294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ojTXZ-0003J4-GS for ged-emacs-devel@m.gmane-mx.org; Fri, 14 Oct 2022 18:52:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ojTWS-0002bc-Mb for emacs-devel@gnu.org; Fri, 14 Oct 2022 18:51:20 -0400 Original-Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:46663) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ojTWR-0001dw-1l for emacs-devel@gnu.org; Fri, 14 Oct 2022 18:51:20 -0400 Original-Received: by mail-pl1-x630.google.com with SMTP id l1so5984449pld.13 for ; Fri, 14 Oct 2022 15:51:18 -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=zcON7AV0+a7GDU6/cmd96gnP9/QfKkPq1TOTW/8FRNc=; b=PlR1OeoMXsgC6rRfHCqrz5eLt1CgpBoGF6CTDWRNYP1zmJIijdQcEyb2NX3dTpvcVL IKSmfJkNgzxAtLsZ/wj9G522oLguOO+2MFTyvcHUPEQlgmL+5x0RmSX6W9dqsBPhZ1cx UlbNGqYutgkgOfJGGCRUMXFSUIIlPnE9CcL49yg2iA2AYuDDO76vJLqmj6+slxPG2LNu o/AUGckK6pY+6jVitfHQAnNFgP9YUt9gLfqu/uwotkrqAR9ezPkQgIRjCgQbe5v1+ct/ sPEj1RdM5dl4ylj6E2w75TCFGzO3xIEmIMsrnraOjBKd0dL2EjZO+gGSfqvTw0s8uYbJ fE7Q== 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=zcON7AV0+a7GDU6/cmd96gnP9/QfKkPq1TOTW/8FRNc=; b=dQ8idVuAyQ3hdnH2TA1NOLhcgZpHQdiMjIqJIAjoQqExxBIqJglFbxY2jbTZSiL/UF c5RNgdYJbFTPL89ToyRXvRGS24jsQsl07vuOZi7i2qIx3jSG1VDm8vcp44e9YpHwjnSX gh+kj8+YGXwQfRT7EDGh7EEvtKWGIUcf3dQCm5AINcor7VDyTZynC7G4bDG3IyrREa9Q tQxhwdx2OLA36sxHyR1ahhuuWoqYDfufHdUiEaFVnZJWkysv/Knubgpot5Djro6eD8JW 0BEppYEMxOpkKuGn3+Xb9NDg0ZGClxGmLBG7QBxyZLnINNSOHWdj8h+f4oBmM8z80og4 6Q4w== X-Gm-Message-State: ACrzQf3gBI7s5eADGYpMNnetS1OqLkEkNMkn4WiVBavyH+cxkaBEzVny Iamd3+g52oC7bdox08n0cUs= X-Google-Smtp-Source: AMsMyM5p3X4sJNuOFt3PU+q5syOuZhremhjyZ/RQ3utA3kkZkYvabRcfzwIDEW5YDqRwXrGiKKt/1A== X-Received: by 2002:a17:90b:4f4e:b0:20d:9f5b:abbf with SMTP id pj14-20020a17090b4f4e00b0020d9f5babbfmr205880pjb.148.1665787877271; Fri, 14 Oct 2022 15:51:17 -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 u21-20020a62d455000000b0053b2681b0e0sm2230745pfl.39.2022.10.14.15.51.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Oct 2022 15:51:16 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=casouri@gmail.com; helo=mail-pl1-x630.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:297739 Archived-At: > On Oct 14, 2022, at 1:49 PM, Stefan Monnier = wrote: >=20 >> I wonder if we can have a major mode hook that runs before the body = runs, >> like xxx-mode-before-hook. >=20 > Given the way things are currently setup, it's not really feasible in > a clean and reliable way, no. >=20 > What we have instead is: > - the `:after-hook`, i.e. part of the major-mode's > code that is run after the major-mode hook. > - The `hack-local-variables-hook` which the major-mode can set > buffer-locally. It's similar to the `after-hook:`, except it's run > after setting the file-local variables, so it's more often what > we want. >=20 I dunno, it literally has =E2=80=9Chack=E2=80=9D in its name. If we = can=E2=80=99t do before-hook, maybe its best to let major mode setup = normally and locally bind treesit-enable-function, which treesit-mode = calls should user add it to major mode hook. And if a user wants more control (eg, use tree-sitter for indent only), = he/she assigns the tree-sitter function to indent-line-function, etc. No = hand-holding from us. Buuut, if a user wants tree-sitter for parent mode but not derived mode, = they need to write (add-hook 'xxx-mode-hook (lambda () (when (eq major-mode 'xxx-mode) (treesit-mode)))) Which again is a bit awkward. So maybe a central variable isn=E2=80=99t that bad an idea. Could you = layout why mapping modes to some information is bad? Can we fix it = somehow? Yuan=