GNU bug report logs - #62204
30.0.50; Feature Request: treesit-major-mode-hook

Previous Next

Package: emacs;

Reported by: Aleksandar Dimitrov <code <at> aleks.bg>

Date: Wed, 15 Mar 2023 13:11:02 UTC

Severity: wishlist

Found in version 30.0.50

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Aleksandar Dimitrov <code <at> aleks.bg>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; Feature Request: treesit-major-mode-hook
Date: Wed, 15 Mar 2023 12:50:38 +0100
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/




This bug report was last modified 2 years and 152 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.