* PATCH: compinstall
@ 2000-05-15 11:56 Peter Stephenson
0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2000-05-15 11:56 UTC (permalink / raw)
To: Zsh hackers list
This modifies compinstall to support the long and long-list keywords for
menu selection. I have also moved configuration of scrolling in lists to
the more logical position of just after menu selction.
Index: Completion/Core/compinstall
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/compinstall,v
retrieving revision 1.12
diff -u -r1.12 compinstall
--- Completion/Core/compinstall 2000/05/10 08:46:46 1.12
+++ Completion/Core/compinstall 2000/05/15 11:54:13
@@ -1053,9 +1053,7 @@
3. Make completion verbose, using option descriptions etc. (on by default).
-4. Allow scrolling of long completion lists and set the prompt.
-
-5. Make single-valued options display the value's description as
+4. Make single-valued options display the value's description as
part of the option's description.
q. Return without saving.
@@ -1126,25 +1124,6 @@
esac
;;
4) print "\
-You can make completion lists scroll when they don't fit on the screen.
-To do this, edit a prompt to show when scrolling is active; an empty string
-turns this feature off. It can contain \`%l' to show the number of matches
-as \`current_number/total_number', \`%p' to show the fraction of the way
-down the list, or font-control sequences such as %B, %U, %S and the
-corresponding %b, %u, %s; quotes will be added automatically. Note that
-this is the default behaviour; delete the whole line to turn it off, in
-which case the display of completions which don't fit on the screen is
-controlled by the LISTMAX parameter (currently ${LISTMAX:-unset}), which
-specifies the maximum number to show without asking. Hit return to keep
-the current value.
-"
- [[ -z $haslistp ]] &&
- listp='%SAt %p: Hit TAB for more, or the character to insert%s'
- vared -eh -p 'prompt> ' -c listp
- # Unconditionally use listp; will become '' if empty.
- haslistp=1
- ;;
- 5) print "\
Many commands have options which take a single argument. In some cases,
completion is not set up to describe the option even though it has a
description for the argument. You can enter a string containing \`%d',
@@ -1172,8 +1151,6 @@
__ci_set_this_style format format
__ci_set_this_style group-name groupn
__ci_set_this_style verbose verbose
- [[ -n $haslistp ]] && listp=${(qq)listp}
- __ci_set_this_style list-prompt listp
[[ -n $autod ]] && autod=${(qq)autod}
__ci_set_this_style auto-description autod
}
@@ -1267,6 +1244,9 @@
__ci_get_this_style list-colors listc
__ci_get_this_style menu menu
+ __ci_get_this_style list-prompt listp
+ [[ -n $listp ]] && haslistp=1
+ listp=${(Q)listp}
while true; do
clear
@@ -1277,6 +1257,8 @@
2. Use cursor keys to select completions from completion lists.
+3. Allow scrolling of long selection lists and set the prompt.
+
q. Return without saving.
0. Done setting options for insertion.
"
@@ -1325,13 +1307,17 @@
- 0 or 1, to turn this feature on unconditionally
- a higher number to turn this feature on when there are that many
completions
+- an \`l' for \`long' to turn it on for completions which don't fit on the
+ screen
+- an \`ll' for \`long list' to turn it on for completions which don't fit
+ on the screen, even for commands which only do listing of completions.
- a negative number to turn this feature off
- an empty line to leave the setting the way it is.
"
while true; do
vared -eh -p 'value> ' select
- [[ -z $select || $select = (-|)<-> ]] && break;
- print "Type a number or an empty line." >&2
+ [[ -z $select || $select = ((-|)<->|l#) ]] && break;
+ print "Type a number, l, ll, or an empty line." >&2
done
amenu=(${=menu})
elt=${amenu[(i)*select*]}
@@ -1344,6 +1330,18 @@
fi
menu="$amenu"
;;
+ l#) if [[ $select = l ]]; then
+ select=long
+ else
+ select=long-list
+ fi
+ if [[ -n $elt ]]; then
+ amenu[$elt]="select=$select"
+ else
+ amenu=($amenu "select=$select")
+ fi
+ menu="$amenu"
+ ;;
-<->) if [[ -n $elt ]]; then
# i never liked the way indexing was done anyway
if [[ $elt -eq 1 ]]; then
@@ -1356,6 +1354,28 @@
;;
esac
;;
+ 3) print "\
+You can make completion lists scroll when they don't fit on the screen.
+Note this is different from scrolling in menu selection --- a more basic
+pager is used which should work even with fairly stupid terminals.
+
+To enable this, edit a prompt to show when scrolling is active; an empty
+string turns this feature off. It can contain \`%l' to show the number of
+matches as \`current_number/total_number', \`%p' to show the fraction of
+the way down the list, or font-control sequences such as %B, %U, %S and the
+corresponding %b, %u, %s; quotes will be added automatically. Note that
+this is the default behaviour; delete the whole line to turn it off, in
+which case the display of completions which don't fit on the screen is
+controlled by the LISTMAX parameter (currently ${LISTMAX:-unset}), which
+specifies the maximum number to show without asking. Hit return to keep
+the current value.
+"
+ [[ -z $haslistp ]] &&
+ listp='%SAt %p: Hit TAB for more, or the character to insert%s'
+ vared -eh -p 'prompt> ' -c listp
+ # Unconditionally use listp; will become '' if empty.
+ haslistp=1
+ ;;
q) return 1
;;
esac
@@ -1363,6 +1383,8 @@
__ci_set_this_style list-colors listc
__ci_set_this_style menu menu
+ [[ -n $haslistp ]] && listp=${(qq)listp}
+ __ci_set_this_style list-prompt listp
return 0
}
@@ -1385,7 +1407,8 @@
2. Change how completions are inserted: includes options for sorting,
and keeping the original or an unambiguous prefix with correction etc.
-3. Configure coloured/highlighted completion lists and selection of items.
+3. Configure coloured/highlighted completion lists, selection of items
+ and scrolling.
4. Change whether old-style \`compctl' completions will be used.
--
Peter Stephenson <pws@cambridgesiliconradio.com>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070
^ permalink raw reply [flat|nested] 2+ messages in thread
* PATCH: compinstall
@ 2000-04-27 20:40 Peter Stephenson
0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2000-04-27 20:40 UTC (permalink / raw)
To: Zsh hackers list
I've added some exciting and innovative features to compinstall. Well, all
right, I've added three things that were asked for by Andrej, but it's nice
to pretend.
- You can specify a list of completers with _oldlist. I picked five
completers it looked sensible to offer. Patch compinstall if you want
more.
- You can ask for partial-word terminators to be matchable in partial-word
matching
- If you don't have a setting for list-prompt, you get offered the default
prompt for editing and have to delete the line explicitly to turn it off:
this corresponds to its actual behaviour.
I haven't tried to make it turn off styles you've just removed. You have
to start up a new shell to do that.
Index: Completion/Core/compinstall
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/compinstall,v
retrieving revision 1.7
diff -u -r1.7 compinstall
--- Completion/Core/compinstall 2000/04/18 13:41:14 1.7
+++ Completion/Core/compinstall 2000/04/27 20:34:21
@@ -324,7 +324,7 @@
__ci_do_minor_completer_options() {
# Set the options for the minor completers.
- local key cond word olist omenu moriginal aspace
+ local key cond word olist omenu moriginal aspace tmparr
__ci_get_this_style condition cond
[[ -n $cond ]] && cond=${(Q)cond}
__ci_get_this_style word word
@@ -369,7 +369,7 @@
_list will usually compare the contents of the entire line with its previous
contents to decided if it has been changed since the last keypress. You
can instead perform this comparison on just the current word, ignoring
-the rest of the command line. Do you want to do this? (y/n) [n] ? "
+the rest of the command line. Do you want to do this? (y/n) [n] "
word=
read -q key && word=true
print
@@ -379,11 +379,16 @@
way, e.g. with ^D, even if the list was generated by some special completion
command. The default behaviour of _oldlist is to show this list if it was
not already visible, otherwise to generate the standard completion listing,
-but you can force it always to be shown, or make it never shown. Choose:
+but you can force it always to be shown, or make it never shown.
+Alternatively, you can specify a list of completers for which _oldlist will
+be used. Choose:
d. Default behaviour.
a. Always show old list.
-n. Never show old list."
+n. Never show old list.
+s. Specify a list of completers.
+"
+
while true; do
read -k key'?--- Hit selection --- '
print
@@ -393,8 +398,41 @@
[aA]) olist=always
;;
[nN]) olist=never
+ ;;
+ [sS]) olist=
+ tmparr=(_complete _approximate _correct _match _expand)
+ while true; do
+ clear
+ print "\
+ *** compinstall: choosing completers to have _oldlist behaviour ***
+
+Type any of:
+
+1. _complete
+2. _approximate
+3. _correct
+4. _match
+5. _expand
+
+or 0 to end, or - to delete the last choice."
+ if [[ -n $olist ]]; then
+ print "\
+Current choices:
+ $olist"
+ fi
+ read -k key'?--- Hit selection --- '
+ print
+ case $key in
+ 0) break
+ ;;
+ -) olist=(${olist[1,-2]})
+ ;;
+ [1-5]) olist=($olist $tmparr[$key])
+ ;;
+ esac
+ done
;;
- *) print "Type one of d, a or n."
+ *) print "Type one of d, a, n or s."
continue
;;
esac
@@ -798,6 +836,7 @@
# More specific use of matchers is usually covered by completion functions.
local mlist m_ci m_pw m_sub c_list C_list p_list s_list pw_seps key key2 elt
+ local pw_dstar
integer eltcnt lastnz
__ci_get_this_style matcher-list mlist
@@ -814,6 +853,7 @@
# $pws_seps gives the separators used for partial-word completion
# by element of the matcher list; these can be edited separately.
pw_seps=('._-' '._-' '._-' '._-')
+ pw_dstar=('' '' '' '')
# See what's in the matcher initially. If these have been edited,
# we're in trouble, but that's pretty much true of everything.
@@ -822,9 +862,10 @@
[[ $mlist[$eltcnt] = *"m:{a-zA-Z}={A-Za-z}"* ]] && C_list[$eltcnt]=$eltcnt
# For partial word stuff, we use backreferences to find out what
# the set of separators was.
- if [[ $mlist[$eltcnt] = (#b)*"r:|["([^\]]#)"]=* r:|=*"* ]]; then
+ if [[ $mlist[$eltcnt] = (#b)*"r:|["([^\]]#)"]=*"#" r:|=*"* ]]; then
p_list[$eltcnt]=$eltcnt
pw_seps[$eltcnt]=${match[1]}
+ [[ $mlist[$eltcnt] = *"=**"* ]] && pw_dstar[$eltcnt]='*'
fi
# Just look for the left matcher for substring, since the right matcher
# might have been handled as part of a partial-word spec.
@@ -892,6 +933,13 @@
if [[ $pw_seps[$key2] = *']'* ]]; then
pw_seps[$key2]="]${pw_seps[$key2]//\\\]}"
fi
+ print -n "
+You can allow the partial-word terminators to be matched in the pattern,
+too: then for example \`c.u' would expand to \`comp.source.unix', whereas
+usually you would need to type an extra intervening dot. Do you wish the
+terminators to be matched in this way? (y/n) [n] "
+ pw_dstar[$key2]=
+ read -q key && pw_dstar[$key2]='*'
fi
;;
[sS]) __ci_toggle_matcher s_list $key2
@@ -914,7 +962,8 @@
[[ $c_list[$eltcnt] != ' ' ]] && elt="${elt:+$elt }m:{a-z}={A-Z}"
[[ $C_list[$eltcnt] != ' ' ]] && elt="${elt:+$elt }m:{a-zA-Z}={A-Za-z}"
[[ $p_list[$eltcnt] != ' ' ]] &&
- elt="${elt:+$elt }r:|[${pw_seps[$eltcnt]}]=* r:|=*"
+ elt="${elt:+$elt }r:|[${pw_seps[$eltcnt]}]=*${pw_dstar[$eltcnt]}\
+ r:|=*${pw_dstar[$eltcnt]}"
if [[ $s_list[$eltcnt] != ' ' ]]; then
if [[ $elt = *"r:|=*"* ]]; then
elt="${elt:+$elt }l:|=*"
@@ -943,13 +992,14 @@
}
__ci_do_list_format() {
- local key format groupn verbose listp autod
+ local key format groupn verbose listp autod haslistp
__ci_get_this_style format format
[[ -n $format ]] && format=${(Q)format}
__ci_get_this_style group-name groupn
__ci_get_this_style verbose verbose
__ci_get_this_style list-prompt listp
- [[ -n $listp ]] && listp=${(Q)listp}
+ [[ -n $listp ]] && haslistp=1
+ listp=${(Q)listp}
__ci_get_this_style auto-description autod
[[ -n $autod ]] && autod=${(Q)autod}
@@ -1040,17 +1090,23 @@
esac
;;
4) print "\
-Normally, the display of completions which don't fit on the screen is
+You can make completion lists scroll when they don't fit on the screen.
+To do this, edit a prompt to show when scrolling is active; an empty string
+turns this feature off. It can contain \`%l' to show the number of matches
+as \`current_number/total_number', \`%p' to show the fraction of the way
+down the list, or font-control sequences such as %B, %U, %S and the
+corresponding %b, %u, %s; quotes will be added automatically. Note that
+this is the default behaviour; delete the whole line to turn it off, in
+which case the display of completions which don't fit on the screen is
controlled by the LISTMAX parameter (currently ${LISTMAX:-unset}), which
-specifies the maximum number to show without asking. Instead, you can make
-completion lists scroll when they don't fit on the screen. To do this,
-edit a prompt to show when scrolling is active; an empty string turns
-this feature off. It can contain \`%l' to show the number of matches
-as \`current_number/total_number', as well as font-control sequences such
-as %B, %U, %S. Quotes will be added automatically. Hit return to keep the
-current value.
+specifies the maximum number to show without asking. Hit return to keep
+the current value.
"
+ [[ -z $haslistp ]] &&
+ listp='%SAt %p: Hit TAB for more, or the character to insert%s'
vared -eh -p 'prompt> ' -c listp
+ # Unconditionally use listp; will become '' if empty.
+ haslistp=1
;;
5) print "\
Many commands have options which take a single argument. In some cases,
@@ -1080,7 +1136,7 @@
__ci_set_this_style format format
__ci_set_this_style group-name groupn
__ci_set_this_style verbose verbose
- [[ -n $listp ]] && listp=${(qq)listp}
+ [[ -n $haslistp ]] && listp=${(qq)listp}
__ci_set_this_style list-prompt listp
[[ -n $autod ]] && autod=${(qq)autod}
__ci_set_this_style auto-description autod
--
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
Work: pws@CambridgeSiliconRadio.com
Web: http://www.pwstephenson.fsnet.co.uk
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-05-15 11:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-15 11:56 PATCH: compinstall Peter Stephenson
-- strict thread matches above, loose matches on Subject: below --
2000-04-27 20:40 Peter Stephenson
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).