zsh-workers
 help / color / mirror / code / Atom feed
* Re; lftp completion
@ 2001-03-13 12:59 Oliver Kiddle
  0 siblings, 0 replies; 6+ messages in thread
From: Oliver Kiddle @ 2001-03-13 12:59 UTC (permalink / raw)
  To: zsh-workers

Bart wrote:

> Chmouel's _lftp function is very similar to _ncftp.  Here's a single
> function that handles both, without resorting to "awk -F" or "cut":

> local bookmarks=$HOME/.${words[0]:t}/bookmarks

Shouldn't the function be using $service instead of ${words[0]:t}?

> Any object to replacing _ncftp with the above and removing _lftp? (One
> possible objection might be that lftp allows commas in its bookmark
> names; I don't know whether or not that's the case.)

It seems like a reasonable thing to do to me. There is also enough
similarity that even if someone takes the time to improve the function
they can probably keep the two commands together.

Oliver


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

* Re: Re; lftp completion
@ 2001-03-16  8:16 Sven Wischnowsky
  0 siblings, 0 replies; 6+ messages in thread
From: Sven Wischnowsky @ 2001-03-16  8:16 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> }  Sven 'or use a style to allow overriding that' Wischnowsky
> 
> Is this the sort of thing you mean?  (Not committed yet.)  It's been so
> long since I added a style that I've forgetten all the details.

We could just use `zstyle -s ":completion:${curcontext}:" bookmarks ...'
and rely on _normal putting the (real) command name in the context.

But I don't care enough about all those ftps to decide if this should
go in or if we wait for some utility function (as mentioned by Oliver) 
to appear.


Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

* Re: Re; lftp completion
  2001-03-14  8:01 Sven Wischnowsky
@ 2001-03-15 18:00 ` Bart Schaefer
  0 siblings, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 2001-03-15 18:00 UTC (permalink / raw)
  To: zsh-workers

}  Sven 'or use a style to allow overriding that' Wischnowsky

Is this the sort of thing you mean?  (Not committed yet.)  It's been so
long since I added a style that I've forgetten all the details.


_ncftp () {
  local bookmarks
  zstyle -s \*:$service bookmarks-file bookmarks ||
     bookmarks=$HOME/.$service/bookmarks
  if [[ -f $bookmarks ]]
  then
    bookmarks=(${"${(f)$(<$bookmarks)}"%%[[:space:],]*})
    [[ $service = ncftp ]] && shift 2 bookmarks
    _wanted bookmarks expl bookmark compadd -a bookmarks && return 0 
  fi
  _hosts
}

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

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* Re: Re; lftp completion
@ 2001-03-14  8:01 Sven Wischnowsky
  2001-03-15 18:00 ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Sven Wischnowsky @ 2001-03-14  8:01 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On Mar 13,  2:38pm, Oliver Kiddle wrote:
> } Subject: Re; lftp completion
> }
> } Bart wrote:
> } 
> } > local bookmarks=$HOME/.${words[0]:t}/bookmarks
> } 
> } Shouldn't the function be using $service instead of ${words[0]:t}?
> 
> I went back and forth on that one.  Using $service would mean that some
> other command wanted to read ncftp's (or lftp's) bookmarks file, rather
> than having its own with a similar format.  I concluded that wasn't
> likely; but maybe the other way would in fact be better.

How about a compromise: check if $HOME/.${words[0]:t}/bookmarks exists 
and if it doesn't, fall back on $HOME/$service/bookmarks.


Bye
 Sven 'or use a style to allow overriding that' Wischnowsky


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

* Re: Re; lftp completion
  2001-03-13 14:38 Oliver Kiddle
@ 2001-03-13 17:32 ` Bart Schaefer
  0 siblings, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 2001-03-13 17:32 UTC (permalink / raw)
  To: zsh-workers

On Mar 13,  2:38pm, Oliver Kiddle wrote:
} Subject: Re; lftp completion
}
} Bart wrote:
} 
} > local bookmarks=$HOME/.${words[0]:t}/bookmarks
} 
} Shouldn't the function be using $service instead of ${words[0]:t}?

I went back and forth on that one.  Using $service would mean that some
other command wanted to read ncftp's (or lftp's) bookmarks file, rather
than having its own with a similar format.  I concluded that wasn't
likely; but maybe the other way would in fact be better.

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

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* Re; lftp completion
@ 2001-03-13 14:38 Oliver Kiddle
  2001-03-13 17:32 ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Oliver Kiddle @ 2001-03-13 14:38 UTC (permalink / raw)
  To: zsh-workers

Bart wrote:

> Chmouel's _lftp function is very similar to _ncftp.  Here's a single
> function that handles both, without resorting to "awk -F" or "cut":

> local bookmarks=$HOME/.${words[0]:t}/bookmarks

Shouldn't the function be using $service instead of ${words[0]:t}?

> Any object to replacing _ncftp with the above and removing _lftp? (One
> possible objection might be that lftp allows commas in its bookmark
> names; I don't know whether or not that's the case.)

It seems like a reasonable thing to do to me. There is also enough 
similarity that even if someone takes the time to improve the function 
they can probably keep the two commands together.

Oliver


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

end of thread, other threads:[~2001-03-16  8:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-13 12:59 Re; lftp completion Oliver Kiddle
2001-03-13 14:38 Oliver Kiddle
2001-03-13 17:32 ` Bart Schaefer
2001-03-14  8:01 Sven Wischnowsky
2001-03-15 18:00 ` Bart Schaefer
2001-03-16  8:16 Sven Wischnowsky

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