GNU bug report logs - #79271
30.1; cperl-mode regexp indent issue

Previous Next

Package: emacs;

Reported by: John C <john.ciolfi.32 <at> gmail.com>

Date: Tue, 19 Aug 2025 17:44:02 UTC

Severity: normal

Found in version 30.1

Done: Harald Jörg <haj <at> posteo.de>

To reply to this bug, email your comments to 79271 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#79271; Package emacs. (Tue, 19 Aug 2025 17:44:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to John C <john.ciolfi.32 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 19 Aug 2025 17:44:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: John C <john.ciolfi.32 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.1; cperl-mode regexp indent issue
Date: Tue, 19 Aug 2025 13:43:14 -0400
[Message part 1 (text/plain, inline)]
1. In a temporary directory, say ~/tmp/, get latest cperl-mode.el from

https://github.com/emacs-mirror/emacs/blob/master/lisp/progmodes/cperl-mode.el
   I used the Jul-28-2025 version

https://github.com/emacs-mirror/emacs/blob/cef4302d309e26c2191821ba998518fb89fff54e/lisp/progmodes/cperl-mode.el

2. cd ~/tmp

3. emacs -Q -L .           # Using emacs 30.1

4. M-x byte-compile-file RET cperl-mode.el RET

5. C-x C-f foo.pl

   C-x h   # select all of foo.pl
   C-M-\   # indent foo.pl

Here's the indented foo.pl:

# -*- mode: cperl -*-
my $str =~ s/^
    (Field1: [^\n]+) \s*
  Field2: \s* (\S+) \s*
            //xsm;

Notice that the regexp is not indented nicely. I would expect "Field2 ..."
to be aligned under
"(Field...)":

  my $str =~ s/^
               (Field1: [^\n]+) \s*
               Field2: \s* (\S+) \s*
               //xsm;


In GNU Emacs 30.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38,
 cairo version 1.16.0) of 2025-04-04, modified by Debian built on sbuild
Windowing system distributor 'The X.Org Foundation', version 11.0.12101006
System Description: Debian GNU/Linux 12 (bookworm)

Configured using:
 'configure --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/libexec
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-libsystemd --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/30.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/30.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils --build
 x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
 --libexecdir=/usr/libexec --localstatedir=/var/lib
 --infodir=/usr/share/info --mandir=/usr/share/man --with-libsystemd
 --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/30.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/30.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils --with-cairo
 --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars
 'CFLAGS=-g -O2
 -ffile-prefix-map=/build/reproducible-path/emacs-30.1+1=.
-fstack-protector-strong
 -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
 -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP
NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: CPerl

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/home/ciolfi/tmp/cperl-mode hides
/usr/share/emacs/30.1/lisp/progmodes/cperl-mode

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util time-date mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs cl-lib sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils compile
text-property-search comint subr-x ansi-osc ansi-color ring comp-run
bytecomp byte-compile comp-common cperl-mode rx facemenu rmc iso-transl
tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
touch-screen tool-bar dnd fontset image regexp-opt fringe tabulated-list
replace newcomment text-mode lisp-mode prog-mode register page tab-bar
menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse
jit-lock font-lock syntax font-core term/tty-colors frame minibuffer
nadvice seq simple cl-generic indonesian philippine cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop
case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo gtk x-toolkit xinput2 x multi-tty move-toolbar
make-network-process native-compile emacs)

Memory information:
((conses 16 84401 12096) (symbols 48 7366 0) (strings 32 20464 1856)
 (string-bytes 1 700197) (vectors 16 11848)
 (vector-slots 8 163636 10525) (floats 8 26 34) (intervals 56 418 0)
 (buffers 992 12))
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79271; Package emacs. (Wed, 20 Aug 2025 14:42:02 GMT) Full text and rfc822 format available.

Message #8 received at 79271 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: John C <john.ciolfi.32 <at> gmail.com>, Harald Jörg
 <haj <at> posteo.de>
Cc: 79271 <at> debbugs.gnu.org
Subject: Re: bug#79271: 30.1; cperl-mode regexp indent issue
Date: Wed, 20 Aug 2025 17:40:59 +0300
> From: John C <john.ciolfi.32 <at> gmail.com>
> Date: Tue, 19 Aug 2025 13:43:14 -0400
> 
> 1. In a temporary directory, say ~/tmp/, get latest cperl-mode.el from
>    https://github.com/emacs-mirror/emacs/blob/master/lisp/progmodes/cperl-mode.el
>    I used the Jul-28-2025 version
>   
> https://github.com/emacs-mirror/emacs/blob/cef4302d309e26c2191821ba998518fb89fff54e/lisp/progmodes/cperl-mode.el
> 
> 
> 2. cd ~/tmp
> 
> 3. emacs -Q -L .           # Using emacs 30.1
> 
> 4. M-x byte-compile-file RET cperl-mode.el RET
> 
> 5. C-x C-f foo.pl
> 
>    C-x h   # select all of foo.pl
>    C-M-\   # indent foo.pl
> 
> Here's the indented foo.pl:
> 
> # -*- mode: cperl -*-
> my $str =~ s/^
>     (Field1: [^\n]+) \s*
>   Field2: \s* (\S+) \s*
>             //xsm;
> 
> Notice that the regexp is not indented nicely. I would expect "Field2 ..." to be aligned under
> "(Field...)":
> 
>   my $str =~ s/^
>                (Field1: [^\n]+) \s*
>                Field2: \s* (\S+) \s*
>                //xsm;

And this one, too.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79271; Package emacs. (Wed, 20 Aug 2025 17:36:02 GMT) Full text and rfc822 format available.

Message #11 received at 79271 <at> debbugs.gnu.org (full text, mbox):

From: Harald Jörg <haj <at> posteo.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 79271 <at> debbugs.gnu.org, John C <john.ciolfi.32 <at> gmail.com>
Subject: Re: bug#79271: 30.1; cperl-mode regexp indent issue
Date: Wed, 20 Aug 2025 17:34:51 +0000
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: John C <john.ciolfi.32 <at> gmail.com>
>> Date: Tue, 19 Aug 2025 13:43:14 -0400
>> 
>> 1. In a temporary directory, say ~/tmp/, get latest cperl-mode.el from
>>    https://github.com/emacs-mirror/emacs/blob/master/lisp/progmodes/cperl-mode.el
>>    I used the Jul-28-2025 version
>>   
>> https://github.com/emacs-mirror/emacs/blob/cef4302d309e26c2191821ba998518fb89fff54e/lisp/progmodes/cperl-mode.el
>> 
>> 
>> 2. cd ~/tmp
>> 
>> 3. emacs -Q -L .           # Using emacs 30.1
>> 
>> 4. M-x byte-compile-file RET cperl-mode.el RET
>> 
>> 5. C-x C-f foo.pl
>> 
>>    C-x h   # select all of foo.pl
>>    C-M-\   # indent foo.pl
>> 
>> Here's the indented foo.pl:
>> 
>> # -*- mode: cperl -*-
>> my $str =~ s/^
>>     (Field1: [^\n]+) \s*
>>   Field2: \s* (\S+) \s*
>>             //xsm;
>> 
>> Notice that the regexp is not indented nicely. I would expect "Field2 ..." to be aligned under
>> "(Field...)":
>> 
>>   my $str =~ s/^
>>                (Field1: [^\n]+) \s*
>>                Field2: \s* (\S+) \s*
>>                //xsm;
>
> And this one, too.

Another very good recipe (and future test case), thanks!

I'll fix that too (hopefully).  cperl-mode wrongly indents "Field2:" as
a label.
-- 
Cheers,
haj




Reply sent to Harald Jörg <haj <at> posteo.de>:
You have taken responsibility. (Fri, 22 Aug 2025 12:18:02 GMT) Full text and rfc822 format available.

Notification sent to John C <john.ciolfi.32 <at> gmail.com>:
bug acknowledged by developer. (Fri, 22 Aug 2025 12:18:02 GMT) Full text and rfc822 format available.

Message #16 received at 79271-done <at> debbugs.gnu.org (full text, mbox):

From: Harald Jörg <haj <at> posteo.de>
To: 79271-done <at> debbugs.gnu.org
Subject: Indentation of "looks like a label" in a regex fixed
Date: Fri, 22 Aug 2025 12:17:41 +0000
This bug has now been fixed in the master branch.  Tests have been
added, including the example code from the report.  I am closing the
issue now.

Keep the reports coming!  There's still a lot of room for improvement
with regard to test coverage in cperl-mode.

-- 
Cheers,
haj




This bug report was last modified 20 days ago.

Previous Next


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