zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: Tweaking predict-on
@ 2000-03-09  9:45 Sven Wischnowsky
  0 siblings, 0 replies; 2+ messages in thread
From: Sven Wischnowsky @ 2000-03-09  9:45 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> ...
> 
> I'm wondering if it would be worthwhile for ZLE and completion widgets to
> be able to do some sort of FIONREAD test and react differently when there
> is typeahead ... it won't work everywhere, but ...

I've been dreaming about this, too, when I wrote i-c-w.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

* PATCH: Tweaking predict-on
@ 2000-03-04 19:32 Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2000-03-04 19:32 UTC (permalink / raw)
  To: zsh-workers

If you really want to pound on the completion system, enable predict-on for
a while.  Having completion attempted on every keystroke shows up all kinds
of things; in particular I've gotten the undo system into a very bad state
by cut'n'pasting a function definition during predict-on and then trying to
undo my way out of the resulting chaos.  Not reliably repeatable, though.

I'm wondering if it would be worthwhile for ZLE and completion widgets to
be able to do some sort of FIONREAD test and react differently when there
is typeahead ... it won't work everywhere, but ...

Of course that may go slightly less haywire after this patch, so if you're
interested in debugging "undo" you may want an older predict-on.

This patch changes:

* Remove "emulate -L zsh" for benefit of the completion system.

* Add test of whether we're inside a multi-line buffer, and don't attempt
  predictive typing in that case.

* Reformat a long line.

Index: Functions/Zle/predict-on
===================================================================
@@ -36,10 +36,15 @@
   zle -A .backward-delete-char backward-delete-char
 }
 insert-and-predict () {
-  emulate -L zsh
-  if [[ ${RBUFFER[1]} = ${KEYS[-1]} ]]
+  setopt localoptions noshwordsplit noksharrays
+  if [[ $LBUFFER = *$'\012'* ]]
   then
-    # same as what's typed, just move on
+    # Editing a multiline buffer, it's unlikely prediction is wanted
+    zle .$WIDGET "$@"
+    return
+  elif [[ ${RBUFFER[1]} = ${KEYS[-1]} ]]
+  then
+    # Same as what's typed, just move on
     ((++CURSOR))
   else
     LBUFFER="$LBUFFER$KEYS"
@@ -92,12 +97,15 @@
   return 0
 }
 delete-backward-and-predict() {
-  emulate -L zsh
   if [[ -n "$LBUFFER" ]]
   then
+    setopt localoptions noshwordsplit noksharrays
+    if [[ $LBUFFER = *$'\012'* ]] then
+      # Editing a multiline buffer, it's unlikely prediction is wanted
+      zle .$WIDGET "$@"
     # If the last widget was e.g. a motion, then probably the intent is
     # to actually edit the line, not change the search prefix.
-    if [[ $LASTWIDGET == (self-insert|magic-space|backward-delete-char) ]]
+    elif [[ $LASTWIDGET == (self-insert|magic-space|backward-delete-char) ]]
     then
       ((--CURSOR))
       zle .history-beginning-search-forward || RBUFFER=""
@@ -118,7 +126,8 @@
 
 predict-limit-list() {
   if (( compstate[list_lines]+BUFFERLINES > LINES ||
-	( compstate[list_max] != 0 && compstate[nmatches] > compstate[list_max] ) ))
+	( compstate[list_max] != 0 &&
+	    compstate[nmatches] > compstate[list_max] ) ))
   then
     compstate[list]=''
     compstate[force_list]=yes

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

end of thread, other threads:[~2000-03-09  9:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-09  9:45 PATCH: Tweaking predict-on Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
2000-03-04 19:32 Bart Schaefer

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