emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: On treesit preference for "consumer" modes


From: Eshel Yaron
Subject: Re: On treesit preference for "consumer" modes
Date: Sat, 26 Aug 2023 19:58:57 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Hi,

JD Smith <jdtsmith@gmail.com> writes:

> ...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.

I think the last sentence is a slight over simplification: even before
`foo-ts-mode`s, Emacs didn't have a clean abstraction for a (programming
language) AFAICT, only major modes.  And "competing" major modes for the
same language are not a new problem.  So these "consumer modes" would
have to be more clever and, hopefully, already have the right methods in
place to deal with the existence of multiple major modes per language.
(Admittedly, `foo-ts-mode`s make this challenge much more pronounced.)

Looking at the specific examples you mentioned: Org mode handles this
well with `org-src-lang-modes`, which is quite more sophisticated than
just reaching out for `LANG-mode`.  (BTW in `sweeprolog.el` there's a
similar mechanism for highlighting quasi-quoted content that leverages
similar user option `sweeprolog-qq-mode-alist`.)

The shell input example is more interesting since currently, IIUC,
`shell-mode` really is naive in the sense that it always uses `sh-mode`
without having a user option for specifying e.g. `bash-ts-mode` instead.

Best,

Eshel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]