zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Include number of chars in zle unget mechanism in $PENDING calculation
@ 2017-03-01  1:25 Eric Freese
  2017-03-01  2:52 ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Freese @ 2017-03-01  1:25 UTC (permalink / raw)
  To: zsh-workers; +Cc: Eric Freese

Tested locally with the following:

  % self-insert() { echo "$PENDING" >> log; zle .self-insert -- $@ }
  % zle -N self-insert
  % foo() { zle -U "hello"; zle -U "world" }
  % zle -N foo
  % bindkey ^B foo

After pressing C-b, the buffer reads:

  worldhello

And the contents of log are:

  9
  8
  7
  6
  5
  4
  3
  2
  1
  0
---
 Src/Zle/zle_params.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index 1e4c5b8..476e9a7 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -512,7 +512,7 @@ get_bufferlines(UNUSED(Param pm))
 static zlong
 get_pending(UNUSED(Param pm))
 {
-    return noquery(0);
+    return kungetct + noquery(0);
 }
 
 /**/
-- 
2.9.0


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

* Re: [PATCH] Include number of chars in zle unget mechanism in $PENDING calculation
  2017-03-01  1:25 [PATCH] Include number of chars in zle unget mechanism in $PENDING calculation Eric Freese
@ 2017-03-01  2:52 ` Bart Schaefer
  2017-03-01  3:51   ` Eric Freese
  2017-03-01 14:41   ` Eric Freese
  0 siblings, 2 replies; 7+ messages in thread
From: Bart Schaefer @ 2017-03-01  2:52 UTC (permalink / raw)
  To: Eric Freese, zsh-workers

Yeah, this was discussed (with identical patch) back in May 2016 in
workers/38522.  It turned out not to have the desired effect so we
didn't do anything with it.

The question is whether it's useful to be able to tell that TTY read
will not block, separately from whether ZLE has available input.
There are cases where one might be invoking a tty read in the middle
of a widget, before any of the "zle -U" pushback would be consumed.

We'd also have to change the doc that says "where the shell is not able
to get this information, this parameter will always have a value of zero."


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

* Re: [PATCH] Include number of chars in zle unget mechanism in $PENDING calculation
  2017-03-01  2:52 ` Bart Schaefer
@ 2017-03-01  3:51   ` Eric Freese
  2017-03-02 14:31     ` Peter Stephenson
  2017-03-01 14:41   ` Eric Freese
  1 sibling, 1 reply; 7+ messages in thread
From: Eric Freese @ 2017-03-01  3:51 UTC (permalink / raw)
  To: Bart Schaefer, zsh-workers

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

Ok. How about a separate parameter that just returns kungetct?

My use case is disabling zsh-autosuggestions (https://github.com/zsh-
users/zsh-autosuggestions) while bracketed-paste-magic and other
widgets using zle -U are running. Ideally, I could just avoid fetching
a suggestion until $PENDING and this new param are zero.



On Tue, Feb 28, 2017 at 7:52 PM Bart Schaefer <schaefer@brasslantern.com>
wrote:
>
> Yeah, this was discussed (with identical patch) back in May 2016 in
> workers/38522.  It turned out not to have the desired effect so we
> didn't do anything with it.
>
> The question is whether it's useful to be able to tell that TTY read
> will not block, separately from whether ZLE has available input.
> There are cases where one might be invoking a tty read in the middle
> of a widget, before any of the "zle -U" pushback would be consumed.
>
> We'd also have to change the doc that says "where the shell is not able
> to get this information, this parameter will always have a value of zero."

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

* [PATCH] Include number of chars in zle unget mechanism in $PENDING calculation
  2017-03-01  2:52 ` Bart Schaefer
  2017-03-01  3:51   ` Eric Freese
@ 2017-03-01 14:41   ` Eric Freese
  1 sibling, 0 replies; 7+ messages in thread
From: Eric Freese @ 2017-03-01 14:41 UTC (permalink / raw)
  To: Bart Schaefer, zsh-workers

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

Ok. How about a separate parameter that just returns kungetct?

My use case is disabling zsh-autosuggestions (https://github.com/zsh-
users/zsh-autosuggestions)
while bracketed-paste-magic and other
widgets using zle -U are running. Ideally, I could just avoid fetching
a suggestion until $PENDING and this new param are zero.

On Tue, Feb 28, 2017 at 7:52 PM Bart Schaefer <schaefer@brasslantern.com>
wrote:

> Yeah, this was discussed (with identical patch) back in May 2016 in
> workers/38522.  It turned out not to have the desired effect so we
> didn't do anything with it.
>
> The question is whether it's useful to be able to tell that TTY read
> will not block, separately from whether ZLE has available input.
> There are cases where one might be invoking a tty read in the middle
> of a widget, before any of the "zle -U" pushback would be consumed.
>
> We'd also have to change the doc that says "where the shell is not able
> to get this information, this parameter will always have a value of zero."
>


-- 
Sent from my iPhone

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

* Re: [PATCH] Include number of chars in zle unget mechanism in $PENDING calculation
  2017-03-01  3:51   ` Eric Freese
@ 2017-03-02 14:31     ` Peter Stephenson
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Stephenson @ 2017-03-02 14:31 UTC (permalink / raw)
  To: zsh-workers

On Tue, 28 Feb 2017 20:51:32 -0700
Eric Freese <ericdfreese@gmail.com> wrote:
> Ok. How about a separate parameter that just returns kungetct?

How about...

pws

diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index d68365b..b65e3be 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -864,6 +864,12 @@ vindex(KEYS)
 item(tt(KEYS) (scalar))(
 The keys typed to invoke this widget, as a literal string; read-only.
 )
+vindex(KEYS_QUEUED_COUNT)
+item(tt(KEYS_QUEUED_COUNT) (integer))(
+The number of bytes pushed back to the input queue and therefore
+available for reading immediately before any I/O is done; read-only.
+See also tt(PENDING); the two values are distinct.
+)
 vindex(killring)
 item(tt(killring) (array))(
 The array of previously killed items, with the most recently killed first.
@@ -919,7 +925,8 @@ item(tt(PENDING) (integer))(
 The number of bytes pending for input, i.e. the number of bytes which have
 already been typed and can immediately be read. On systems where the shell
 is not able to get this information, this parameter will always have a
-value of zero.  Read-only.
+value of zero.  Read-only.  See also tt(KEYS_QUEUED_COUNT); the two
+values are distinct.
 )
 vindex(PREBUFFER)
 item(tt(PREBUFFER) (scalar))(
diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index 1e4c5b8..0a922d2 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -85,6 +85,8 @@ static const struct gsu_integer cursor_gsu =
 { get_cursor, set_cursor, zleunsetfn };
 static const struct gsu_integer histno_gsu =
 { get_histno, set_histno, zleunsetfn };
+static const struct gsu_integer keys_queued_count_gsu =
+{ get_keys_queued_count, NULL, zleunsetfn };
 static const struct gsu_integer mark_gsu =
 { get_mark, set_mark, zleunsetfn };
 static const struct gsu_integer numeric_gsu =
@@ -146,6 +148,8 @@ static struct zleparam {
     { "HISTNO", PM_INTEGER, GSU(histno_gsu), NULL },
     { "KEYMAP", PM_SCALAR | PM_READONLY, GSU(keymap_gsu), NULL },
     { "KEYS", PM_SCALAR | PM_READONLY, GSU(keys_gsu), NULL },
+    { "KEYS_QUEUED_COUNT", PM_INTEGER | PM_READONLY, GSU(keys_queued_count_gsu),
+      NULL},
     { "killring", PM_ARRAY, GSU(killring_gsu), NULL },
     { "LASTABORTEDSEARCH", PM_SCALAR | PM_READONLY, GSU(lastabortedsearch_gsu),
       NULL },
@@ -458,6 +462,13 @@ get_keys(UNUSED(Param pm))
 }
 
 /**/
+static zlong
+get_keys_queued_count(UNUSED(Param pm))
+{
+    return kungetct;
+}
+
+/**/
 static void
 set_numeric(UNUSED(Param pm), zlong x)
 {


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

* Re: [PATCH] Include number of chars in zle unget mechanism in $PENDING calculation
  2017-03-03 23:54 Eric Freese
@ 2017-03-04 14:53 ` Daniel Shahaf
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Shahaf @ 2017-03-04 14:53 UTC (permalink / raw)
  To: Eric Freese; +Cc: zsh-workers

Eric Freese wrote on Fri, Mar 03, 2017 at 16:54:39 -0700:
> Would love to see this merged.

It was merged yesterday (67c5d83df33c).


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

* Re: [PATCH] Include number of chars in zle unget mechanism in $PENDING calculation
@ 2017-03-03 23:54 Eric Freese
  2017-03-04 14:53 ` Daniel Shahaf
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Freese @ 2017-03-03 23:54 UTC (permalink / raw)
  To: zsh-workers

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

This looks great! Pulled it down and it solves my problem.

Would love to see this merged.

> How about...
>
> pws
>
> diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
> index d68365b..b65e3be 100644
> --- a/Doc/Zsh/zle.yo
> +++ b/Doc/Zsh/zle.yo
> @@ -864,6 +864,12 @@ vindex(KEYS)
>  item(tt(KEYS) (scalar))(
>  The keys typed to invoke this widget, as a literal string; read-only.
>  )
> +vindex(KEYS_QUEUED_COUNT)
> +item(tt(KEYS_QUEUED_COUNT) (integer))(
> +The number of bytes pushed back to the input queue and therefore
> +available for reading immediately before any I/O is done; read-only.
> +See also tt(PENDING); the two values are distinct.
> +)
>  vindex(killring)
>  item(tt(killring) (array))(
>  The array of previously killed items, with the most recently killed
first.
> @@ -919,7 +925,8 @@ item(tt(PENDING) (integer))(
>  The number of bytes pending for input, i.e. the number of bytes which
have
>  already been typed and can immediately be read. On systems where the
shell
>  is not able to get this information, this parameter will always have a
> -value of zero.  Read-only.
> +value of zero.  Read-only.  See also tt(KEYS_QUEUED_COUNT); the two
> +values are distinct.
>  )
>  vindex(PREBUFFER)
>  item(tt(PREBUFFER) (scalar))(
> diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
> index 1e4c5b8..0a922d2 100644
> --- a/Src/Zle/zle_params.c
> +++ b/Src/Zle/zle_params.c
> @@ -85,6 +85,8 @@ static const struct gsu_integer cursor_gsu =
>  { get_cursor, set_cursor, zleunsetfn };
>  static const struct gsu_integer histno_gsu =
>  { get_histno, set_histno, zleunsetfn };
> +static const struct gsu_integer keys_queued_count_gsu =
> +{ get_keys_queued_count, NULL, zleunsetfn };
>  static const struct gsu_integer mark_gsu =
>  { get_mark, set_mark, zleunsetfn };
>  static const struct gsu_integer numeric_gsu =
> @@ -146,6 +148,8 @@ static struct zleparam {
>      { "HISTNO", PM_INTEGER, GSU(histno_gsu), NULL },
>      { "KEYMAP", PM_SCALAR | PM_READONLY, GSU(keymap_gsu), NULL },
>      { "KEYS", PM_SCALAR | PM_READONLY, GSU(keys_gsu), NULL },
> +    { "KEYS_QUEUED_COUNT", PM_INTEGER | PM_READONLY,
GSU(keys_queued_count_gsu),
> +      NULL},
>      { "killring", PM_ARRAY, GSU(killring_gsu), NULL },
>      { "LASTABORTEDSEARCH", PM_SCALAR | PM_READONLY,
GSU(lastabortedsearch_gsu),
>        NULL },
> @@ -458,6 +462,13 @@ get_keys(UNUSED(Param pm))
>  }
>
>  /**/
> +static zlong
> +get_keys_queued_count(UNUSED(Param pm))
> +{
> +    return kungetct;
> +}
> +
> +/**/
>  static void
>  set_numeric(UNUSED(Param pm), zlong x)
>  {

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

end of thread, other threads:[~2017-03-04 14:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-01  1:25 [PATCH] Include number of chars in zle unget mechanism in $PENDING calculation Eric Freese
2017-03-01  2:52 ` Bart Schaefer
2017-03-01  3:51   ` Eric Freese
2017-03-02 14:31     ` Peter Stephenson
2017-03-01 14:41   ` Eric Freese
2017-03-03 23:54 Eric Freese
2017-03-04 14:53 ` Daniel Shahaf

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