zsh-workers
 help / color / mirror / code / Atom feed
* Re: [Feature Request] Re: Can one detect that Zsh/Zle is in recursive-edit?
       [not found]   ` <CAKc7PVBsSGqW1m5hKTPYDFTmi+=EqvWAJExCWzBkHW8OjHO_zQ@mail.gmail.com>
@ 2018-08-14 17:06     ` Peter Stephenson
  2018-08-14 17:30       ` Bart Schaefer
  2018-08-14 17:44       ` Sebastian Gniazdowski
  0 siblings, 2 replies; 3+ messages in thread
From: Peter Stephenson @ 2018-08-14 17:06 UTC (permalink / raw)
  To: Zsh hackers' list

On Tue, 14 Aug 2018 18:17:36 +0200
Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
> If there currently is no method of detecting .recursive-edit
> "session", then could a feature request be responded positively:
> please add an indicator that Zsh is in .recursive-edit state
> ("session").

It's certainly easy to do (although probably not hard to add at
the user level as calls to recursive-edit ought to be explicit).

diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index b72606c..6ae4863 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 7ec8afe..db70e7d 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 20735e6..9f4fb5a 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;


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

* Re: [Feature Request] Re: Can one detect that Zsh/Zle is in recursive-edit?
  2018-08-14 17:06     ` [Feature Request] Re: Can one detect that Zsh/Zle is in recursive-edit? Peter Stephenson
@ 2018-08-14 17:30       ` Bart Schaefer
  2018-08-14 17:44       ` Sebastian Gniazdowski
  1 sibling, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2018-08-14 17:30 UTC (permalink / raw)
  To: Zsh hackers' list

On Tue, Aug 14, 2018 at 10:06 AM, Peter Stephenson
<p.stephenson@samsung.com> wrote:
> On Tue, 14 Aug 2018 18:17:36 +0200
> Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
>> If there currently is no method of detecting .recursive-edit
>> "session", then could a feature request be responded positively:
>> please add an indicator that Zsh is in .recursive-edit state
>> ("session").
>
> It's certainly easy to do (although probably not hard to add at
> the user level as calls to recursive-edit ought to be explicit).

I was looking at this for a few minutes the other day and wondering if
there should be a hook similar to zle-keymap-select that gets invoked
on entry to recursive-edit.

It could even BE zle-keymap-select if recursive-edit had its own
keymap (always initialized as a copy of the current keymap at time of
entry).


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

* Re: [Feature Request] Re: Can one detect that Zsh/Zle is in recursive-edit?
  2018-08-14 17:06     ` [Feature Request] Re: Can one detect that Zsh/Zle is in recursive-edit? Peter Stephenson
  2018-08-14 17:30       ` Bart Schaefer
@ 2018-08-14 17:44       ` Sebastian Gniazdowski
  1 sibling, 0 replies; 3+ messages in thread
From: Sebastian Gniazdowski @ 2018-08-14 17:44 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh hackers list

On Tue, 14 Aug 2018 at 19:14, Peter Stephenson <p.stephenson@samsung.com> wrote:
>
> On Tue, 14 Aug 2018 18:17:36 +0200
> Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
> > If there currently is no method of detecting .recursive-edit
> > "session", then could a feature request be responded positively:
> > please add an indicator that Zsh is in .recursive-edit state
> > ("session").
>
> It's certainly easy to do (although probably not hard to add at
> the user level as calls to recursive-edit ought to be explicit).

Cool, thanks. In effect, when new release will be made, I'll send
patches to zsh-autosuggestions and zsh-syntax-highlighting that will
suppress those plugins on ZLE_RECURSIVE > 0 (which often means some
"application" has started a "session" and doesn't want to be
interfered).

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin


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

end of thread, other threads:[~2018-08-14 17:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAKc7PVC_i6fvhLSoWqFdNa0egtXj+Sfoou0FUQmjU+TXexyOFA@mail.gmail.com>
     [not found] ` <CGME20180814161906epcas3p37378a9a3eb58ea9a526c3b9fadd91531@epcas3p3.samsung.com>
     [not found]   ` <CAKc7PVBsSGqW1m5hKTPYDFTmi+=EqvWAJExCWzBkHW8OjHO_zQ@mail.gmail.com>
2018-08-14 17:06     ` [Feature Request] Re: Can one detect that Zsh/Zle is in recursive-edit? Peter Stephenson
2018-08-14 17:30       ` Bart Schaefer
2018-08-14 17:44       ` Sebastian Gniazdowski

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).