GNU bug report logs - #15004
24.3; fill-paragraph on perl-mode indented comment at start of buffer

Previous Next

Package: emacs;

Reported by: Kevin Ryde <user42 <at> zip.com.au>

Date: Thu, 1 Aug 2013 23:44:01 UTC

Severity: minor

Tags: confirmed

Found in versions 28.0.50, 24.3

Full log


View this message in rfc822 format

From: Mauro Aranda <maurooaranda <at> gmail.com>
To: 15004 <at> debbugs.gnu.org
Cc: Kevin Ryde <user42 <at> zip.com.au>
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
Kevin Ryde <user42 <at> 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.






This bug report was last modified 2 years and 266 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.