From d8c05064a0de0d7ca378ebebe4f8dd0270c34e5c Mon Sep 17 00:00:00 2001 From: James Cherti Date: Sun, 24 Nov 2024 12:09:33 -0500 Subject: [PATCH] Support hyphen in Bash function names * lisp/progmodes/sh-script.el (sh-imenu-generic-expression): Add hyphen to function-name regexp. Copyright-paperwork-exempt: yes (cherry picked from commit 2ea0919550366babfea1de6468ef9e8b1857b478) --- lisp/progmodes/sh-script.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index f817e55a04c..a070b2efbbb 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -300,6 +300,18 @@ naming the shell." (nil "^\\s-*\\([[:alpha:]_][[:alnum:]_]*\\)\\s-*()" 1))) + ;; The difference between the Bash regular expression and the sh regular + ;; expression is that Bash also allows hyphens (-). + (bash + . ((nil + ;; function FOO + ;; function FOO() + "^\\s-*function\\s-+\\([[:alpha:]_][[:alnum:]_-]*\\)\\s-*\\(?:()\\)?" + 1) + ;; FOO() + (nil + "^\\s-*\\([[:alpha:]_][[:alnum:]_-]*\\)\\s-*()" + 1))) (mksh . ((nil ;; function FOO -- 2.39.5