zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: Re: Problem with 'predict-on'
Date: Wed, 24 Mar 2004 16:45:11 +0000	[thread overview]
Message-ID: <1040324164511.ZM15770@candle.brasslantern.com> (raw)
In-Reply-To: <hg5h9729cfc5$.dlg@thorstenkampe.de>

On Mar 24,  5:18am, Thorsten Kampe wrote:
} 
} I'm testing the ZLE widget "predict-on" with...

predict-on is probably due for an overhaul.  It was written for 3.1.x
(I've forgotten which value of 'x') and only updated once about a year
ago.

} autoload -U predict-on; predict-on

} This means that predict-on is active by default.

Actually a better way to accomplish this is

zle-line-init() { predict-on }
zle -N zle-line-init

Calling predict-on in .zshrc means it's on for the very first prompt,
but zle-line-init makes sure it's on at the beginning of every prompt.

Ideally, predict-on would give an error if it is called anywhere other
than in a widget, but the zle-line-init special widget didn't exist
when predict-on was created.

} But there are some flaws with predict-on:

Yes, several.  You'll also notice that it doesn't interact very well
with "undo".  (PWS or Wayne, if you're reading this, advice on how to
fix that would be appreciated.)

I've also just noticed a new problem with backspacing, one which I'm
quite sure has appeared quite recently ... I'm reporting that in another
message to zsh-workers right now.

} first of all I can not backspace the first
} character I typed in the command line.

Yes, that's true.  If there isn't at least one character, there's no
basis for predictive typing.  So the choices would be to delete the
entire line when the first character is deleted, or ... I'm not sure
what.  If "delete the entire line" seems like the right thing, try
this patch:

Index: predict-on
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-4.0/Functions/Zle/predict-on,v
retrieving revision 1.2
diff -c -r1.2 predict-on
--- predict-on	15 Mar 2003 17:43:15 -0000	1.2
+++ predict-on	24 Mar 2004 16:08:52 -0000
@@ -120,6 +120,8 @@
       zle .history-beginning-search-forward || RBUFFER=""
       return 0
     fi
+  else
+    zle .kill-whole-line
   fi
 }
 delete-no-predict() {

However, that may not be very helpful until the history-search bug gets
fixed.

} Then pasting text via
} [Shift]-[Ins] doesn't turn off prediction (like it should[1]).

This probably means that ((PENDING)) doesn't work correctly on your
system, or that the implemention of Shift+Ins is such that the pasted
text does not appear as typeahead.

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.

Unfortunately if insert-and-predict can't determine that there is more
than a single character being inserted, it doesn't know that a paste is
happening, and so doesn't turn itself off.


  reply	other threads:[~2004-03-24 16:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-24  4:18 Thorsten Kampe
2004-03-24 16:45 ` Bart Schaefer [this message]
2004-03-24 20:25   ` Thorsten Kampe
2004-03-25  3:17     ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1040324164511.ZM15770@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).