Closed brotzeit closed 7 months ago
If rust-mode was a new package that's supposed to add features to rust-ts-mode it would make sense to use a minor mode. I think there is no real downside to using a derived mode and this way we don't have to apply any additional changes. We can still change this once treesitter is the standard and the old code is deprecated. For now it seems to be the more convenient solution.
But maybe I'm wrong. Other opinions ? @jimblandy @psibi
Ha, I see your point, and backward compatibility is indeed a nice thing :)
Maybe it would be nice if the control variable defaulted to t whenever rust-ts-mode
is available so the transition will be perfectly transparent:
(defcustom rust-mode-treesitter-derive
(and (fboundp 'treesit-language-available-p)
(treesit-language-available-p 'rust))
…
I thought about it but the ts mode applies different syntax highlighting. Users will probably complain that we just change the default. Many rust-mode users only want very basic features. I know those people probably won't use emacs master, but I would wait.
I think we should always feel free to make substantial improvements even when they change behavior. If treesitter is available, reliable, and really provides the improvements it claims to, we should just use it.
Is anything blocking this feature being merged? AFAICS it should be a noop until explicitly enabled.
Can this be merged?
hello. will this be merged or are there any more to be done first? thank you!
I have done a minor change to this PR to make it work for my setup (Emacs 29.1). I can confirm that it works with my basic testing. I'm planning to test drive this PR for around a week to see if I face any issues and merge it if I see no issues.
If others can test drive this PR meanwhile, that will be helpful. An easy way to test this is setting the following variable:
(setq rust-mode-treesitter-derive t)
And in your rust code buffer, check that tree sitter based functions is working (Eg: treesit-end-of-defun
).
I was just looking into a way to complement the new
rust-ts-mode
withrust-mode
features. Wouldn't it be nicer to separate i those features as a minor mode that could be hooked torust-ts-mode
?