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 #23 received at 62204 <at> debbugs.gnu.org (full text, mbox):

From: Aleksandar Dimitrov <code <at> aleks.bg>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 62204 <at> debbugs.gnu.org, Aleksandar Dimitrov <code <at> aleks.bg>
Subject: Re: bug#62204: 30.0.50; Feature Request: treesit-major-mode-hook
Date: Sun, 19 Mar 2023 23:35:25 +0100
Hi Eli,

Eli Zaretskii <eliz <at> gnu.org> writes:
> Something like that.  Basically, any function that wants to do
> something that depends on tree-sitter being available for the major
> mode should make such a test to determine whether tree-sitter support
> is available.

As mentioned in the other email to Yuan Fu, my goal was to avoid such a check, and
only install those functions that depend on treesitter when treesitter
was available. The reason is less performance-driven and more about my
subjective goal to avoid cluttering functions with conditionals whenever
possible.

> They are, but they are not the only such place.  Many features in
> Emacs use buffer-local variables and keybindings without a special
> hook.
>
> Please also keep in mind that proliferation of general-purpose hooks
> is not without disadvantages.  For starters, a hook disconnects the
> cause from the effect, and makes it harder to track the control flow
> and thus harder to understand how a given Lisp program works.

I agree that hooks add indirection. They were the first tool I pulled
out of my (very limited) Emacs toolbox, because I'm very used to working
with them.

But if such a hook isn't desirable in the grand scheme of things, that's
OK! There are certainly viable alternatives.
Thanks for taking your time to explain this.

Aleks




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

Previous Next


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