Subject: bug#76851: 29.4; cperl-mode builtin fcn indent bug and fix

From: John Ciolfi <[email-masked]>
Date: Sat, 8 Mar 2025 01:07:24 -0500

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

--- 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 ()