From: Oliver Kiddle <opk@thoth.u-net.com>
To: Peter Stephenson <pws@ibmth.df.unipi.it>
Cc: Zsh hackers list <zsh-workers@sunsite.auc.dk>
Subject: PATCH: completion for hosts and character classes
Date: Thu, 01 Jul 1999 15:34:21 +0100 [thread overview]
Message-ID: <377B7C6D.5F1FC98C@thoth.u-net.com> (raw)
In-Reply-To: <9906211143.AA29441@ibmth.df.unipi.it>
On 21 Jun, Peter Stephenson wrote:
> Oliver Kiddle wrote:
> > BTW, the _hosts change which I sent last Friday (and which isn't in pws-23)
> > doesn't work with my hosts file at home so I'll send a replacement later in
> > the week.
My mistake was using \t in the pattern to match tabs which ofcourse
doesn't work. The patch which follows uses [:blank:] and works with all
the host files I've tried. I've also included a patch for
compctl-examples which generated hosts and groups arrays, using the old
method with lots of (@). Interestingly, the replacements seem to be
noticeably faster (on my slow computer). The other part of the patch is
to complete the character classes like [:blank:]. This seems to work but
as with my other attempts to patch _subscript, will probably need a bit
of tidying up.
> I must have forgotten about that. But we probably need more sophisticated
> ways of generating host names from all sorts of different sources.
> /etc/hosts isn't all that well used any more.
Have you got any suggestions for other ways of generating a hosts list.
The only cases I can think of where there won't be a hosts file is if
NIS is being used or if the computer is a nameserver itself. It's quite
easy to generate a list of hosts in each of these cases but I'm not
quite sure how to determine when these are the case.
In some contexts, we'll probably want to do something totally different
for completing hosts. For example, with ncftp, using the bookmarks and
for urls using the Netscape/Lynx bookmarks or history file.
Oliver Kiddle
PS. If the patch doesn't work, check that none of the lines have been
wrapped.
*** Completion/User/_hosts.old Tue Apr 13 08:37:40 1999
--- Completion/User/_hosts Thu Jul 1 13:58:17 1999
***************
*** 1,3 ****
! #compdef ftp ncftp ping rwho rup xping traceroute nslookup
! compgen -k hosts
--- 1,5 ----
! #compdef ftp ncftp ping rwho rup xping traceroute nslookup telnet
xhost
! : ${(A)hosts:=${(s:
:)${(ps:\t:)${${(f)"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
!
! compgen -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' -k hosts
*** Misc/compctl-examples.old Thu Jul 1 13:48:33 1999
--- Misc/compctl-examples Thu Jul 1 13:52:16 1999
***************
*** 11,17 ****
# page.
#
#------------------------------------------------------------------------------
! hosts=("${(@)${(@s: :)${(@s: :)${(@)${(@f)$(</etc/hosts)}%%\#*}#*[
]*}}:#}")
ports=( "${(@)${(@)${(@f)$(</etc/services)}:#\#*}%%[ ]*}" )
# groups=( $(cut -d: -f1 /etc/group) )
--- 11,17 ----
# page.
#
#------------------------------------------------------------------------------
! hosts=( ${(s:
:)${(ps:\t:)${${(f)"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}} )
ports=( "${(@)${(@)${(@f)$(</etc/services)}:#\#*}%%[ ]*}" )
# groups=( $(cut -d: -f1 /etc/group) )
***************
*** 18,25 ****
# groups=( $(ypcat group.byname | cut -d: -f1) ) # if you use NIS
# It can be done without forking, but it used too much memory in old
zsh's:
! groups=( "${(@)${(@f)$(</etc/group)}%%:*}" )
! #groups=( "${(@)${(@f)$(ypcat groups)}%%:*}" ) # if you use NIS
# Completion for zsh builtins.
compctl -z -P '%' bg
--- 18,25 ----
# groups=( $(ypcat group.byname | cut -d: -f1) ) # if you use NIS
# It can be done without forking, but it used too much memory in old
zsh's:
! groups=( ${${(s: :)$(</etc/group)}%%:*} )
! #groups=( ${${(s: :)$(ypcat groups)}%%:*} ) # if you use NIS
# Completion for zsh builtins.
compctl -z -P '%' bg
*** Completion/Base/_subscript.old Mon Jun 21 13:25:51 1999
--- Completion/Base/_subscript Thu Jul 1 14:41:54 1999
***************
*** 1,6 ****
#compdef -subscript-
! if [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then
if [[ "$RBUFFER" = \]* ]]; then
compadd -S '' - "${(@kP)${compstate[parameter]}}"
else
--- 1,9 ----
#compdef -subscript-
! if [[ "$PREFIX" = :* ]]; then
! compadd -p: -S ':]' alnum alpha blank cntrl digit graph lower print
punct \
! space upper xdigit
! elif [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then
if [[ "$RBUFFER" = \]* ]]; then
compadd -S '' - "${(@kP)${compstate[parameter]}}"
else
next prev parent reply other threads:[~1999-07-01 14:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-06-21 11:52 PATCH: _subscript, Re: pws-23 Kiddle, Oliver
1999-06-21 11:43 ` Peter Stephenson
1999-07-01 14:34 ` Oliver Kiddle [this message]
1999-07-02 9:10 ` PATCH: completion for hosts and character classes Peter Stephenson
1999-06-21 13:04 ` PATCH: _subscript, Re: pws-23 Andrej Borsenkow
1999-07-02 9:48 PATCH: completion for hosts and character classes Sven Wischnowsky
1999-07-02 13:07 Sven Wischnowsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=377B7C6D.5F1FC98C@thoth.u-net.com \
--to=opk@thoth.u-net.com \
--cc=pws@ibmth.df.unipi.it \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).