* Suggestion of enhancement by adding a hyphen to sh-imenu-generic-expression
@ 2024-11-23 21:04 James Cherti
2024-11-24 9:41 ` Eli Zaretskii
0 siblings, 1 reply; 6+ messages in thread
From: James Cherti @ 2024-11-23 21:04 UTC (permalink / raw)
To: emacs-devel
Hello,
While editing a Bash shell script today, I discovered that imenu does
not include functions with hyphens in their names.
While it is true that sh does not allow hyphens in function names, Bash
does permit them.
My suggestion is to add a hyphen '-' to the sh-imenu-generic-expression
(sh-script.el) regular expression to make imenu include these functions,
--
James Cherti
https://www.jamescherti.com/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Suggestion of enhancement by adding a hyphen to sh-imenu-generic-expression
2024-11-23 21:04 Suggestion of enhancement by adding a hyphen to sh-imenu-generic-expression James Cherti
@ 2024-11-24 9:41 ` Eli Zaretskii
2024-11-24 17:21 ` James Cherti
0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2024-11-24 9:41 UTC (permalink / raw)
To: James Cherti; +Cc: emacs-devel
> Date: Sat, 23 Nov 2024 16:04:17 -0500
> From: James Cherti <contact@jamescherti.com>
>
> Hello,
>
> While editing a Bash shell script today, I discovered that imenu does
> not include functions with hyphens in their names.
>
> While it is true that sh does not allow hyphens in function names, Bash
> does permit them.
>
> My suggestion is to add a hyphen '-' to the sh-imenu-generic-expression
> (sh-script.el) regular expression to make imenu include these functions,
Would you like to submit a patch along these lines?
Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Suggestion of enhancement by adding a hyphen to sh-imenu-generic-expression
2024-11-24 9:41 ` Eli Zaretskii
@ 2024-11-24 17:21 ` James Cherti
2024-11-30 10:35 ` Eli Zaretskii
0 siblings, 1 reply; 6+ messages in thread
From: James Cherti @ 2024-11-24 17:21 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 894 bytes --]
Hello Eli,
Attached is the patch you requested for sh-script.el.
The patch enables the use of hyphens in Bash function names by adding a
regular expression for Bash to `sh-imenu-generic-expression`.
--
James Cherti
GitHub: https://github.com/jamescherti
Website: https://www.jamescherti.com/
On 2024-11-24 04:41, Eli Zaretskii wrote:
>> Date: Sat, 23 Nov 2024 16:04:17 -0500
>> From: James Cherti <contact@jamescherti.com>
>>
>> Hello,
>>
>> While editing a Bash shell script today, I discovered that imenu does
>> not include functions with hyphens in their names.
>>
>> While it is true that sh does not allow hyphens in function names, Bash
>> does permit them.
>>
>> My suggestion is to add a hyphen '-' to the sh-imenu-generic-expression
>> (sh-script.el) regular expression to make imenu include these functions,
>
> Would you like to submit a patch along these lines?
>
> Thanks.
[-- Attachment #2: bash-imenu-hyphen.patch --]
[-- Type: text/x-patch, Size: 1092 bytes --]
From 6f4d453e0eafe1e081d7f1dbef7d128497840dc0 Mon Sep 17 00:00:00 2001
From: James Cherti <contact@jamescherti.com>
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: Suggestion of enhancement by adding a hyphen to sh-imenu-generic-expression
2024-11-24 17:21 ` James Cherti
@ 2024-11-30 10:35 ` Eli Zaretskii
2024-11-30 13:28 ` Visuwesh
0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2024-11-30 10:35 UTC (permalink / raw)
To: James Cherti; +Cc: emacs-devel
> Date: Sun, 24 Nov 2024 12:21:04 -0500
> From: James Cherti <contact@jamescherti.com>
> Cc: emacs-devel@gnu.org
>
> Hello Eli,
>
> Attached is the patch you requested for sh-script.el.
>
> The patch enables the use of hyphens in Bash function names by adding a
> regular expression for Bash to `sh-imenu-generic-expression`.
Thanks, installed on the master branch.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Suggestion of enhancement by adding a hyphen to sh-imenu-generic-expression
2024-11-30 10:35 ` Eli Zaretskii
@ 2024-11-30 13:28 ` Visuwesh
2024-11-30 14:02 ` Eli Zaretskii
0 siblings, 1 reply; 6+ messages in thread
From: Visuwesh @ 2024-11-30 13:28 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: James Cherti, emacs-devel
[சனி நவம்பர் 30, 2024] Eli Zaretskii wrote:
>> Date: Sun, 24 Nov 2024 12:21:04 -0500
>> From: James Cherti <contact@jamescherti.com>
>> Cc: emacs-devel@gnu.org
>>
>> Hello Eli,
>>
>> Attached is the patch you requested for sh-script.el.
>>
>> The patch enables the use of hyphens in Bash function names by adding a
>> regular expression for Bash to `sh-imenu-generic-expression`.
>
> Thanks, installed on the master branch.
bug#56003 and bug#52319 can be closed now.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Suggestion of enhancement by adding a hyphen to sh-imenu-generic-expression
2024-11-30 13:28 ` Visuwesh
@ 2024-11-30 14:02 ` Eli Zaretskii
0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2024-11-30 14:02 UTC (permalink / raw)
To: Visuwesh; +Cc: contact, emacs-devel
> From: Visuwesh <visuweshm@gmail.com>
> Cc: James Cherti <contact@jamescherti.com>, emacs-devel@gnu.org
> Date: Sat, 30 Nov 2024 18:58:21 +0530
>
> [சனி நவம்பர் 30, 2024] Eli Zaretskii wrote:
>
> >> Date: Sun, 24 Nov 2024 12:21:04 -0500
> >> From: James Cherti <contact@jamescherti.com>
> >> Cc: emacs-devel@gnu.org
> >>
> >> Hello Eli,
> >>
> >> Attached is the patch you requested for sh-script.el.
> >>
> >> The patch enables the use of hyphens in Bash function names by adding a
> >> regular expression for Bash to `sh-imenu-generic-expression`.
> >
> > Thanks, installed on the master branch.
>
> bug#56003 and bug#52319 can be closed now.
Thanks, done.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-11-30 14:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-23 21:04 Suggestion of enhancement by adding a hyphen to sh-imenu-generic-expression James Cherti
2024-11-24 9:41 ` Eli Zaretskii
2024-11-24 17:21 ` James Cherti
2024-11-30 10:35 ` Eli Zaretskii
2024-11-30 13:28 ` Visuwesh
2024-11-30 14:02 ` Eli Zaretskii
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).