From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: JD Smith Newsgroups: gmane.emacs.devel Subject: On treesit preference for "consumer" modes Date: Sat, 26 Aug 2023 12:47:18 -0400 Message-ID: <7649A9B7-3697-4CA4-BCBE-BAC7DA814B12@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) 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="32444"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Aug 26 18:48:17 2023 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 1qZwSP-0008Hn-DR for ged-emacs-devel@m.gmane-mx.org; Sat, 26 Aug 2023 18:48:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZwRj-00039Z-Nk; Sat, 26 Aug 2023 12:47:35 -0400 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 1qZwRi-00039R-U7 for emacs-devel@gnu.org; Sat, 26 Aug 2023 12:47:34 -0400 Original-Received: from mail-yw1-x112b.google.com ([2607:f8b0:4864:20::112b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qZwRg-0008Al-QL for emacs-devel@gnu.org; Sat, 26 Aug 2023 12:47:34 -0400 Original-Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-58df8cab1f2so21850647b3.3 for ; Sat, 26 Aug 2023 09:47:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693068451; x=1693673251; h=to:date:message-id:subject:mime-version:content-transfer-encoding :from:from:to:cc:subject:date:message-id:reply-to; bh=yC6HniMzwnfVEbTQf2yLbXdgPCDxijzvGQxSpafw1+c=; b=NLjus9G7ArCPcPRLfBFbGasBMChtdS6WXuiivuwB4+ovqkQU9VWHRCBOPJ3ayVhVTJ qiuuFs+z+VyOo8bco4YeQOEDs34smOXF+HqkUl6ewuZglb+diCDp7FiNgVypMDWUD/8O 2ZdPV0K8bupggYSrV+X4W32fEZP71IbXY+qnj3G0bOaY2AHAfqYIDMc43oLYkASX4zls tbVH3FXi0ipiBm2hhyrg8dVTLajbCKFLA1XQ2VOorlORiMUmOTfH63JsNW9930zOGiwe MrJ34yELWuxpMAuE892fSwx/RzkaTjPmAxu03xpzeuwDQHaJKZnk6UPmRzWPHlXtAAYp BXBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693068451; x=1693673251; h=to:date:message-id:subject:mime-version:content-transfer-encoding :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yC6HniMzwnfVEbTQf2yLbXdgPCDxijzvGQxSpafw1+c=; b=V7rlky7tgbAVNPC07L9LBcTNEo80d2xnvtUmdMm09oit8nGdu0O5VFyS+jfefk8qm1 YOxeYMGLF0Qsk+FsxlK7AXz8dtA/720BmNZC6AAfwqaDKTjwLtJV7sbcUuWQnNaURxxU s/f6p8fEMygVb4gB3V787W0R5/iP9b2H06oO74Ye0Qqc4Hj3Y5A4seeoSWU6864GlaFF IvsrGXMwaEkwJdSFMWAdoJaUXESQ1T8fkU9N9QQoZaBs8EVCPv/6HJPJ4zUwlGBzmQt+ UCvfXoopgrPtwk5LMF3gCFM1BqjqChCQZn8LBxu0zupeFY0UPYGg4AP+8ZQQ2FDTN0wJ M8hQ== X-Gm-Message-State: AOJu0YwGiJ8Qj2bTRjbstQA8CmsFtczb4LKhL8h7DfC/bOkLIv9yqBkZ Pxx6TlskAek5+cTT/qW7/R/k0Dc5/Q8glA== X-Google-Smtp-Source: AGHT+IGKPWldkymqF3jMV/GwTL586NrFR9dRHE6aqV26H9GXQQenX4AuDBRYDhHhRJw0+1G2Wv3CjA== X-Received: by 2002:a05:690c:3748:b0:594:e255:bacd with SMTP id fw8-20020a05690c374800b00594e255bacdmr3318270ywb.49.1693068450798; Sat, 26 Aug 2023 09:47:30 -0700 (PDT) Original-Received: from smtpclient.apple ([131.183.131.33]) by smtp.gmail.com with ESMTPSA id v187-20020a8185c4000000b0058cbf72d6f2sm1140191ywf.119.2023.08.26.09.47.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 26 Aug 2023 09:47:29 -0700 (PDT) X-Mailer: Apple Mail (2.3731.700.6) Received-SPF: pass client-ip=2607:f8b0:4864:20::112b; envelope-from=jdtsmith@gmail.com; helo=mail-yw1-x112b.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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:309260 Archived-At: The current LANG-mode and LANG-ts-mode separation leaves some = ambiguities. One in particular: some modes are =E2=80=9Cconsumers=E2=80=9D= of other majors modes. That is, they have a different focus, but use = LANG modes as subordinate helpers for some aspect of their feature set. = Examples: org-mode SRC block highlighting, or a shell mode which wants = to highlight and indent code written at the shell prompt. In the = pre-treesit era, such a =E2=80=9Cconsumer mode=E2=80=9D simply reached = for, e.g., LANG-mode for this, directly making use of all the = customizations users have applied. In the new era of LANG-mode and LANG-ts-mode duality, how should the = consumer mode decide which one to use? 1. Obviously you can check `(treesit-available-p)', but this tells you = nothing about whether the user prefers and has configured treesit = support in their LANG buffers. =20 2. You can be more specific with `(treesit-ready-p LANG)', but again = that only says whether treesit with LANG is possible, not whether it is = desired or configured. 3. You could check `major-mode-remap-alist' for a LANG entry, which does = indicate affirmative user desire for treesit, but=20 a) this is not required to configure LANG-ts-mode for use in LANG = buffers, and =20 b) it=E2=80=99s not clear this variable or its active usage will = persist for the long term, in particular if LANG-mode is eventually = deprecated in favor of LANG-ts-mode. 4. You could force the user to opt-in, with a custom setting like = `some-consumer-mode-support-treesit', but that requires users to spot = this option, and will quite reasonably confuse users who have already = configured treesit support in their LANG buffers. Why should they have = to repeat themselves like that? 5. You could combine #3 with checking `auto-mode-alist', but you=E2=80=99d= have to interpret file extension regexes, which is likely error pone, = and leaves out dir-local variables, etc. Is there some long-term durable, central setting or function which = consumer modes can consult to determine whether to use LANG-mode or = LANG-ts-mode? I guess I=E2=80=99m looking for something like `(treesit-preferred = LANG)=E2=80=99 or `(default-major-mode LANG)=E2=80=99.=