zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: _subscript, Re: pws-23
  1999-06-21 11:52 PATCH: _subscript, Re: pws-23 Kiddle, Oliver
@ 1999-06-21 11:43 ` Peter Stephenson
  1999-07-01 14:34   ` PATCH: completion for hosts and character classes Oliver Kiddle
  1999-06-21 13:04 ` PATCH: _subscript, Re: pws-23 Andrej Borsenkow
  1 sibling, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 1999-06-21 11:43 UTC (permalink / raw)
  To: Zsh hackers list

"Kiddle, Oliver" wrote:
> _subscript in pws-23 seems to have been slightly damaged, probably due to
> word wrapping somewhere.

I've received this one with the first hunk wrapped, too.  It's probably
your end, since I've haven't noticed it when Sven and others having been
flinging patches about with abandon.

> I use print -D to print
> the value of the array. This is rather useful with things like path where
> things get compacted to something like ~/bin.

I wish there was a way of getting things like this done without forking,
roughly the way TCL does.

> 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.

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.

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


^ permalink raw reply	[flat|nested] 5+ messages in thread

* PATCH: _subscript, Re: pws-23
@ 1999-06-21 11:52 Kiddle, Oliver
  1999-06-21 11:43 ` Peter Stephenson
  1999-06-21 13:04 ` PATCH: _subscript, Re: pws-23 Andrej Borsenkow
  0 siblings, 2 replies; 5+ messages in thread
From: Kiddle, Oliver @ 1999-06-21 11:52 UTC (permalink / raw)
  To: 'Peter Stephenson <pws@ibmth.df.unipi.it>'
  Cc: 'zsh-workers@sunsite.auc.dk'

_subscript in pws-23 seems to have been slightly damaged, probably due to
word wrapping somewhere. The list= line for associative arrays should end
with " ) and the following line should not have the closing bracket. A patch
for this follows but I've also made a slight change: I use print -D to print
the value of the array. This is rather useful with things like path where
things get compacted to something like ~/bin. If it breaks anything else, we
could use: if [[ ${compstate[parameter]} = *path* ]]; then, to only do it
for path arrays.

What might be useful is to add make zsh expand ${(D)...} in a similar way to
print -D.

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. Peter: thanks for putting the .bin links in for the bzipped
source: it didn't corrupt this time.

Oliver Kiddle

*** Completion/Base/_subscript.old	Sun Jun 20 14:32:31 1999
--- Completion/Base/_subscript	Mon Jun 21 12:38:24 1999
***************
*** 13,20 ****
    list=()
    for i in "$ind[@]"; do
      [[ "$i" = ${PREFIX}*${SUFFIX} ]] &&
!         list=( "$list[@]" "${(r:4:: ::):)i}
${(P)${compstate[parameter]}[$i]}
! )
    done
  
   if [[ "$RBUFFER" = \]* ]]; then
--- 13,20 ----
    list=()
    for i in "$ind[@]"; do
      [[ "$i" = ${PREFIX}*${SUFFIX} ]] &&
! 	  list=( "$list[@]" \
! 	      "${(r:4:: ::):)i} `print -D
${(P)${compstate[parameter]}[$i]}`" )
    done
  
   if [[ "$RBUFFER" = \]* ]]; then


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: PATCH: _subscript, Re: pws-23
  1999-06-21 11:52 PATCH: _subscript, Re: pws-23 Kiddle, Oliver
  1999-06-21 11:43 ` Peter Stephenson
@ 1999-06-21 13:04 ` Andrej Borsenkow
  1 sibling, 0 replies; 5+ messages in thread
From: Andrej Borsenkow @ 1999-06-21 13:04 UTC (permalink / raw)
  To: Kiddle, Oliver, pws; +Cc: zsh-workers

> !         list=( "$list[@]" "${(r:4:: ::):)i}
> ${(P)${compstate[parameter]}[$i]}

^^^^^^^^^^^^

> ! 	  list=( "$list[@]" \
> ! 	      "${(r:4:: ::):)i} `print -D
> ${(P)${compstate[parameter]}[$i]}`" )

^^^^^^^^^^^^^

The lines are wrapped and patch does not apply (malformed patch, says it). May
be, after all, MIME is not as evil ...

/andrej


^ permalink raw reply	[flat|nested] 5+ messages in thread

* PATCH: completion for hosts and character classes
  1999-06-21 11:43 ` Peter Stephenson
@ 1999-07-01 14:34   ` Oliver Kiddle
  1999-07-02  9:10     ` Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Oliver Kiddle @ 1999-07-01 14:34 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh hackers list

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: completion for hosts and character classes
  1999-07-01 14:34   ` PATCH: completion for hosts and character classes Oliver Kiddle
@ 1999-07-02  9:10     ` Peter Stephenson
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 1999-07-02  9:10 UTC (permalink / raw)
  To: Zsh hackers list

Oliver Kiddle wrote:
> > 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.

It's actually years since I've consciously used a machine with a useful
/etc/hosts file, now that DNS is so widespread.  The way I generate a hosts
variable is by looking at .netrc or .rhosts or .ncftp/bookmarks, depending
how I feel when I write .zshrc.  This gets a much more personalised set of
hosts. 

> PS. If the patch doesn't work, check that none of the lines have been
> wrapped.

You should try and make sure you can create shorter lines by using
backslashes, or send it uuencoded or with mime quoting.

By the way, it's high time I pointed out that sending me a copy of a
message going to any of the zsh lists is futile as they get sorted into the
same folder and I just have to delete one.

Also, I'm working on compinstall, but I'm logged in from a maddening PC
terminal at a conference, so it will have to wait until the weekend.

Also, since I'm out of time, I'd also be quite glad to see some neater code
for keymaps.  Obviously this will be after 3.1.6.  If improvements can be
split into smaller chunks, that would help testing.

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1999-07-02  9:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-06-21 11:52 PATCH: _subscript, Re: pws-23 Kiddle, Oliver
1999-06-21 11:43 ` Peter Stephenson
1999-07-01 14:34   ` PATCH: completion for hosts and character classes Oliver Kiddle
1999-07-02  9:10     ` Peter Stephenson
1999-06-21 13:04 ` PATCH: _subscript, Re: pws-23 Andrej Borsenkow

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).