about summary refs log tree commit diff
path: root/Functions
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2000-09-04 21:10:29 +0000
committerBart Schaefer <barts@users.sourceforge.net>2000-09-04 21:10:29 +0000
commitdc1f7c5a3429321b10c6e05c11d99c94ff5c3e87 (patch)
tree904366741d50f3a05e55ecf909aaf41f14c1380f /Functions
parent88b886e6034b1902c929eb6e6e2a06b9f4854c03 (diff)
downloadzsh-dc1f7c5a3429321b10c6e05c11d99c94ff5c3e87.tar.gz
zsh-dc1f7c5a3429321b10c6e05c11d99c94ff5c3e87.tar.xz
zsh-dc1f7c5a3429321b10c6e05c11d99c94ff5c3e87.zip
Create "User Contributions" doc and make some assoctiated changes.
Diffstat (limited to 'Functions')
-rw-r--r--Functions/Prompts/promptinit5
-rw-r--r--Functions/Zle/history-search-end11
-rw-r--r--Functions/Zle/predict-on41
3 files changed, 32 insertions, 25 deletions
diff --git a/Functions/Prompts/promptinit b/Functions/Prompts/promptinit
index a07650500..4ccdcf55b 100644
--- a/Functions/Prompts/promptinit
+++ b/Functions/Prompts/promptinit
@@ -76,7 +76,7 @@ Options:
 
 Use prompt -h <theme> for help on specific themes.'
 
-  getopts "chlps" opt
+  getopts "chlps:" opt
   case "$opt" in
     (h|p)
       setopt localtraps
@@ -136,7 +136,8 @@ Use prompt -h <theme> for help on specific themes.'
        print "  autoload -U promptinit"
        print "  promptinit"
        print "  prompt $*[2,-1]"
-       ;;
+       shift
+       ;&
     *) if [[ "$1" == 'random' ]]; then
          local random_themes
          if (( $#* == 1 )); then
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