bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#69562: 29.2.50; go-ts-mode does not handle comments with fill-paragr


From: Ankit Gadiya
Subject: bug#69562: 29.2.50; go-ts-mode does not handle comments with fill-paragraph
Date: Wed, 6 Mar 2024 10:52:49 +0530

On Tue, 5 Mar 2024 at 20:19, Dmitry Gutov <dmitry@gutov.dev> wrote:
>
> Please keep the bug address in Cc. The bug tracker does not forward the
> messages to others or save them in history otherwise.
>
Noted, thank you.

> On 05/03/2024 16:22, Ankit Gadiya wrote:
> >> Does you example originally have one long commented line? Because when I
> >> try it that way, filling seems to work fine, comments are added on the
> >> new lines.
> >
> > Yes, I think the lines got wrapped in the mail but I had a long line. 
> > Admittedly
> > that sample is specifically to showcase the issue but a more realistic 
> > scenario
> > is when I already have multiline comments, I update it and want to re-fill
> > it. Here also, it is clear that fill-paragraph does not respect the comment
> > delimiter so it moves them just like regular characters.
> >
> > (all comment lines start with // in case mail adds line breaks)
> >
> >      // Sample is a sample function with a very long comment. Sample is a
> >      // new details added to the comment sample function with a very
> > long comment. Sample is a sample function
> >      // with a very long comment. Sample is a sample function with a very 
> > long
> >      // comment.
> >      func Sample() {
> >
> >      }
> >
> > Becomes this
> >
> >      // Sample is a sample function with a very long comment. Sample is a 
> > // new
> >      details added to the comment sample function with a very long
> > comment. Sample is
> >      a sample function // with a very long comment. Sample is a sample
> > function with
> >      a very long // comment.
> >      func Sample() {
> >
> >      }
>
> That's odd: here it becomes
>
>    // Sample is a sample function with a very long comment. Sample is a
>    // new details added to the comment sample function with a very long
>    // comment. Sample is a sample function with a very long
>    // comment. Sample is a sample function with a very long comment.
>    func Sample() {
>
>    }
>
> > I was able to reproduce it by running `emacs -Q` and manually enabling
> > go-ts-mode in the go file. Please note that in the `go-mode` ELPA package it
> > used to work as it defines its own fill-paragraph function. So possibly that
> > function might be triggered for you if you have that configured?
>
> I've also tried with 'emacs -Q', both the emacs-29 branch and master.
>
> The version you included in the bug report (ae80192d97b8d0e54a94290) is
> very recent, so there can't be any commits that changed things since.
>
> Are you testing in the same Emacs as the one you filed the bug report in?
>

Yes, I only have one Emacs version installed on my system and I'm currently
tracking the emacs-29 branch (last compiled maybe a week ago). I tried enabling
`debug-on-entry` for the `fill-paragraph` function. Here is the
Backtrace if it's
useful. I think beyond this it goes into lower level buffer manipulation
functions.


  current-left-margin()
* move-to-left-margin()
* forward-paragraph(1)
* fill-forward-paragraph(1)
* fill-region(17 269 nil)
* #f(compiled-function (&optional justify region) "Fill paragraph at
or after point.\n\nIf JUSTIFY is non-nil (interactively, with prefix
argument), justify as well.\nIf `sentence-end-double-space' is
non-nil, then period followed by one\nspace does not end a sentence,
so don't break a line there.\nThe variable `fill-column' controls the
width for filling.\n\nIf `fill-paragraph-function' is non-nil, we call
it (passing our\nargument to it), and if it returns non-nil, we simply
return its value.\n\nIf `fill-paragraph-function' is nil, return the
`fill-prefix' used for filling.\n\nThe REGION argument is non-nil if
called interactively; in that\ncase, if Transient Mark mode is enabled
and the mark is active,\ncall `fill-region' to fill each of the
paragraphs in the active\nregion, instead of just filling the current
paragraph." (interactive #f(compiled-function () #<bytecode
0x11237b10c59aec8e>)) #<bytecode -0xb45f5d20aa35b1f>)(nil t)
* apply(#f(compiled-function (&optional justify region) "Fill
paragraph at or after point.\n\nIf JUSTIFY is non-nil (interactively,
with prefix argument), justify as well.\nIf
`sentence-end-double-space' is non-nil, then period followed by
one\nspace does not end a sentence, so don't break a line there.\nThe
variable `fill-column' controls the width for filling.\n\nIf
`fill-paragraph-function' is non-nil, we call it (passing
our\nargument to it), and if it returns non-nil, we simply return its
value.\n\nIf `fill-paragraph-function' is nil, return the
`fill-prefix' used for filling.\n\nThe REGION argument is non-nil if
called interactively; in that\ncase, if Transient Mark mode is enabled
and the mark is active,\ncall `fill-region' to fill each of the
paragraphs in the active\nregion, instead of just filling the current
paragraph." (interactive #f(compiled-function () #<bytecode
0x11237b10c59aec8e>)) #<bytecode -0xb45f5d20aa35b1f>) (nil t))
* fill-paragraph(nil t)
  funcall-interactively(fill-paragraph nil t)
  call-interactively(fill-paragraph record nil)
  command-execute(fill-paragraph record)
  execute-extended-command(nil "fill-paragraph" "fill-pa")
  funcall-interactively(execute-extended-command nil "fill-paragraph" "fill-pa")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

> > Today @stebalien@emacs.ch suggested to set adaptive-fill-regexp for 
> > go-ts-mode
> > and that solved it for me (if this is useful).
> >
> >      (setq-mode-local go-ts-mode adaptive-fill-regexp "[ \t]*//+[ \t]*")
>
> TBH I'm not yet sure what the value of this variable should look like.
> But if I manage to reproduce the bug on my machine, this will be the
> next thing we can try, thanks.

I also tried pulling the latest grammar for go and it's still
reproducing on my machine.





reply via email to

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