emacs-devel
[Top][All Lists]
Advanced

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

Re: Turning on/off tree-sitter modes


From: Eli Zaretskii
Subject: Re: Turning on/off tree-sitter modes
Date: Sat, 30 Nov 2024 09:38:46 +0200

> Date: Sat, 30 Nov 2024 05:26:35 +0200
> From: Dmitry Gutov <dmitry@gutov.dev>
> 
> On 29/11/2024 20:09, Stefan Monnier via Emacs development discussions. 
> wrote:
> 
> > In any case I was thinking of a UI that's not specific to tree-sitter
> > that works as follows:
> > 
> >     (defun change-major-mode (newmode)
> >       (interactive (list (read-the-new-mode)))
> >       (cond
> >        ((eq major-mode (the-mode-normally-selected-by-auto-mode-alist))
> >         (setf (alist-get major-mode major-mode-remap-alist) newmode)
> >         (when (called-interactively-p)
> >           (customize-mark-as-set 'major-mode-remap-alist)))
> >        (t
> >         (let ((regexp (guess-regexp buffer-file-name)))
> >           (add-to-list 'auto-mode-alist (cons regexp newmode))
> >           (when (called-interactively-p)
> >             ...somehow convince Custom to do the above `add-to-list`...))))
> >       (funcall newmode))
> 
> That sounds interesting, especially the 'guess-regexp' part. I think it 
> would make it ineligible for calling from the init script, though, which 
> could be a preference for many.

We could have both.  We don't have to choose only one.

> > `read-the-new-mode` could use a variable like Dmitry's
> > `treesit--mode-associations` to provide good defaults.
> > 
> > BTW, this var shouldn't be set like in his patch, IMO but via
> > 
> >      ###;;;autoload
> >      (add-to-list 'treesit--mode-associations (javascript-mode . 
> > js-ts-mode))
> 
> TBF one of my goals for the later patches was to avoid adding new public 
> "registry" variables, like treesit-auto-mode-alist, 
> treesit-major-mode-remap-alist, treesit-interpreter-mode-alist, etc. It 
> seems like having more of them can be a source of confusion, and it's 
> not obvious that using them in 3rd party modes would be a benefit.

I tend to agree that adding such variables adds complexity, which is
perhaps unnecessary.



reply via email to

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