]> git.eshelyaron.com Git - emacs.git/commitdiff
Support hyphen in Bash function names
authorJames Cherti <contact@jamescherti.com>
Sun, 24 Nov 2024 17:09:33 +0000 (12:09 -0500)
committerEshel Yaron <me@eshelyaron.com>
Wed, 4 Dec 2024 17:01:22 +0000 (18:01 +0100)
* 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

index f817e55a04c0c9387cd0f79e4b3197f817eaeace..a070b2efbbb0dfe23904aca014ad862575b5e3d6 100644 (file)
@@ -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