diff options
author | Bart Schaefer <barts@users.sourceforge.net> | 2000-09-04 21:10:29 +0000 |
---|---|---|
committer | Bart Schaefer <barts@users.sourceforge.net> | 2000-09-04 21:10:29 +0000 |
commit | dc1f7c5a3429321b10c6e05c11d99c94ff5c3e87 (patch) | |
tree | 904366741d50f3a05e55ecf909aaf41f14c1380f /Functions/Zle | |
parent | 88b886e6034b1902c929eb6e6e2a06b9f4854c03 (diff) | |
download | zsh-dc1f7c5a3429321b10c6e05c11d99c94ff5c3e87.tar.gz zsh-dc1f7c5a3429321b10c6e05c11d99c94ff5c3e87.tar.xz zsh-dc1f7c5a3429321b10c6e05c11d99c94ff5c3e87.zip |
Create "User Contributions" doc and make some assoctiated changes.
Diffstat (limited to 'Functions/Zle')
-rw-r--r-- | Functions/Zle/history-search-end | 11 | ||||
-rw-r--r-- | Functions/Zle/predict-on | 41 |
2 files changed, 29 insertions, 23 deletions
diff --git a/Functions/Zle/history-search-end b/Functions/Zle/history-search-end index 24e7a0a87..fd58bb5f8 100644 --- a/Functions/Zle/history-search-end +++ b/Functions/Zle/history-search-end @@ -8,13 +8,13 @@ # bindkey '...' history-beginning-search-backward-end # bindkey '...' history-beginning-search-forward-end -integer ocursor=$CURSOR +integer cursor=$CURSOR mark=$MARK if [[ $LASTWIDGET = history-beginning-search-*-end ]]; then - # Last widget called set $hbs_pos. - CURSOR=$hbs_pos + # Last widget called set $MARK. + CURSOR=$MARK else - hbs_pos=$CURSOR + MARK=$CURSOR fi if zle .${WIDGET%-end}; then @@ -22,7 +22,8 @@ if zle .${WIDGET%-end}; then zle .end-of-line else # failure, restore position - CURSOR=$ocursor + CURSOR=$cursor + MARK=$mark return 1 fi # } diff --git a/Functions/Zle/predict-on b/Functions/Zle/predict-on index bd7212050..1ce368bfa 100644 --- a/Functions/Zle/predict-on +++ b/Functions/Zle/predict-on @@ -29,20 +29,27 @@ predict-on() { zle -N magic-space insert-and-predict zle -N backward-delete-char delete-backward-and-predict zle -N delete-char-or-list delete-no-predict + zstyle -t :predict verbose && zle -M predict-on + return 0 } predict-off() { zle -A .self-insert self-insert zle -A .magic-space magic-space zle -A .backward-delete-char backward-delete-char + zstyle -t :predict verbose && zle -M predict-off + return 0 } insert-and-predict () { setopt localoptions noshwordsplit noksharrays - if [[ $LBUFFER = *$'\012'* ]] + + if [[ $LBUFFER == *$'\012'* ]] || (( PENDING )) then - # Editing a multiline buffer, it's unlikely prediction is wanted + # Editing a multiline buffer or pasting in a chunk of text; + # it's unlikely prediction is wanted + zstyle -t ":predict" toggle && predict-off zle .$WIDGET "$@" return - elif [[ ${RBUFFER[1]} = ${KEYS[-1]} ]] + elif [[ ${RBUFFER[1]} == ${KEYS[-1]} ]] then # Same as what's typed, just move on ((++CURSOR)) @@ -58,10 +65,7 @@ insert-and-predict () { unsetopt automenu recexact integer curs=$CURSOR pos nchar=${#LBUFFER//[^${KEYS[-1]}]} local -a +h comppostfuncs - local crs curcontext="${curcontext}" - - [[ -z "$curcontext" ]] && curcontext=::: - curcontext="predict:${curcontext#*:}" + local crs curcontext="predict:${${curcontext:-:::}#*:}" comppostfuncs=( predict-limit-list ) zle complete-word @@ -69,7 +73,7 @@ insert-and-predict () { # get out of that `case'. repeat 1 do - zstyle -s ":completion:${curcontext}:" cursor crs + zstyle -s ":predict" cursor crs case $crs in (complete) # At the place where the completion left it, if it is after @@ -92,27 +96,28 @@ insert-and-predict () { done fi fi + else + zstyle -t ":predict" toggle && predict-off fi fi return 0 } delete-backward-and-predict() { - if [[ -n "$LBUFFER" ]] + if (( $#LBUFFER > 1 )) 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 + # When editing a multiline buffer, it's unlikely prediction is wanted; + # or if the last widget was e.g. a motion, then probably the intent is # to actually edit the line, not change the search prefix. - elif [[ $LASTWIDGET == (self-insert|magic-space|backward-delete-char) ]] + if [[ $LBUFFER = *$'\012'* || + $LASTWIDGET != (self-insert|magic-space|backward-delete-char) ]] then + zstyle -t ":predict" toggle && predict-off + LBUFFER="$LBUFFER[1,-2]" + else ((--CURSOR)) zle .history-beginning-search-forward || RBUFFER="" return 0 - else - # Depending on preference, you might call "predict-off" here. - LBUFFER="$LBUFFER[1,-2]" fi fi } @@ -130,7 +135,7 @@ predict-limit-list() { compstate[nmatches] > compstate[list_max] ) )) then compstate[list]='' - elif zstyle -t ":completion:predict::::" list always + elif zstyle -t ":predict" list always then compstate[list]='force list' fi |