GNU bug report logs - #76851
29.4; cperl-mode builtin fcn indent bug and fix

Previous Next

Package: emacs;

Reported by: John Ciolfi <ciolfi <at> mathworks.com>

Date: Sat, 8 Mar 2025 06:10:02 UTC

Severity: normal

Tags: patch

Found in version 29.4

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

Bug is archived. No further changes may be made.

Full log


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

From: John Ciolfi <ciolfi <at> mathworks.com>
To: <bug-gnu-emacs <at> gnu.org>
Subject: 29.4; cperl-mode builtin fcn indent bug and fix
Date: Sat, 8 Mar 2025 01:07:24 -0500
[Message part 1 (text/plain, inline)]
Hi

Given this perl file:

    sub test {
        exec '/bin/echo',
            'Your arguments are: ', @ARGV;
    }
    
    sub exec_fcn {
    }
    
        sub other {
        }

The 'sub other' is indented incorrectly (and all code following it).

The fix is in cperl-after-block-and-statement-beg to not match exec_, i.e. we should
not treat exec_fcn as a builtin. Attached is the fix.

Thanks,
John

[cperl-mode-builtin-fix.patch (text/x-diff, inline)]
--- a/cperl-mode.el
+++ b/cperl-mode.el
@@ -5606,8 +5606,16 @@ Do not look before LIM."
 	 (progn
 	   (forward-sexp -1)
 	   (not
+            ;; Used to indent functions like:
+            ;;    exec 'prog',
+            ;;        @ARGS;
+            ;; [[:space:]] means we will not match exec_fcn and 'sub other' is indented correctly:
+            ;;    sub exec_fcn {
+            ;;    }
+            ;;    sub other {
+            ;;    }
 	    (looking-at
-	     "\\(map\\|grep\\|say\\|printf?\\|system\\|exec\\|tr\\|s\\)\\>")))))))
+	     "\\(map\\|grep\\|say\\|printf?\\|system\\|exec\\|tr\\|s\\)[[:space:]]")))))))
 
 
 (defun cperl-indent-exp ()
[ATT00001 (text/plain, attachment)]

This bug report was last modified 77 days ago.

Previous Next


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