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

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

bug#15004: 24.3; fill-paragraph on perl-mode indented comment at start o


From: Mauro Aranda
Subject: bug#15004: 24.3; fill-paragraph on perl-mode indented comment at start of buffer
Date: Wed, 21 Sep 2022 09:32:53 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

Kevin Ryde <user42@zip.com.au> writes:

> Starting from emacs -Q,
>
>  (progn
>    (switch-to-buffer "xx")
>    (erase-buffer)
>    (insert " # aa aa\n")
>    (insert " # bb bb\n")
>    (insert " # cc cc\n")
>    (insert " # dd dd\n")
>    (goto-char (point-min))
>    (perl-mode)
>    (fill-paragraph nil))
>
> gives
>
>  # aa aa
>  # bb bb cc cc dd dd
>
> whereas I hoped the fill-paragraph would include the first line too,
>
>  # aa aa bb bb cc cc dd dd

I can reproduce this on current master.

> The problem is only if the lines are at the start of the buffer.

Indeed, but that seems to be out of sheer luck: somehow the narrowing
goes from the newline previous to the start of comment when the lines
are not at the start of the buffer.

> I couldn't tell where it might go wrong except that it might be related
> to perl-mode using comment-start-skip "\\(^\\|\\s-\\);?#+ *" which has a
> \\(\\) group to demand preceding whitespace if not at start of line.
> If you change it to
>
>   (set (make-local-variable 'comment-start-skip) ";?#+[ \t]*")
>
> then the fill correctly includes the first line.
>

I don't know why comment-start-skip is set this way in perl-mode.  It
tries to do something more than just match the start of a comment and
skip to the body, and that confuses me.

Maybe it can be simplified to just "#+[ \t]*".  Light testing shows no
problem with doing that.  In fact, by no demanding preceding whitespace,
the following works as expected:

sub foo {
    $bar = shift;#Just testing.
}

With point anywhere inside the function, C-M-q moves the comment to
comment-column.







reply via email to

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