* rust-ts-mode can't refill or reindent comments
@ 2022-12-30 1:20 Brent Westbrook
2022-12-30 8:37 ` Yuan Fu
0 siblings, 1 reply; 2+ messages in thread
From: Brent Westbrook @ 2022-12-30 1:20 UTC (permalink / raw)
To: emacs-devel
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: rust-ts-mode can't refill or reindent comments
2022-12-30 1:20 rust-ts-mode can't refill or reindent comments Brent Westbrook
@ 2022-12-30 8:37 ` Yuan Fu
0 siblings, 0 replies; 2+ messages in thread
From: Yuan Fu @ 2022-12-30 8:37 UTC (permalink / raw)
To: Brent Westbrook; +Cc: emacs-devel
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-30 8:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-30 1:20 rust-ts-mode can't refill or reindent comments Brent Westbrook
2022-12-30 8:37 ` Yuan Fu
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).