Subject: bug#19754: sh-script.el: mostly wrong defun-prompt-regexp

From: Lars Ingebrigtsen <[email-masked]>
Date: Tue, 23 Feb 2016 22:15:55 +1100

Carlos Pita <[email-masked]> writes:

> At least in bash you have several valid forms not allowed by that regexp:
>
> 1) spaces between (, ), and { are optional
>
> 2) function name {...} (indeed, function {} is not even valid!)
>
> 3) function name () {...}
>
> 4) function          name() {...}
>
> Also the concat seems pointless to me.
>
> Here is a patched version:
>
> (setq-local defun-prompt-regexp
>         (concat
>          "^\\("
>          "\\(function[ \t]\\)?[ \t]*[[:alnum:]]+[ \t]*([ \t]*)"
>          "\\|"
>          "function[ \t]+[[:alnum:]]+[ \t]*\\(([ \t]*)\\)?"
>          "\\)[ \t]*"))

I've tried a few function definition forms in bash scripts, and your
regexp seems to give much better `C-M-a' action, so I've applied it to
the Emacs trunk.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no