about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--Doc/Zsh/zle.yo16
-rw-r--r--Src/Zle/iwidgets.list1
-rw-r--r--Src/Zle/zle_keymap.c13
4 files changed, 37 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index d3080ca32..29757e57e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-04-24  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* zsh-users/10172: Doc/Zsh/zle.yo, Src/Zle/iwidgets.list,
+	Src/Zle/zle_keymap.c: read-command reads a key sequence as
+	in normal zle operation but sets REPLY to the result instead
+	of executing it.
+
 2006-04-23  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* unposted: Functions/Misc/zmathfuncdef: improve recognition
diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index 937f70942..d6c8c773f 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -103,6 +103,12 @@ This input can itself invoke further replacement strings, but in order to
 detect loops the process will be stopped if there are twenty such replacements
 without a real command being read.
 
+A key sequence typed by the user can be turned into a command name for use
+in user-defined widgets with the tt(read-command) widget, described
+ifzman(below)\
+ifnzman(in noderef(Miscellaneous) below)\
+.
+
 texinode(Zle Builtins)(Zle Widgets)(Keymaps)(Zsh Line Editor)
 sect(Zle Builtins)
 cindex(zle, builtin commands)
@@ -1767,6 +1773,16 @@ At a secondary (tt(PS2)) prompt, move the entire current multiline
 construct into the editor buffer.
 The latter is equivalent to tt(push-input) followed by tt(get-line).
 )
+tindex(read-command)
+item(tt(read-command))(
+Only useful from a user-defined widget.  A keystroke is read just as in
+normal operation, but instead of the command being executed the name
+of the command that would be executed is stored in the shell parameter
+tt(REPLY).  This can be used as the argument of a future tt(zle)
+command.  If the key sequence is not bound, status 1 is returned;
+typically, however, tt(REPLY) is set to tt(undefined-key) to indicate
+a useless key sequence.
+)
 tindex(recursive-edit)
 item(tt(recursive-edit))(
 Only useful from a user-defined widget.  At this point in the function,
diff --git a/Src/Zle/iwidgets.list b/Src/Zle/iwidgets.list
index cc9ef20f9..5be5a474f 100644
--- a/Src/Zle/iwidgets.list
+++ b/Src/Zle/iwidgets.list
@@ -86,6 +86,7 @@
 "quoted-insert", quotedinsert, ZLE_MENUCMP | ZLE_KEEPSUFFIX
 "quote-line", quoteline, 0
 "quote-region", quoteregion, 0
+"read-command", readcommand, 0
 "recursive-edit", recursiveedit, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
 "redisplay", redisplay, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
 "redo", redo, ZLE_KEEPSUFFIX
diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c
index 7b1f9e1ad..1d5e6ed2d 100644
--- a/Src/Zle/zle_keymap.c
+++ b/Src/Zle/zle_keymap.c
@@ -1441,3 +1441,16 @@ zlesetkeymap(int mode)
 	return;
     linkkeymap(km, "main", 0);
 }
+
+/**/
+mod_export int
+readcommand(UNUSED(char **args))
+{
+    Thingy thingy = getkeycmd();
+
+    if (!thingy)
+	return 1;
+
+    setsparam("REPLY", ztrdup(thingy->nam));
+    return 0;
+}