zsh-users
 help / color / mirror / code / Atom feed
* Cancel zle -M on a keypress, use cursor keys
@ 2016-01-18  9:47 Sebastian Gniazdowski
  2016-01-18 17:34 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Gniazdowski @ 2016-01-18  9:47 UTC (permalink / raw)
  To: Zsh Users

Hello,
I've written a Zle completion widget that edits BUFFER and proposes
matches via zle -M. I want to cancel the zle -M message when user does
anything different than browsing completions (done with Alt-h and
Alt-H). How to accomplish this? I guess I could somehow detect
self-insert, but it's quite invasive approach, and I already have "zle
-N self-insert url-quote-magic" in .zshrc.

I would also want to catch cursor keys and use them for browsing the
matches. How to do this, should I somehow use bindkey locally in the
widget?

Best regards,
Sebastian Gniazdowski


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

* Re: Cancel zle -M on a keypress, use cursor keys
  2016-01-18  9:47 Cancel zle -M on a keypress, use cursor keys Sebastian Gniazdowski
@ 2016-01-18 17:34 ` Bart Schaefer
  2016-01-20 10:27   ` Sebastian Gniazdowski
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2016-01-18 17:34 UTC (permalink / raw)
  To: Zsh Users

On Jan 18, 10:47am, Sebastian Gniazdowski wrote:
}
} I've written a Zle completion widget that edits BUFFER and proposes
} matches via zle -M. I want to cancel the zle -M message when user does
} anything different than browsing completions (done with Alt-h and
} Alt-H). How to accomplish this?
[...]
} I would also want to catch cursor keys and use them for browsing the
} matches. How to do this, should I somehow use bindkey locally in the

I think you want to invoke "zle recursive-edit" with its own private
keymap.  Refer to Functions/Zle/read-from-minibuffer for an example;
you may even be able to use read-from-minibuffer directly.

The other way is to use "read -k" in in a loop, for which the most
detailed (though now fairly old and probably improvable) example is
Functions/Zle/incremental-complete-word.


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

* Re: Cancel zle -M on a keypress, use cursor keys
  2016-01-18 17:34 ` Bart Schaefer
@ 2016-01-20 10:27   ` Sebastian Gniazdowski
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Gniazdowski @ 2016-01-20 10:27 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users

On 18 January 2016 at 18:34, Bart Schaefer <schaefer@brasslantern.com> wrote:
> I think you want to invoke "zle recursive-edit" with its own private
> keymap.

This was quite easy, this is nearly the whole code required (the rest
is first_call initialization):

+if (( first_call ));then
+    zle recursive-edit -K main
+    zle -M ""
+fi

It gives a special mode exited by e.g. enter key, what's signalized by
zle -M "". I had to use $first_call variable because LASTWIDGET is
left unchanged (and points to e.g. vi-backward-char) when
zew-history-complete-word is called for the second time, i.e. right
after zle recursive-edit.

> The other way is to use "read -k" in in a loop, for which the most
> detailed (though now fairly old and probably improvable) example is
> Functions/Zle/incremental-complete-word.

This might be better because now zle -M "...\n...\n..." gives blinks
(when holding "next entry" key).That's maybe connected to keyboard
usage, as I did a short test: called zew-history-complete-word 1000
times recursively, and zle -M "...\n...\n..." didn't blink then. read
-k might change how keys influences the display. Or maybe it's because
that currently the widget exits after each recognized keystroke, but
not sure how this could influence zle -M.

Best regards,
Sebastian Gniazdowski


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

end of thread, other threads:[~2016-01-20 10:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-18  9:47 Cancel zle -M on a keypress, use cursor keys Sebastian Gniazdowski
2016-01-18 17:34 ` Bart Schaefer
2016-01-20 10:27   ` 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).