unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Aleksandar Dimitrov <code@aleks.bg>
To: 62204@debbugs.gnu.org
Subject: bug#62204: 30.0.50; Feature Request: treesit-major-mode-hook
Date: Wed, 15 Mar 2023 12:50:38 +0100	[thread overview]
Message-ID: <86cz5adyi9.fsf@aleks.bg> (raw)


I'd like to propose a major mode hook that is called every time any treesit-based major mode is enabled.

My use case is this: I'd like to extend the expand-region.el package so that it can make use of treesit to set the region to any treesit node. This should work in all treesit-based major modes.

Currently, I've found two ways to accomplish loading my functionality for all ts-modes:

- enumerate them all and use their respective hooks
- advise something like `treesit-major-mode-setup` to execute my code

The first idea might miss a mode if Emacs decides to add one down the
line, or if the user defines her own ts-mode.

The second idea does not feel idiomatic, as this sort of functionality
is usually covered by hooks.

I'd imagine there are other use cases for minor modes and other
functionality that we'd like to provide to any ts-based mode, not just
particular ones.

The concrete use-case is exemplified here:
https://github.com/magnars/expand-region.el/pull/279/





             reply	other threads:[~2023-03-15 11:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-15 11:50 Aleksandar Dimitrov [this message]
2023-03-15 14:24 ` bug#62204: 30.0.50; Feature Request: treesit-major-mode-hook Eli Zaretskii
2023-03-16  0:35   ` Aleksandar Dimitrov
2023-03-16  6:38     ` Eli Zaretskii
2023-03-19 22:35       ` Aleksandar Dimitrov
2023-03-18  7:49 ` Yuan Fu
2023-03-19 22:26   ` Aleksandar Dimitrov

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=86cz5adyi9.fsf@aleks.bg \
    --to=code@aleks.bg \
    --cc=62204@debbugs.gnu.org \
    /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 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).