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: Juri Linkov
Subject: Re: Turning on/off tree-sitter modes
Date: Sun, 24 Nov 2024 19:29:44 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu)

>> The answer depends on the purpose of the 'treesit-add-enabled-mode'
>> command that I still don't understand.  Is it supposed to be used
>> in user configs as
>> 
>>   (treesit-add-enabled-mode 'ruby-mode 'ruby-ts-mode)
>> 
>> to be another way to do the same as
>> 
>>   (add-to-list 'major-mode-remap-alist '(ruby-mode . ruby-ts-mode))
>> 
>> Or maybe we want to simplify this setting.  Then we need
>> not a command, but a new option 'treesit-enable-modes':
>> 
>>   (add-to-list 'treesit-enable-modes 'ruby-ts-mode)
>
> When you suggest such ways of implementing user preferences, please
> always consider two factors: (a) the complexity from the users' POV,
> and (b) the way to undo the preference.
>
> Using alists or lists for customization requires that users understand
> the basics of lists in Emacs, and have good command of the relevant
> primitives.  As the experience of default-frame-alist suggests, that
> is not a trivial thing to master (IMO, default-frame-alist survives
> only because most users don't customize it directly, but via
> higher-level APIs like set-frame-font etc.).
>
> Undoing the preferences is also not easy when lists/alists are used,
> because there could be more than one element in the list, and it's
> easy to forget to remove all of them.

The Custom UI helps to avoid such problems with the buttons
to add/remove list elements like

  major-mode-remap-alist:
  INS DEL Key: js-mode
          Value: js-ts-mode
  INS DEL Key: ruby-mode
          Value: ruby-ts-mode

>> > Not 100% sure though - because that plan would delete the vast majority of
>> > the uses of the latter from the core (except for TeX's mappings, it seems).
>> 
>> Agreed, 'major-mode-remap-defaults' could be removed when loading a ts-mode 
>> file
>> will not modify file associations anymore.
>
> I don't think we can or should remove it, because it's useful for the
> cases like the TeX/LaTeX mode (for which we set it up now by default).

Agreed, 'major-mode-remap-defaults' should stay to handle rare cases.



reply via email to

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