Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: predict-on: suppress long listings



On Oct 27,  4:03pm, Sven Wischnowsky wrote:
} Subject: Re: PATCH: predict-on: suppress long listings
}
} The last key, `predict_list', is probably not needed, but with the
} usual behavior of showing a list below the command line, I find it
} somewhat irritating when it suddenly stops doing so only because we
} have reached the state where only one match is left.

Actually, to prevent the "do you wish" prompt we should check list_max
as well.  And here's the automenu change.

Index: Functions/Zle/predict-on
===================================================================
@@ -31,20 +31,11 @@
   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
-
-  # Prediction doesn't work well with automenu set, so we unset it here
-  # and restore it in predict-off().
-  if [[ -o automenu ]]; then
-    unsetopt automenu
-    _predict_am=yes
-  fi
 }
 predict-off() {
   zle -A .self-insert self-insert
   zle -A .magic-space magic-space
   zle -A .backward-delete-char backward-delete-char
-
-  [[ -n $_predict_am ]] && setopt automenu
 }
 insert-and-predict () {
   emulate -L zsh
@@ -61,6 +52,7 @@
 	RBUFFER=""
 	if [[ ${KEYS[-1]} != ' ' ]]
 	then
+	  unsetopt automenu
 	  integer curs=$CURSOR pos nchar=${#LBUFFER//[^${KEYS[-1]}]}
 	  local -a +h comppostfuncs
 	  comppostfuncs=( predict-limit-list )
@@ -120,11 +112,14 @@
 # of matches from forcing a "do you wish to see all ...?" prompt.
 
 predict-limit-list() {
-  if [[ compstate[list_lines]+BUFFERLINES -gt LINES ]]; then
+  if (( compstate[list_lines]+BUFFERLINES > LINES ||
+	compstate[nmatches] > compstate[list_max] ))
+  then
     compstate[list]=''
     compstate[force_list]=yes
+  elif [[ $compconfig[predict_list] = always ]]
+    compstate[force_list]=yes
   fi
-  [[ $compconfig[predict_list] = always ]] && compstate[force_list]=yes
 }
 
 # Handle zsh autoloading conventions

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



Messages sorted by: Reverse Date, Date, Thread, Author