unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#55889: 29.0.50; Support mksh-specific function names in imenu
@ 2022-06-10 14:36 Visuwesh
  2022-06-11 11:05 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Visuwesh @ 2022-06-10 14:36 UTC (permalink / raw)
  To: 55889

[-- Attachment #1: Type: text/plain, Size: 626 bytes --]

Tags: patch

mksh supports characters well beyond [:alnum:_] in its function names.
More specifically, syn.c:function_body says the following

	/*-
	 * Check for valid characters in name. POSIX and AT&T ksh93 say
	 * only allow [a-zA-Z_0-9] but this allows more as old pdkshs
	 * have allowed more; the following were never allowed:
	 *	NUL TAB NL SP " $ & ' ( ) ; < = > \ ` |
	 * C_QUOTE|C_SPC covers all but adds # * ? [ ]
	 */

However, it seems like executing a function with a forward-slash (/)
character in it is impossible as well.

Attached patch adds a mksh-specific entry to sh-imenu-generic-expression
to do that.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Support-mksh-specific-function-names-in-imenu.patch --]
[-- Type: text/x-diff, Size: 1609 bytes --]

From 53139e53b75aa37cc808c1c8b3e3be367ae09fb3 Mon Sep 17 00:00:00 2001
From: Visuwesh <visuweshm@gmail.com>
Date: Fri, 10 Jun 2022 20:01:03 +0530
Subject: [PATCH] Support mksh-specific function names in imenu

* lisp/progmodes/sh-script.el (sh-imenu-generic-expression): Add
mksh-specific function names to imenu-generic-expression.
---
 lisp/progmodes/sh-script.el | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 4d2554c087..844fb690a5 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -286,7 +286,7 @@ sh-shell-arg
   :group 'sh-script)
 
 (defcustom sh-imenu-generic-expression
-  '((sh
+  `((sh
      . ((nil
 	 ;; function FOO
 	 ;; function FOO()
@@ -295,8 +295,21 @@ sh-imenu-generic-expression
 	;; FOO()
 	(nil
 	 "^\\s-*\\([[:alpha:]_][[:alnum:]_]*\\)\\s-*()"
-	 1)
-	)))
+	 1)))
+    (mksh
+     . ((nil
+         ;; function FOO
+         ;; function FOO()
+         ,(rx bol (* (syntax whitespace)) "function" (+ (syntax whitespace))
+              (group (1+ (not (any "\0\t\n \"$&'();<=>\\`|#*?[]/"))))
+              (* (syntax whitespace)) (? "()"))
+         1)
+        (nil
+         ;; FOO()
+         ,(rx bol (* (syntax whitespace))
+              (group (1+ (not (any "\0\t\n \"$&'();<=>\\`|#*?[]/"))))
+             (* (syntax whitespace)) "()")
+         1))))
   "Alist of regular expressions for recognizing shell function definitions.
 See `sh-feature' and `imenu-generic-expression'."
   :type '(alist :key-type (symbol :tag "Shell")
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#55889: 29.0.50; Support mksh-specific function names in imenu
  2022-06-10 14:36 bug#55889: 29.0.50; Support mksh-specific function names in imenu Visuwesh
@ 2022-06-11 11:05 ` Lars Ingebrigtsen
  2022-06-11 15:46   ` Visuwesh
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-11 11:05 UTC (permalink / raw)
  To: Visuwesh; +Cc: 55889

Visuwesh <visuweshm@gmail.com> writes:

> Attached patch adds a mksh-specific entry to sh-imenu-generic-expression
> to do that.

Thanks; pushed to Emacs 29 (with an indentation fix).

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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#55889: 29.0.50; Support mksh-specific function names in imenu
  2022-06-11 11:05 ` Lars Ingebrigtsen
@ 2022-06-11 15:46   ` Visuwesh
  2022-06-11 16:13     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Visuwesh @ 2022-06-11 15:46 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 55889

[சனி ஜூன் 11, 2022] Lars Ingebrigtsen wrote:

> Visuwesh <visuweshm@gmail.com> writes:
>
>> Attached patch adds a mksh-specific entry to sh-imenu-generic-expression
>> to do that.
>
> Thanks; pushed to Emacs 29 (with an indentation fix).

I forgot to bump :version as well, oops.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#55889: 29.0.50; Support mksh-specific function names in imenu
  2022-06-11 15:46   ` Visuwesh
@ 2022-06-11 16:13     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-11 16:13 UTC (permalink / raw)
  To: Visuwesh; +Cc: 55889

Visuwesh <visuweshm@gmail.com> writes:

>> Thanks; pushed to Emacs 29 (with an indentation fix).
>
> I forgot to bump :version as well, oops.

No prob; now done.

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





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-06-11 16:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-10 14:36 bug#55889: 29.0.50; Support mksh-specific function names in imenu Visuwesh
2022-06-11 11:05 ` Lars Ingebrigtsen
2022-06-11 15:46   ` Visuwesh
2022-06-11 16:13     ` Lars Ingebrigtsen

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).