* Completion/User functions again
@ 1999-07-14 10:37 Andrej Borsenkow
1999-07-14 12:09 ` PATCH: " Oliver Kiddle
0 siblings, 1 reply; 4+ messages in thread
From: Andrej Borsenkow @ 1999-07-14 10:37 UTC (permalink / raw)
To: ZSH workers mailing list
I'm still feeling uneasy about installing all of these functions. There are
several reasons:
- _tar and _find are hopelessly GNUish. You cannot expect, that users will
study every function to find out if it is applicable to there system. They will
simply install it and wonder why it does not work. Of course, gzip, configure
etc are GNU as well - but they do not conflict with system standard commands.
- _hosts, _rlogin, _x_options are using array hosts. This most probably does
not exist. Again, I do not like installing something that does not work
out-of-the-box by default. This should be done explicitly in hope, that users
understand what's going on :-)
- _chown, _chgrp, _stty are too system dependent. It is better to not provide
completion at all than provide completion that only partially works. I do not
suggest removing them from distribution - but to not install them by default.
To summarise - I firmly believe, that everything that gets installed must work
"as is" on every system. Anything that works only on some systems or something
that needs additional setup should only be installed explicitly.
/andrej
^ permalink raw reply [flat|nested] 4+ messages in thread
* PATCH: Re: Completion/User functions again
1999-07-14 10:37 Completion/User functions again Andrej Borsenkow
@ 1999-07-14 12:09 ` Oliver Kiddle
0 siblings, 0 replies; 4+ messages in thread
From: Oliver Kiddle @ 1999-07-14 12:09 UTC (permalink / raw)
To: Andrej Borsenkow; +Cc: ZSH workers mailing list
Andrej Borsenkow wrote:
>
> - _tar and _find are hopelessly GNUish. You cannot expect, that users will
> study every function to find out if it is applicable to there system. They will
> simply install it and wonder why it does not work. Of course, gzip, configure
> etc are GNU as well - but they do not conflict with system standard commands.
This is why I suggested a while ago that things such as tar and find are
moved to a 'Gnu' directory and other directories such as Aix, Irix etc
can contain completions specific to
those systems.
> - _hosts, _rlogin, _x_options are using array hosts. This most probably does
> not exist. Again, I do not like installing something that does not work
> out-of-the-box by default. This should be done explicitly in hope, that users
> understand what's going on :-)
This is why I changed _hosts to generate a hosts array from /etc/hosts
if $hosts is unset. This may not work perfectly on all systems but it's
better than just assuming $hosts is set and can always be improved
later. Following is a patch so _rlogin and _x_options use _hosts - I
must have forgotten to do this before. The patch to _x_options also
causes it to only complete options on words starting with a '-'. I
prefer to complete options this way as it keeps the number of matches
down.
> - _chown, _chgrp, _stty are too system dependent. It is better to not provide
> completion at all than provide completion that only partially works. I do not
> suggest removing them from distribution - but to not install them by default.
chown and chgrp will work on the vast majority of systems. They could
certainly be improved to generate a more reliable list of groups though.
Maybe stty can be improved by parsing the output of stty -a.
> To summarise - I firmly believe, that everything that gets installed must work
> "as is" on every system. Anything that works only on some systems or something
> that needs additional setup should only be installed explicitly.
Maybe we should put a note in one of the readmes to make it clear that
the functions may not work on all systems, maybe detailing which might
have issues. I find many of the functions enormously useful and it would
be a pity for them not to be used.
One thing which I just noticed which I don't think is right:
rlogin <tab>
zsh: do you wish to see all 114 possibilities? n
The no returns to 'rlogin ' on the command-line. now, if I press tab
again, menu completion
starts. I think it should ignore the original tab if the question was
answered with no.
Oliver Kiddle
*** Completion/User/_rlogin.old Wed Jul 14 12:36:32 1999
--- Completion/User/_rlogin Wed Jul 14 12:37:42 1999
***************
*** 1,7 ****
#compdef rlogin rsh ssh
if [[ CURRENT -eq 2 ]]; then
! compgen -k hosts
elif [[ CURRENT -eq 3 ]]; then
compadd - -l
else
--- 1,7 ----
#compdef rlogin rsh ssh
if [[ CURRENT -eq 2 ]]; then
! _hosts
elif [[ CURRENT -eq 3 ]]; then
compadd - -l
else
*** Completion/User/_x_options.old Wed Jul 14 12:36:39 1999
--- Completion/User/_x_options Wed Jul 14 12:37:42 1999
***************
*** 3,9 ****
# A simple pattern completion, just as an example.
if [ "$words[CURRENT-1]" = "-display" ]; then
! compgen -k hosts -S':0'
else
! compadd -J options - -display -name -xrm
fi
--- 3,9 ----
# A simple pattern completion, just as an example.
if [ "$words[CURRENT-1]" = "-display" ]; then
! ISUFFIX=':0' _hosts
else
! compadd -P- -J options - display name xrm
fi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: Re: Completion/User functions again
@ 1999-07-14 12:46 Sven Wischnowsky
1999-07-14 13:12 ` Tanaka Akira
0 siblings, 1 reply; 4+ messages in thread
From: Sven Wischnowsky @ 1999-07-14 12:46 UTC (permalink / raw)
To: zsh-workers
Oliver Kiddle wrote:
> Andrej Borsenkow wrote:
> >
> > - _tar and _find are hopelessly GNUish. You cannot expect, that users will
> > study every function to find out if it is applicable to there system. They will
> > simply install it and wonder why it does not work. Of course, gzip, configure
> > etc are GNU as well - but they do not conflict with system standard commands.
>
> This is why I suggested a while ago that things such as tar and find are
> moved to a 'Gnu' directory and other directories such as Aix, Irix etc
> can contain completions specific to
> those systems.
I've been thinking about this for a long time, too. The problems are
that we would have to fill those directories (so that they don't look
silly) and with such directories users would expect to need only to
copy the contents of one such directory (or link User to it), so they
would have to be (almost) complete. That's a lot of work and who'll do
that, I wonder.
While we are at it: we still don't have completion functions for some
commands for which we have compctl examples, e.g. cvs and rpm. I don't
use either of these often enough to be able to write good functions
for them -- any volunteers for that?
> The patch to _x_options also
> causes it to only complete options on words starting with a '-'. I
> prefer to complete options this way as it keeps the number of matches
> down.
I never expected _x_options to survive this long... ;-)
> Maybe we should put a note in one of the readmes to make it clear that
> the functions may not work on all systems, maybe detailing which might
> have issues. I find many of the functions enormously useful and it would
> be a pity for them not to be used.
Maybe, yes.
> One thing which I just noticed which I don't think is right:
> rlogin <tab>
> zsh: do you wish to see all 114 possibilities? n
> The no returns to 'rlogin ' on the command-line. now, if I press tab
> again, menu completion
> starts. I think it should ignore the original tab if the question was
> answered with no.
Hm. 1) It has always been like that (or should have been). 2) Dunno,
you can always use ^D, but I don't have a real opinion about this --
anyone else wanting to comment?
Maybe we should add some kind of programming style guide some day,
containing things like `make functions that can be used as helper
functions do something useful with their arguments if possible' and
`do not use compgen if you're only after the -k or -s options'
(compadd is faster and -- I think -- cleaner for this).
Bye
Sven
diff -u -r oc/User/_hosts Completion/User/_hosts
--- oc/User/_hosts Tue Jul 13 10:58:41 1999
+++ Completion/User/_hosts Wed Jul 14 14:32:29 1999
@@ -2,4 +2,4 @@
: ${(A)hosts:=${(s: :)${(ps:\t:)${${(f)"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
-compgen -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' -k hosts
+compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" - "$hosts[@]"
diff -u -r oc/User/_x_options Completion/User/_x_options
--- oc/User/_x_options Wed Jul 14 14:33:41 1999
+++ Completion/User/_x_options Wed Jul 14 14:42:29 1999
@@ -3,7 +3,8 @@
# A simple pattern completion, just as an example.
if [ "$words[CURRENT-1]" = "-display" ]; then
- ISUFFIX=':0' _hosts
+ _compskip=''
+ _hosts -S :0
else
compadd -P- -J options - display name xrm
fi
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: Re: Completion/User functions again
1999-07-14 12:46 Sven Wischnowsky
@ 1999-07-14 13:12 ` Tanaka Akira
0 siblings, 0 replies; 4+ messages in thread
From: Tanaka Akira @ 1999-07-14 13:12 UTC (permalink / raw)
To: zsh-workers
In article <199907141246.OAA11798@beta.informatik.hu-berlin.de>,
Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:
> While we are at it: we still don't have completion functions for some
> commands for which we have compctl examples, e.g. cvs and rpm. I don't
> use either of these often enough to be able to write good functions
> for them -- any volunteers for that?
I wrote _cvs.
But it's ugly, not self-contained and it doesn't deal with CVS/Entries.
And I don't have a time to implove it in this week.
So, if another implementation exists, it may better.
---------- _cvs ----------
#compdef cvs
typeset -A short_opts
local com="${words[(i)(add|ad|new|admin|adm|rcs|annotate|ann|checkout|co|get|commit|ci|com|diff|di|dif|edit|editors|export|exp|ex|history|hi|his|import|im|imp|init|log|lo|rlog|login|logon|lgn|logout|rdiff|patch|release|re|rel|remove|rm|delete|status|st|stat|rtag|rt|rfreeze|tag|ta|freeze|unedit|update|up|upd|watch|watchers)]}"
local complete_D="compgen -k '(yesterday week\\ ago month\\ ago)'"
local complete_k="compgen -k '(kv kvl k o b v)'"
local complete_r="compgen -k '(tag)'"
#_view_completion_parameters "com=$com"
if (( $com < $CURRENT )); then
case "$words[$com]" in
add|ad|new) # "+k:m:"
short_opts=(k: "$complete_k" m: "compgen -k '(MESSAGE)'")
_complete_opts || compgen -f
;;
admin|adm|rcs) # "+ib::c:a:A:e:l::u::LUn:N:m:o:s:t::IqxV:k:"
short_opts=(i '' b:: '' c: '' a: '' A: '' e: '' l:: '' u:: '' L '' U '' n: '' N: '' m: '' o: '' s: '' t:: '' I '' q '' x '' V: '' k: '')
_complete_opts || compgen -f
;;
annotate|ann) # "+lr:D:fR"
short_opts=(l '' r: '' D: '' f '' R '')
_complete_opts || compgen -f
;;
checkout|co|get) # "+ANnk:d:flRpQqcsr:D:j:P"
short_opts=(A '' N '' n '' k: "$complete_k" d: '' f '' l '' R '' p '' Q '' q '' c '' s '' r: "$complete_r" D: "$complete_D" j: '' P '')
_complete_opts || compgen -k '(MODULE)'
;;
commit|ci|com) # "+nlRm:fF:r:"
short_opts=(n '' l '' R '' m: '' f '' F: '' r: "$complete_r")
_complete_opts || compgen -f
;;
diff|di|dif) # "+abcdefhilnpstuw0123456789BHNRC:D:F:I:L:U:V:W:k:r:"
short_opts=(a '' b '' c '' d '' e '' f '' h '' i '' l '' n '' p '' s '' t '' u '' w ''
0 '' 1 '' 2 '' 3 '' 4 '' 5 '' 6 '' 7 '' 8 '' 9 '' B '' H '' N '' R ''
C: '' D: "$complete_D" F: '' I: '' L: '' U: '' V: '' W: '' k: "$complete_k" r: "$complete_r")
_complete_opts || compgen -f
;;
edit) # "+lRa:"
short_opts=(l '' R '' a: '')
_complete_opts || compgen -f
;;
editors) # "+lR"
short_opts=(l '' R '')
_complete_opts || compgen -f
;;
export|exp|ex) # "+ANnk:d:flRpQqcsr:D:j:P"
short_opts=(A '' N '' n '' k: "$complete_k" d: '' f '' l '' R '' p '' Q '' q '' c '' s '' r: "$complete_r" D: "$complete_D" j: '' P '')
_complete_opts || compgen -k '(MODULE)'
;;
history|hi|his) # "+Tacelow?D:b:f:m:n:p:r:t:u:x:X:z:"
short_opts=(T '' a '' c '' e '' l '' o '' w '' \? '' D: "$complete_D" b: '' f: '' m: '' n: '' p: '' r: '' t: '' u: '' x: '' X: '' z: '')
_complete_opts || compgen -f
;;
import|im|imp) # "+Qqdb:m:I:k:W:"
short_opts=(Q '' q '' d '' b: '' m: '' I: '' k: '' W: '')
_complete_opts || compgen -k '(REPOSITORY-VENDORTAG-RELEASETAG)'
;;
init)
short_opts=()
_complete_opts || compgen -f
;;
login|logon|lgn)
short_opts=()
_complete_opts || compgen -f
;;
logout)
short_opts=()
_complete_opts || compgen -f
;;
rdiff|patch|pa) # "+V:k:cuftsQqlRD:r:"
short_opts=(V: '' k: "$complete_k" c '' u '' f '' t '' s '' Q '' q '' l '' R '' D: "$complete_D" r: "$complete_r")
_complete_opts || compgen -f
;;
release|re|rel) # "+Qdq"
short_opts=(Q '' d '' q '')
_complete_opts || compgen -f
;;
remove|rm|delete) # "+flR"
short_opts=(f '' l '' R '')
_complete_opts || compgen -f
;;
status|st|stat) # "+vlR"
short_opts=(v '' l '' R '')
_complete_opts || compgen -f
;;
tag|ta|freeze) # "+FQqlRcdr:D:bf"
short_opts=(F '' Q '' q '' l '' R '' c '' d '' r: "$complete_r" D: "$complete_D" b '' f '')
_complete_opts || compgen -f
;;
unedit) # "+lR"
short_opts=(l '' R '')
_complete_opts || compgen -f
;;
update|up|upd) # "+ApPflRQqduk:r:D:j:I:W:"
short_opts=(A '' p '' P '' f '' l '' R '' Q '' q '' d '' u '' k: "$complete_k" r: "$complete_r" D: "$complete_D" j: '' I: '' W: '')
_complete_opts || compgen -f
;;
watch)
if [[ $CURRENT = $(($com + 1)) ]]; then
compgen -k '(on off add remove)'
else
case "$words[$com+1]" in
on|off) # "+lR"
short_opts=(l '' R '')
_complete_opts || compgen -f
;;
add|remove) # "+lRa:"
short_opts=(l '' R '' a: '')
_complete_opts || compgen -f
;;
esac
fi
;;
watchers) # "+lR"
short_opts=(l '' R '')
_complete_opts || compgen -f
;;
*) compgen -f;;
esac
return
fi
case ${+cvs_roots} in
0)
cvs_roots=()
if [[ -f ~/.cvspass ]]; then
cvs_roots=(
$(cut -d ' ' -f 1 ~/.cvspass)
)
fi
;;
esac
short_opts=(
H '' Q '' q '' r '' w '' l '' n '' t '' v '' f '' a ''
b: "compgen -k '(/usr/local/bin)'"
T: "compgen -k '(/tmp)'"
e: "compgen -k '(vi)'"
d: "compgen -k cvs_roots || compgen -/"
z: "compgen -k '(9)'"
s: "_cvs_user_variable"
)
_complete_opts ||
compgen -k '(add admin annotate checkout commit
diff edit editors export history
import init log login logout
rdiff release remove status rtag
tag unedit update watch watchers)' ||
compgen -k '(add ad new admin adm rcs annotate ann
checkout co get commit ci com diff di dif
edit editors export exp ex
history hi his import im imp init
log lo rlog login logon lgn logout
rdiff patch release re rel remove rm delete
status st stat rtag rt rfreeze tag ta freeze
unedit update up upd watch
watchers)'
------------------------------
---------- _complete_opts ----------
#autoload
# Usage:
# typeset -A short_opts
# short_opts=(
# H ''
# f 'compgen -f'
# )
# _complete_opts
typeset -a no_arg with_arg
no_arg=($short_opts[(I)?])
with_arg=($short_opts[(I)?:]:s/://)
case "${#no_arg}-${#with_arg}" in
0-0)
if [[ x$PREFIX = x-* ]]; then
compgen -k '()'
else
false
fi
;;
0-*)
if [[ x$PREFIX = x- ]]; then
IPREFIX="$IPREFIX$PREFIX"
PREFIX=
compgen -k with_arg
elif [[ x$PREFIX = x-[${(j::)with_arg}] ]]; then
IPREFIX="$IPREFIX$PREFIX"
PREFIX=
eval $short_opts[$IPREFIX[-1]:]
elif [[ x$PREFIX = x-[${(j::)with_arg}]* ]]; then
local p="$PREFIX[1,(r)[${(j::)with_arg}]]"
IPREFIX="$IPREFIX$p"
PREFIX="$PREFIX[$#p + 1,-1]"
eval $short_opts[$IPREFIX[-1]:]
elif [[ x$words[$CURRENT-1] = x-[${(j::)with_arg}] ]]; then
local p="$words[$CURRENT - 1]"
eval $short_opts[$p[-1]:]
else
false
fi
;;
*-0)
if [[ x$PREFIX = x-[${(j::)no_arg}]# ]]; then
IPREFIX="$IPREFIX$PREFIX"
PREFIX=
compgen -k no_arg
else
false
fi
;;
*-*)
if [[ x$PREFIX = x-[${(j::)no_arg}]# ]]; then
IPREFIX="$IPREFIX$PREFIX"
PREFIX=
compgen -k no_arg
compgen -k with_arg
elif [[ x$PREFIX = x-[${(j::)no_arg}]#[${(j::)with_arg}] ]]; then
IPREFIX="$IPREFIX$PREFIX"
PREFIX=
eval $short_opts[$IPREFIX[-1]:]
elif [[ x$PREFIX = x-[${(j::)no_arg}]#[${(j::)with_arg}]* ]]; then
local p="$PREFIX[1,(r)[${(j::)with_arg}]]"
IPREFIX="$IPREFIX$p"
PREFIX="$PREFIX[$#p + 1,-1]"
eval $short_opts[$IPREFIX[-1]:]
elif [[ x$words[$CURRENT-1] = x-[${(j::)no_arg}]#[${(j::)with_arg}] ]]; then
local p="$words[$CURRENT - 1]"
eval $short_opts[$p[-1]:]
else
false
fi
;;
esac
------------------------------
Also, I wrote _wget, _lynx, etc. If you interest them, See
http://www.ldl.jaist.ac.jp/~akr/zsh/dot-zsh/funcs/.
I want standard way to specify user's completion preferences such as
host-port relation for _telnet and _socket, URLs for _wget and _lynx,
user-host relation for _finger, and so on.
--
Tanaka Akira
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1999-07-14 13:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-14 10:37 Completion/User functions again Andrej Borsenkow
1999-07-14 12:09 ` PATCH: " Oliver Kiddle
1999-07-14 12:46 Sven Wischnowsky
1999-07-14 13:12 ` Tanaka Akira
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).