emacs-devel
[Top][All Lists]
Advanced

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

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


From: Brent Westbrook
Subject: rust-ts-mode can't refill or reindent comments
Date: Thu, 29 Dec 2022 20:20:29 -0500
User-agent: mu4e 1.8.13; emacs 30.0.50

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.

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.

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.



reply via email to

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