zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: _urls again (Re: setopt localoptions noautoremoveslash)
@ 1999-10-15 12:10 Sven Wischnowsky
  1999-10-15 15:30 ` Oliver Kiddle
  0 siblings, 1 reply; 9+ messages in thread
From: Sven Wischnowsky @ 1999-10-15 12:10 UTC (permalink / raw)
  To: zsh-workers


Oliver Kiddle wrote:

> One strange behaviour I find with completing urls is that with
> urls_localhttpd set, when I complete user directories, menu
> selection is entered imediately rather than waiting for a second tab:
> e.g: netscape http://risc10/~<tab> will insert 'ada' and give me the
> list with 'ada' selected rather than just giving me the list. This
> behaviour continues when completing files and directories after the
> username. 
> 
> I've also noticed that with this dual file/directory completion and
> description_format set, I get 'file' aswell as 'directory' at the top
> of the list even if there were no files to complete. 

Do you mean to say that you still get this or that you fixed it? At
least I don't get either of these after your patch. If you still get
them, I need more information about your configuration and the
possible matches that triggered it.

Bye
 Sven


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


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

* Re: PATCH: _urls again (Re: setopt localoptions noautoremoveslash)
  1999-10-15 12:10 PATCH: _urls again (Re: setopt localoptions noautoremoveslash) Sven Wischnowsky
@ 1999-10-15 15:30 ` Oliver Kiddle
       [not found]   ` <991015155008.ZM24081@candle.brasslantern.com>
  1999-10-16 13:56   ` PATCH: _urls again (Re: setopt localoptions noautoremoveslash) Tanaka Akira
  0 siblings, 2 replies; 9+ messages in thread
From: Oliver Kiddle @ 1999-10-15 15:30 UTC (permalink / raw)
  To: zsh-workers

Sven Wischnowsky wrote:
 
> Do you mean to say that you still get this or that you fixed it? At
> least I don't get either of these after your patch. If you still get
> them, I need more information about your configuration and the
> possible matches that triggered it.

I mean that I still get this.

I tracked down the first problem to setopt glob_complete. i.e, the
following is sufficient to cause the problem:
zsh -f
ZLS_COLOURS=...;SELECTMIN=0;zmodload complist
autoload -U compinit;compinit -d
compconf urls_localhttp=...
setopt globcomplete

In the process, I established that _urls requires globcomplete; patch
follows.

With respect to the second problem, I think I was just confused by the
fact that I got a listing which looks like:
file
directory
fred/    joe
when I expected the file to appear before 'directory' so sorry for not
checking it before I sent the mail.

Tanaka Akira wrote:
> +++ Completion/User/_urls       1999/10/15 14:28:55
> @@ -1,4 +1,4 @@
> -#autoload
> +#compdef curl

Shouldn't this be done in _webbrowser. Or we should do what I suggested
before which is to ditch _webbrowser, add the programs to a compdef in
_urls and negate the meaning of -f to _urls.

> * Use [[ ... ]] instead of [ ... ].

Could someone please explain why [[ ... ]] seems to be prefered where
both forms provide the same functionality ? Sven also changed my use of
[ -d ... ] to use the double square brackets. Is it faster or something?

Oliver Kiddle

--- _urls.bak3	Fri Oct 15 16:11:03 1999
+++ _urls	Fri Oct 15 16:13:26 1999
@@ -37,6 +37,8 @@
 #    name used by a user placing web pages within their home area.
 #    e.g. compconf
urls_localhttp=www:/usr/local/apache/htdocs:public_html
 
+setopt localoptions extendedglob
+
 local ipre scheme host user dirs files ret=1 expl
 local localhttp_servername="${${(@s.:.)compconfig[urls_localhttp]}[1]}"
 local
localhttp_documentroot="${${(@s.:.)compconfig[urls_localhttp]}[2]}"


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

* Re: PATCH: _urls again (Re: setopt localoptions noautoremoveslash)
       [not found]   ` <991015155008.ZM24081@candle.brasslantern.com>
@ 1999-10-15 16:05     ` Oliver Kiddle
  1999-10-15 16:40       ` Bart Schaefer
  0 siblings, 1 reply; 9+ messages in thread
From: Oliver Kiddle @ 1999-10-15 16:05 UTC (permalink / raw)
  To: Zsh workers

Bart Schaefer wrote:
> 
> On Oct 15,  4:30pm, Oliver Kiddle wrote:
> } Subject: Re: PATCH: _urls again (Re: setopt localoptions noautoremoveslash
> }
> } In the process, I established that _urls requires globcomplete; patch
> } follows.
> }
> } +setopt localoptions extendedglob
> } +
> 
> So which is it?

Sorry, the beers from lunch time in the pub are stopping me thinking
properly :) The patch is correct: extendedglob is required by _urls. I
got mixed up with globcomplete which is the option that causes the
problem I described before with menu selection kicking in early.

Oliver Kiddle


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

* Re: PATCH: _urls again (Re: setopt localoptions noautoremoveslash)
  1999-10-15 16:05     ` Oliver Kiddle
@ 1999-10-15 16:40       ` Bart Schaefer
  1999-10-15 16:54         ` _urls ... and CVS Adam Spiers
  0 siblings, 1 reply; 9+ messages in thread
From: Bart Schaefer @ 1999-10-15 16:40 UTC (permalink / raw)
  To: Zsh workers

On Oct 15,  5:05pm, Oliver Kiddle wrote:
} Subject: Re: PATCH: _urls again (Re: setopt localoptions noautoremoveslash
}
} The patch is correct: extendedglob is required by _urls.

The patch is broken at my end by line folding in transit ... but it's
also subsumed by Tanaka's 8286.

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


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

* _urls ... and CVS
  1999-10-15 16:40       ` Bart Schaefer
@ 1999-10-15 16:54         ` Adam Spiers
  1999-10-16  5:18           ` Tanaka Akira
  0 siblings, 1 reply; 9+ messages in thread
From: Adam Spiers @ 1999-10-15 16:54 UTC (permalink / raw)
  To: Zsh workers

Bart Schaefer (schaefer@candle.brasslantern.com) wrote:
> On Oct 15,  5:05pm, Oliver Kiddle wrote:
> } Subject: Re: PATCH: _urls again (Re: setopt localoptions noautoremoveslash
> }
> } The patch is correct: extendedglob is required by _urls.
> 
> The patch is broken at my end by line folding in transit ... but it's
> also subsumed by Tanaka's 8286.

Can some kind person please email me correctly-patched _urls?  Mine
got badly messed up somehow.

Ouch, I'm getting desperate for CVS now.  Since Bart and Sven are
probably currently the most active developers, perhaps they would like
to decide what to do about it?  As has been mentioned, either we keep
following the `benign dictatorship' route by someone taking over pws'
role, or we have a select few developers with write-access to the CVS
repository.  Or we ditch the whole CVS idea, but it doesn't seem like
anyone thinks it's anything other than a good idea.

What would be really nice is to incorporate some kind of moderation
layer into the CVS commit wrappers, so that anyone could perform a CVS
commit, but it would only take place after the patch had been mailed
to one or more moderators for approval.  Is that unrealistic?


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

* Re: _urls ... and CVS
  1999-10-15 16:54         ` _urls ... and CVS Adam Spiers
@ 1999-10-16  5:18           ` Tanaka Akira
  0 siblings, 0 replies; 9+ messages in thread
From: Tanaka Akira @ 1999-10-16  5:18 UTC (permalink / raw)
  To: Zsh workers

In article <19991015175407.A19450@thelonious.new.ox.ac.uk>,
  Adam Spiers <adam@thelonious.new.ox.ac.uk> writes:

> Can some kind person please email me correctly-patched _urls?  Mine
> got badly messed up somehow.

This is my latest version.

#compdef curl

# Usage: _urls [-f]
# Options:
#  -f : complete files first.
#
# Configuration keys used:
#
#  urls_path
#    The path to a directory containing a URL database, such as:
#
#      % cd ~/.zsh/urls
#      % find . -ls
#      ... drwxr-xr-x ... 512 Sep  3 02:46 .
#      ... drwxr-xr-x ... 512 Sep  3 02:48 ./http
#      ... drwxr-xr-x ... 512 Sep  3 02:52 ./http/www.zsh.org
#      ... drwxr-xr-x ... 512 Sep  3 03:01 ./http/www.zsh.org/mla
#      ... drwxr-xr-x ... 512 Sep  3 03:01 ./http/www.zsh.org/mla/workers
#      ... drwxr-xr-x ... 512 Sep  3 03:01 ./http/www.zsh.org/mla/workers/1999
#      ... -rw-r--r-- ...   0 Sep  3 03:01 ./http/www.zsh.org/mla/workers/1999/index.html
#      ... drwxr-xr-x ... 512 Sep  3 02:48 ./http/sunsite.auc.dk
#      ... drwxr-xr-x ... 512 Sep  3 02:48 ./http/sunsite.auc.dk/zsh
#      ... drwxr-xr-x ... 512 Sep  3 02:47 ./bookmark
#      ... drwxr-xr-x ... 512 Sep  3 02:48 ./bookmark/zsh
#      ... -rw-r--r-- ...  27 Sep  3 02:47 ./bookmark/zsh/home
#      ... -rw-r--r-- ...  20 Sep  3 02:48 ./bookmark/zsh/meta
#      % cat bookmark/zsh/home 
#      http://sunsite.auc.dk/zsh/
#      % cat bookmark/zsh/meta
#      http://www.zsh.org/
#
#  urls_localhttp
#    Specify a local web server in the form:
#      hostname:doc root:user area
#    where hostname is the name of the web server, doc root is the path to
#    the default web pages for the server and user area is the directory
#    name used by a user placing web pages within their home area.
#    e.g. compconf urls_localhttp=www:/usr/local/apache/htdocs:public_html

setopt localoptions extendedglob

local ipre scheme host user hosts ret=1 expl
local urls_path="${compconfig[urls_path]:-${ZDOTDIR:-$HOME}/.zsh/urls}"
local localhttp_servername="${${(@s.:.)compconfig[urls_localhttp]}[1]}"
local localhttp_documentroot="${${(@s.:.)compconfig[urls_localhttp]}[2]}"
local localhttp_userdir="${${(@s.:.)compconfig[urls_localhttp]}[3]}"

if [[ "$1" = -f ]]; then
  shift
  _files "$@" && return
fi

ipre="$IPREFIX"

if ! compset -P '(#b)([-+.a-z0-9]#):'; then
  _description expl 'URL prefix'
  [[ -d $urls_path/bookmark ]] &&
    compadd "$@" "$expl[@]" -S '' bookmark: && ret=0
  compadd "$@" "$expl[@]" -S '' file: ftp:// gopher:// http:// && ret=0
  return $ret
fi
scheme="$match[1]"

case "$scheme" in
  http|ftp|gopher)
    if ! compset -P //; then
      compadd "$@" -S '' //
      return
    fi
  ;;
  file)
    if ! compset -P //; then
      if [[ -prefix / ]]; then
	_path_files "$@" -S '' -g '*(^/)' && ret=0
	_path_files "$@" -S/ -r '/' -/ && ret=0
      elif [[ -z "$PREFIX" ]]; then
	compadd -S '/' -r '/' - "${PWD%/}"
	ret=0
      fi
      return $ret
    fi
  ;;
  bookmark)
    if [[ -f "$urls_path/$scheme/$PREFIX$SUFFIX" &&
	  -s "$urls_path/$scheme/$PREFIX$SUFFIX" ]]; then
      compadd "$@" -QU -- "$ipre$(<"$urls_path/$scheme/$PREFIX$SUFFIX")" && ret=0
    else
      _description expl 'bookmark'
      _path_files -W "$urls_path/$scheme" "$expl[@]" -S '' -g '*(^/)' && ret=0
      _path_files -W "$urls_path/$scheme" -S/ -r '/' -/ && ret=0
    fi
    return $ret
  ;;
esac

# Complete hosts
if ! compset -P '(#b)([^/]#)/'; then
  hosts=($urls_path/$scheme/$PREFIX*$SUFFIX(/:t))
  (( $#hosts )) || _hosts -S/ && ret=0
  [[ "$scheme" = http ]] && hosts=($hosts $localhttp_servername)
  compadd "$@" -QS/ - $hosts && ret=0
  return $ret
fi
host="$match[1]"

# Complete part after hostname
if [[ "$localhttp_servername" = "$host" ]]; then
  if compset -P \~; then
    if ! compset -P '(#b)([^/]#)/'; then
      _users -S/
      return
    fi
    user="$match[1]"
    _path_files -W ~$user/$localhttp_userdir -g '*(^/)' && ret=0
    _path_files -W ~$user/$localhttp_userdir -S/ -r '/' -/ && ret=0
  else
    _path_files -W $localhttp_documentroot -g '*(^/)' && ret=0
    _path_files -W $localhttp_documentroot -S/ -r '/' -/ && ret=0
  fi
else
  _path_files -W $urls_path/$scheme/$host -g '*(^/)' && ret=0
  _path_files -W $urls_path/$scheme/$host -S/ -r '/' -/ && ret=0
fi
return $ret
-- 
Tanaka Akira


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

* Re: PATCH: _urls again (Re: setopt localoptions noautoremoveslash)
  1999-10-15 15:30 ` Oliver Kiddle
       [not found]   ` <991015155008.ZM24081@candle.brasslantern.com>
@ 1999-10-16 13:56   ` Tanaka Akira
  1999-10-16 15:33     ` "[[" (Re: PATCH: _urls again (Re: setopt localoptions noautoremoveslash)) Bart Schaefer
  1 sibling, 1 reply; 9+ messages in thread
From: Tanaka Akira @ 1999-10-16 13:56 UTC (permalink / raw)
  To: zsh-workers

In article <38074889.6DCA13F@u.genie.co.uk>,
  Oliver Kiddle <opk@u.genie.co.uk> writes:

> > -#autoload
> > +#compdef curl
> 
> Shouldn't this be done in _webbrowser. Or we should do what I suggested
> before which is to ditch _webbrowser, add the programs to a compdef in
> _urls and negate the meaning of -f to _urls.

I don't think so.  The name of the function should show its (default)
behaviour.  If _urls complete files by default, it should be renamed
to _filesurls or some similar name.

> 
> > * Use [[ ... ]] instead of [ ... ].
> 
> Could someone please explain why [[ ... ]] seems to be prefered where
> both forms provide the same functionality ? Sven also changed my use of
> [ -d ... ] to use the double square brackets. Is it faster or something?

I'm not sure about this.  But I believe the description of `test' in
zshbuiltins(1).
-- 
Tanaka Akira


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

* "[[" (Re: PATCH: _urls again (Re: setopt localoptions noautoremoveslash))
  1999-10-16 13:56   ` PATCH: _urls again (Re: setopt localoptions noautoremoveslash) Tanaka Akira
@ 1999-10-16 15:33     ` Bart Schaefer
  0 siblings, 0 replies; 9+ messages in thread
From: Bart Schaefer @ 1999-10-16 15:33 UTC (permalink / raw)
  To: zsh-workers

On Oct 16, 10:56pm, Tanaka Akira wrote:
} Subject: Re: PATCH: _urls again (Re: setopt localoptions noautoremoveslash
}
} In article <38074889.6DCA13F@u.genie.co.uk>,
}   Oliver Kiddle <opk@u.genie.co.uk> writes:
} > 
} > > * Use [[ ... ]] instead of [ ... ].
} > 
} > Could someone please explain why [[ ... ]] seems to be prefered where
} > both forms provide the same functionality ? Sven also changed my use of
} > [ -d ... ] to use the double square brackets. Is it faster or something?
} 
} I'm not sure about this.  But I believe the description of `test' in
} zshbuiltins(1).

PWS says in http://www.ifh.de/~pws/computing/zshguide02.html#l6

    Second aside for users of sh: you may remember that tests in sh used
    a single pair of brackets, `if [ ... ]; then ...', or equivalently
    as a command called test, `if test ...; then ...'. The Korn shell
    was deliberately made to be different, and zsh follows that. The
    reason is that `[[' is treated specially, which allows the shell to
    do some extra checks and allows more natural syntax. For example,
    you may know that in sh it's dangerous to test a parameter which
    may be empty: `[ $var = foo ]' will fail if $var is empty, because
    the word is missed out and the shell never knows it was supposed
    to be there (I'll explain about parameters shortly); with `[[ ...
    ]]', this is quite safe because the shell is aware there's a word
    before the `=', even if it's empty. Also, you can use `&&' and
    `||' to mean logical `and' and `or', which agrees with the usual
    UNIX/C convention; in sh, they would have been taken as starting a
    new command, not as part of the test, and you have to use the less
    clear `-a' and `-o'. Actually, zsh provides the old form of test for
    backward compatibility, but things will work a lot more smoothly if
    you don't use it.

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


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

* Re: "[[" (Re: PATCH: _urls again (Re: setopt localoptions noautoremoveslash))
@ 1999-10-18  6:59 Sven Wischnowsky
  0 siblings, 0 replies; 9+ messages in thread
From: Sven Wischnowsky @ 1999-10-18  6:59 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> PWS says in http://www.ifh.de/~pws/computing/zshguide02.html#l6
> 
>     Second aside for users of sh: you may remember that tests in sh used
>     a single pair of brackets, `if [ ... ]; then ...', or equivalently
>     as a command called test, `if test ...; then ...'. The Korn shell
>     was deliberately made to be different, and zsh follows that. The
>     reason is that `[[' is treated specially, which allows the shell to
>     do some extra checks and allows more natural syntax.

Here on zsh-workers we could probably say what the real difference is: 
the parser knows about `[[ .. ]]' which should allow for faster
execution (I guess this is what Peter meant by `treated specially').
`[ .. ]' can only be handled as a normal builtin.

Bye
 Sven


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


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

end of thread, other threads:[~1999-10-18  6:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-10-15 12:10 PATCH: _urls again (Re: setopt localoptions noautoremoveslash) Sven Wischnowsky
1999-10-15 15:30 ` Oliver Kiddle
     [not found]   ` <991015155008.ZM24081@candle.brasslantern.com>
1999-10-15 16:05     ` Oliver Kiddle
1999-10-15 16:40       ` Bart Schaefer
1999-10-15 16:54         ` _urls ... and CVS Adam Spiers
1999-10-16  5:18           ` Tanaka Akira
1999-10-16 13:56   ` PATCH: _urls again (Re: setopt localoptions noautoremoveslash) Tanaka Akira
1999-10-16 15:33     ` "[[" (Re: PATCH: _urls again (Re: setopt localoptions noautoremoveslash)) Bart Schaefer
1999-10-18  6:59 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).