emacs-devel
[Top][All Lists]
Advanced

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

Re: rust-ts-mode can't refill or reindent comments


From: Yuan Fu
Subject: Re: rust-ts-mode can't refill or reindent comments
Date: Fri, 30 Dec 2022 00:37:48 -0800


> On Dec 29, 2022, at 5:20 PM, Brent Westbrook <bwestbr2@go.olemiss.edu> wrote:
> 
> I've been trying out rust-ts-mode, and this is the second issue I've run
> into with prog-fill-reindent-defun. At first I could solve it by adding
> advice to the function to defer to fill-paragraph:
> 
> (advice-add 'prog-fill-reindent-defun
>           :around #'(lambda (_ _) (fill-paragraph)))
> 
> but after rebuilding from the master branch today, fill-paragraph isn't
> working either. There are no errors or messages, but both
> prog-fill-reindent-defun and fill-paragraph fail to do anything on a
> very long comment line when I try calling them interactively or from
> bindings. I've also reproduced this with emacs -Q.

Strangely enough, it works in my config despite having a bug, so I didn’t 
notice it. Anyway, I fixed it.

> 
> I think this is technically a bug, so I can file a bug report if
> preferred, but I thought it would be okay to discuss it here.

I forgot who said it, but the idea is “if you’re not sure if it warrants a bug, 
file a bug report”.

> As far as I can tell, rust-ts-mode is using c-ts-mode-comment-setup to
> prepare to format comments, but prog-fill-reindent-defun seems to work
> as expected on the Rust comment if I switch to c-ts-mode.
> 
> For a concrete example, this is the comment from a bevy example that I'm
> testing on, with my fill-column set to 80:
> 
> impl WallBundle {
>    // This "builder method" allows us to reuse logic across our wall 
> entities, making our code easier to read and less prone to bugs when we 
> change the logic
>    fn new(location: WallLocation) -> WallBundle {
> 
> 28f26b11a1e seems to be the origin of the issue because
> prog-fill-reindent-defun works fine before that (again with -Q). I tried
> commenting out all of the adaptive-regexp stuff in
> c-ts-mode-comment-setup, closing the defun after line 656, and this
> fixed my issue in rust-ts-mode, but I assume the rest of that code is
> necessary for something and that the real issue is somewhere within it.
> 
> I can keep bisecting that section of the code if that would help, but I
> thought someone more familiar with it might be able to identify the
> issue from here. I'm guessing that it's also some kind of clash with
> rust-ts-mode itself since that code works fine in c-ts-mode.

Thanks for debugging this, it should work now!

Yuan




reply via email to

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