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 13:10:42 -0700 Message-ID: <3D177E1E-E681-47D7-927D-D4FF4B1535E8@gmail.com> References: <3A7E7CD1-74A7-4352-9DFE-FC982EAA398E@gmail.com> <87ilko9r9e.fsf@gnus.org> <9794E2EF-4DB5-4A04-90F0-3EB51E6BE008@gmail.com> <87v8ombrd2.fsf@gnus.org> <86y1titztk.fsf@stephe-leake.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="10165"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen , emacs-devel , Stefan Monnier , Eli Zaretskii To: Stephen Leake Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Oct 14 22:12:25 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 1ojR2e-0002Kh-If for ged-emacs-devel@m.gmane-mx.org; Fri, 14 Oct 2022 22:12:24 +0200 Original-Received: from localhost ([::1]:51552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ojR2d-0006Nu-66 for ged-emacs-devel@m.gmane-mx.org; Fri, 14 Oct 2022 16:12:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49472) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ojR16-0005dP-57 for emacs-devel@gnu.org; Fri, 14 Oct 2022 16:10:48 -0400 Original-Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]:51138) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ojR14-0004cb-Mc; Fri, 14 Oct 2022 16:10:47 -0400 Original-Received: by mail-pj1-x102f.google.com with SMTP id h12so5943030pjk.0; Fri, 14 Oct 2022 13:10:45 -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=2AiRlelodLE+Puf0RcjvHwRrWeqyz2ig9Wj6/IfI1rw=; b=CWhEZhxI93mmzbUIsfwwvfq256iRS3w6prwCTwPh+EDa9CJpNWayodeV44ImENBb76 LoYpmP6bP8pHErjYuHbmJK2A03arV4WOLEnGb8/F3/9YDCUgzFvKLL+AGHgFNakc2f9Q ToD0xZbd81GpHDzgibVcNpTDAdCqjDFccy0CZOIt737x77shQ6nfHGkOMXo2p5YxseLA N24kdGdKf33pP4eiIt5Drbd8cWPUIp3Wd2SYlXhewmhEV5J1ALbBcHx4i+7s87m6/dcu YCkQTW29EKSbJodjAFPXkSNMz2HpOki3ie4QCKLbnMfeUoOPdQvIZANb8OvyU6IbUEEs wfOg== 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=2AiRlelodLE+Puf0RcjvHwRrWeqyz2ig9Wj6/IfI1rw=; b=UKva1fVCSf8aaJgXRQB9Ni3xHp0dwNZa3gdJukPkMGXgxm5v/GYQrnTCPVnBa0gKx9 m0+xK10jWrQ9SU5ghk1kqGjF9CTTyvA5pzaa0Gy/Fh2qFmpjhAIK83NH0kZlyEdzNyWR i14OvMGru9RgEjij8K9XIs+bdKhDCUwD2IOpB3wQ24a2EUxYsQKtG61bY7oB52EpJVfn kENnS7uxrcPvCM01WxVYfETJAS5uxUM5vymznJwrn/qplW2YcNmD8NHuqfwAz+wSmVlY FoQQJaEgHROWFiYvB6fsYVFyux6/A44JlHUDLoK/21cMMEZteofxYmy+bcwh3wPzfSiA IsHQ== X-Gm-Message-State: ACrzQf0wHZiGlXTB26QfuLuZg6WgLhPdU6AqxWqaEw+7+x0U+HC1iOtO OAP6xDubCDCNszRQy9X6HZI= X-Google-Smtp-Source: AMsMyM4T2T8RsQrTXTAuA4GFDmASk0j9QPbOxf5HbsXXRChHmiROKGLrlaA8GkhyAOsxxAopD0MrcQ== X-Received: by 2002:a17:902:ee82:b0:185:3a76:d39c with SMTP id a2-20020a170902ee8200b001853a76d39cmr6717099pld.166.1665778244405; Fri, 14 Oct 2022 13:10:44 -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 25-20020a630b19000000b0045ff216a0casm1806131pgl.3.2022.10.14.13.10.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Oct 2022 13:10:44 -0700 (PDT) In-Reply-To: <86y1titztk.fsf@stephe-leake.org> X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=casouri@gmail.com; helo=mail-pj1-x102f.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:297733 Archived-At: > On Oct 14, 2022, at 4:22 AM, Stephen Leake = wrote: >=20 > Lars Ingebrigtsen writes: >=20 >> Yuan Fu writes: >>=20 >>> I wonder if we can have a major mode hook that runs before the body >>> runs, like xxx-mode-before-hook. Then user can set >>> feature-provider-alist in that hook. This way major modes can decide >>> what backend (provider) to use for each features. >=20 > +1 >=20 > I needed something similar in ada-mode; I implemented it by moving = have > of the major mode function into a post-local-vars hook; that runs > after the major mode function. I think the best way to allow users to alter major mode=E2=80=99s setup = is to have such a hook run after clearing local variable but before = major mode setup. Currently since major mode hook run after the setup, = setting local variable in the hook doesn=E2=80=99t do anything. Example: (defvar-local treesit-activate nil) ;; Enable for python-mode, TBH this looks a bit awkward. (add-hook 'python-mode-before-hook (lambda () (setq treesit-activate t))) (define-minor-mode global-treesit-mode "" :global t (if global-treesit-mode (setq-default treesit-activate t) (setq-default treesit-activate nil))) ;; Not sure about minor mode yet. Yuan=