unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* On treesit preference for "consumer" modes
@ 2023-08-26 16:47 JD Smith
  2023-08-26 17:04 ` Eli Zaretskii
  2023-08-26 17:58 ` Eshel Yaron
  0 siblings, 2 replies; 7+ messages in thread
From: JD Smith @ 2023-08-26 16:47 UTC (permalink / raw)
  To: emacs-devel

The current LANG-mode and LANG-ts-mode separation leaves some ambiguities.  One in particular: some modes are “consumers” 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 “consumer mode” 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.  

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 

  a) this is not required to configure LANG-ts-mode for use in LANG buffers, and
 
  b) it’s 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’d 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’m looking for something like `(treesit-preferred LANG)’ or `(default-major-mode LANG)’.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-08-26 19:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-26 16:47 On treesit preference for "consumer" modes JD Smith
2023-08-26 17:04 ` Eli Zaretskii
2023-08-26 17:14   ` Eli Zaretskii
2023-08-26 17:17   ` JD Smith
2023-08-26 17:31     ` Eli Zaretskii
2023-08-26 17:58 ` Eshel Yaron
2023-08-26 19:18   ` JD Smith

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).