From 6f4d453e0eafe1e081d7f1dbef7d128497840dc0 Mon Sep 17 00:00:00 2001 From: James Cherti Date: Sun, 24 Nov 2024 12:09:33 -0500 Subject: [PATCH] Add hyphen to Bash function names in `sh-imenu-generic-expression` --- 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 8ba64100203..04d995d0404 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -300,6 +300,18 @@ sh-imenu-generic-expression (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