all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eshel Yaron <me@eshelyaron.com>
To: JD Smith <jdtsmith@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: On treesit preference for "consumer" modes
Date: Sat, 26 Aug 2023 19:58:57 +0200	[thread overview]
Message-ID: <m1cyz93cta.fsf@eshelyaron.com> (raw)
In-Reply-To: <7649A9B7-3697-4CA4-BCBE-BAC7DA814B12@gmail.com> (JD Smith's message of "Sat, 26 Aug 2023 12:47:18 -0400")

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



  parent reply	other threads:[~2023-08-26 17:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2023-08-26 19:18   ` JD Smith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m1cyz93cta.fsf@eshelyaron.com \
    --to=me@eshelyaron.com \
    --cc=emacs-devel@gnu.org \
    --cc=jdtsmith@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.