about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@pws-HP.localdomain>2018-08-16 19:23:13 +0100
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2018-08-17 19:43:17 +0100
commit3c93497eb701d8f220bc32d38e1f12bfb534c390 (patch)
tree5f2418a61f77fa7f28f86441572590ec96aa8222
parent9567bfe061679ebdddd371bb829c004fe6e58588 (diff)
downloadzsh-3c93497eb701d8f220bc32d38e1f12bfb534c390.tar.gz
zsh-3c93497eb701d8f220bc32d38e1f12bfb534c390.tar.xz
zsh-3c93497eb701d8f220bc32d38e1f12bfb534c390.zip
43294: Add ZLE_RECURSIVE parameter.
-rw-r--r--ChangeLog5
-rw-r--r--Doc/Zsh/zle.yo7
-rw-r--r--Src/Zle/zle_main.c9
-rw-r--r--Src/Zle/zle_params.c10
4 files changed, 31 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 1565ea370..390324fe6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-08-16  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* 43294: Doc/Zsh/zle.yo, Src/Zle/zle_main.c,
+	Src/Zle/zle_params.c: Add ZLE_RECURSIVE parameter.
+
 2018-08-15  dana  <dana@dana.is>
 
 	* 43302: Completion/Unix/Command/_du: Change -B to -B+
diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index b72606c0b..6ae4863c6 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -1085,6 +1085,13 @@ wrappers of tt(bracketed-paste).  See also tt(zle -f).
 
 tt(YANK_ACTIVE) is read-only.
 )
+vindex(ZLE_RECURSIVE)
+item(tt(ZLE_RECURSIVE) (integer))(
+Usually zero, but incremented inside any instance of
+tt(recursive-edit).  Hence indicates the current recursion level.
+
+tt(ZLE_RECURSIVE) is read-only.
+)
 vindex(ZLE_STATE)
 item(tt(ZLE_STATE) (scalar))(
 Contains a set of space-separated words that describe the current tt(zle)
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 7ec8afeb6..db70e7d7e 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -58,6 +58,11 @@ mod_export int incompctlfunc;
 /**/
 mod_export int hascompmod;
 
+/* Increment for each nested recursive-edit */
+
+/**/
+mod_export int zle_recursive;
+
 /* ZLRF_* flags passed to zleread() */
 
 /**/
@@ -1941,6 +1946,8 @@ recursiveedit(UNUSED(char **args))
     int locerror;
     int q = queue_signal_level();
 
+    ++zle_recursive;
+
     /* zlecore() expects to be entered with signal queue disabled */
     dont_queue_signals();
 
@@ -1950,6 +1957,8 @@ recursiveedit(UNUSED(char **args))
 
     restore_queue_signals(q);
 
+    --zle_recursive;
+
     locerror = errflag ? 1 : 0;
     errflag = done = eofsent = 0;
 
diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index 20735e619..9f4fb5ac2 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -93,6 +93,8 @@ static const struct gsu_integer numeric_gsu =
 { get_numeric, set_numeric, unset_numeric };
 static const struct gsu_integer pending_gsu =
 { get_pending, NULL, zleunsetfn };
+static const struct gsu_integer recursive_gsu =
+{ get_recursive, NULL, zleunsetfn };
 static const struct gsu_integer region_active_gsu =
 { get_region_active, set_region_active, zleunsetfn };
 static const struct gsu_integer undo_change_no_gsu =
@@ -180,6 +182,7 @@ static struct zleparam {
     { "SUFFIX_START", PM_INTEGER, GSU(suffixstart_gsu), NULL },
     { "SUFFIX_END", PM_INTEGER, GSU(suffixend_gsu), NULL },
     { "SUFFIX_ACTIVE", PM_INTEGER | PM_READONLY, GSU(suffixactive_gsu), NULL },
+    { "ZLE_RECURSIVE", PM_INTEGER | PM_READONLY, GSU(recursive_gsu), NULL },
     { "ZLE_STATE", PM_SCALAR | PM_READONLY, GSU(zle_state_gsu), NULL },
     { NULL, 0, NULL, NULL }
 };
@@ -528,6 +531,13 @@ get_pending(UNUSED(Param pm))
 
 /**/
 static zlong
+get_recursive(UNUSED(Param pm))
+{
+    return zle_recursive;
+}
+
+/**/
+static zlong
 get_yankstart(UNUSED(Param pm))
 {
     return yankb;