zsh-workers
 help / color / mirror / code / Atom feed
* _urls -f
@ 2001-12-11 17:17 Oliver Kiddle
  2001-12-11 17:28 ` Clint Adams
  2001-12-12  4:34 ` Tanaka Akira
  0 siblings, 2 replies; 5+ messages in thread
From: Oliver Kiddle @ 2001-12-11 17:17 UTC (permalink / raw)
  To: zsh-workers

I don't like the behaviour of _urls -f in that it completes files before
urls without letting you define a style to complete both together or
urls first.

The patch below is what I would suggest here. Note that _urls is not
called with -f from anywhere other than _webbrowser and anything which
did could always call _webbrowser directly instead anyway (_netscape may
have to).

Any user preferring the current behaviour could get it back with a
style. e.g:
    zstyle ':completion::complete:galeon:*' tag-order files urls

Any views?

Oliver

Index: Completion/Unix/Command/_webbrowser
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_webbrowser,v
retrieving revision 1.2
diff -u -r1.2 _webbrowser
--- Completion/Unix/Command/_webbrowser	2001/10/08 16:22:40	1.2
+++ Completion/Unix/Command/_webbrowser	2001/12/11 17:14:51
@@ -1,3 +1,3 @@
-#compdef amaya arena chimera express grail gzilla hotjava mmm mozilla opera www xmosaic Mosaic galeon
+#compdef amaya arena chimera express grail gzilla hotjava mmm mozilla opera www xmosaic Mosaic galeon konqueror
 
-_urls -f
+_alternative 'files:file:_files' 'urls:url:_urls'
Index: Completion/Unix/Type/_urls
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_urls,v
retrieving revision 1.2
diff -u -r1.2 _urls
--- Completion/Unix/Type/_urls	2001/10/08 16:22:40	1.2
+++ Completion/Unix/Type/_urls	2001/12/11 17:14:51
@@ -1,9 +1,5 @@
 #compdef curl
 
-# Usage: _urls [-f]
-# Options:
-#  -f : complete files first.
-#
 # Configuration styles used:
 #
 #  urls
@@ -48,11 +44,6 @@
 local localhttp_documentroot="$localhttp[2]"
 local localhttp_userdir="$localhttp[3]"
 
-if [[ "$1" = -f ]]; then
-  shift
-  _wanted -C -f files expl file _files "$@" && return 0
-fi
-
 zstyle -a ":completion:${curcontext}:urls" urls urls
 
 if [[ $#urls -gt 1 || ( $#urls -eq 1 && ! -d $urls[1] ) ]]; then
@@ -134,7 +125,7 @@
 
   _tags hosts
   while _tags; do
-    while _next_label hosts expl host "$@"; do
+    while _next_label hosts expl host; do
       compset -S '[:/]*' || suf="/"
       (( $#uhosts )) || _hosts -S "$suf" -r '/:' "$expl[@]" && ret=0
       [[ "$scheme" = http ]] && uhosts=($uhosts $localhttp_servername)

_____________________________________________________________________
This message has been checked for all known viruses by the 
MessageLabs Virus Scanning Service. For further information visit
http://www.messagelabs.com/stats.asp


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

* Re: _urls -f
  2001-12-11 17:17 _urls -f Oliver Kiddle
@ 2001-12-11 17:28 ` Clint Adams
  2001-12-12  4:34 ` Tanaka Akira
  1 sibling, 0 replies; 5+ messages in thread
From: Clint Adams @ 2001-12-11 17:28 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: zsh-workers

> -#compdef amaya arena chimera express grail gzilla hotjava mmm mozilla opera www xmosaic Mosaic galeon
> +#compdef amaya arena chimera express grail gzilla hotjava mmm mozilla opera www xmosaic Mosaic galeon konqueror

gzilla has changed names to dillo.  One might want to include skipstone and
light, as well.


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

* Re: _urls -f
  2001-12-11 17:17 _urls -f Oliver Kiddle
  2001-12-11 17:28 ` Clint Adams
@ 2001-12-12  4:34 ` Tanaka Akira
  2001-12-12 11:24   ` Oliver Kiddle
  1 sibling, 1 reply; 5+ messages in thread
From: Tanaka Akira @ 2001-12-12  4:34 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: zsh-workers

In article <3C163FA6.BC9C1A66@yahoo.co.uk>,
  Oliver Kiddle <okiddle@yahoo.co.uk> writes:

> I don't like the behaviour of _urls -f in that it completes files before
> urls without letting you define a style to complete both together or
> urls first.

Agreed.  I think it was my fault.
-- 
Tanaka Akira


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

* Re: _urls -f
  2001-12-12  4:34 ` Tanaka Akira
@ 2001-12-12 11:24   ` Oliver Kiddle
  2002-01-07 14:37     ` Sven Wischnowsky
  0 siblings, 1 reply; 5+ messages in thread
From: Oliver Kiddle @ 2001-12-12 11:24 UTC (permalink / raw)
  To: Tanaka Akira; +Cc: zsh-workers

Tanaka Akira wrote:

>   Oliver Kiddle <okiddle@yahoo.co.uk> writes:
> > I don't like the behaviour of _urls -f in that it completes files before
> > urls without letting you define a style to complete both together or
> > urls first.
> 
> Agreed.  I think it was my fault.

Good, I'll apply that then. Here's the patch to make the same change
for netscape, links, lynx and w3m.

For netscape, a tag-order of urls before files doesn't seem to work
entirely so I think I'm still misunderstanding the tags stuff there
somewhere.

Oliver

Index: Completion/Unix/Command/_links
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_links,v
retrieving revision 1.1
diff -u -r1.1 _links
--- Completion/Unix/Command/_links	2001/08/22 21:37:00	1.1
+++ Completion/Unix/Command/_links	2001/12/12 11:22:08
@@ -24,8 +24,6 @@
        '-help' \
        ':url:->html' && return 0
 
-case "$state" in
-html)
-  _files -g '*.html' || _urls
-  ;;
-esac
+if [[ "$state" = html ]]; then
+  _alternative 'files:file:_files "*.html"' 'urls:url:_urls'
+fi
Index: Completion/Unix/Command/_lynx
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_lynx,v
retrieving revision 1.1
diff -u -r1.1 _lynx
--- Completion/Unix/Command/_lynx	2001/04/02 11:56:16	1.1
+++ Completion/Unix/Command/_lynx	2001/12/12 11:22:08
@@ -107,6 +107,6 @@
     outside_telnet print shell suspend telnet_port useragent
   ;;
 html)
-  _files -g '*.html' || _urls
+  _alternative 'files:file:_files "*.html"' 'urls:url:_urls'
   ;;
 esac
Index: Completion/Unix/Command/_w3m
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_w3m,v
retrieving revision 1.2
diff -u -r1.2 _w3m
--- Completion/Unix/Command/_w3m	2001/05/03 13:05:49	1.2
+++ Completion/Unix/Command/_w3m	2001/12/12 11:22:09
@@ -42,7 +42,7 @@
 	   compadd $_w3mhistory
 	fi
 
-	_urls || _files -g '*.html'
+	_alternative 'files:file:_files "*.html"' 'urls:url:_urls'
 	;;
 
 esac
Index: Completion/X/Command/_netscape
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/X/Command/_netscape,v
retrieving revision 1.1
diff -u -r1.1 _netscape
--- Completion/X/Command/_netscape	2001/04/02 12:14:25	1.1
+++ Completion/X/Command/_netscape	2001/12/12 11:22:09
@@ -24,9 +24,6 @@
   -{component-bar,composer,edit,messenger,mail,discussions,news} \
   '*:location:->urls' && ret=0
 
-[[ "$state" = "urls" ]] &&
-  _files "$@" && return 0
-
 # Handle netscape remote commands
 if [[ "$state" = "remote" ]]; then  
   local -a remote_commands
@@ -69,24 +66,31 @@
 fi
 
 if [[ "$state" = "urls" ]]; then
-  # Complete netscape urls
-  if compset -P about: ; then
-    _wanted values expl 'about what' \
-        compadd "$@" authors blank cache document fonts global hype image-cache \
-            license logo memory-cache mozilla plugins && ret=0
-  elif compset -P news: ; then
-    _newsgroups "$@" && ret=0
-  else
-    _tags prefixes
-    while _tags; do
-      while _next_label prefixes expl 'URL prefix' "$@"; do
-        _urls "$expl[@]" && ret=0
-	compset -S '[^:]*'
-        compadd -S '' "$expl[@]" about: news: mocha: javascript: && ret=0
-      done
-      (( ret )) || return 0
-    done
-  fi
+  _tags files urls
+  while _tags; do
+    _requested files expl 'file' _files "$@" && ret=0
+    if _requested urls; then
+      # Complete netscape urls
+      if compset -P about: ; then
+	_wanted values expl 'about what' \
+            compadd "$@" authors blank cache document fonts global hype \
+	    	image-cache license logo memory-cache mozilla plugins && ret=0
+      elif compset -P news: ; then
+	_newsgroups "$@" && ret=0
+      else
+	_tags prefixes
+	while _tags; do
+	  while _next_label prefixes expl 'URL prefix' "$@"; do
+            _urls "$expl[@]" && ret=0
+	    compset -S '[^:]*'
+            compadd -S '' "$expl[@]" about: news: mocha: javascript: && ret=0
+	  done
+	  (( ret )) || return 0
+	done
+      fi
+    fi
+    (( ret )) || return 0
+  done
 fi
 
 return ret

_____________________________________________________________________
This message has been checked for all known viruses by the 
MessageLabs Virus Scanning Service. For further information visit
http://www.messagelabs.com/stats.asp


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

* Re: _urls -f
  2001-12-12 11:24   ` Oliver Kiddle
@ 2002-01-07 14:37     ` Sven Wischnowsky
  0 siblings, 0 replies; 5+ messages in thread
From: Sven Wischnowsky @ 2002-01-07 14:37 UTC (permalink / raw)
  To: zsh-workers


Oliver Kiddle wrote:

> ...
> 
> For netscape, a tag-order of urls before files doesn't seem to work
> entirely so I think I'm still misunderstanding the tags stuff there
> somewhere.

The problem is that one can't use nested _tags-loops in the same
function because the C-code behind it has to keep some internal state
which would get messed up otherwise.

One solution is to re-initialise the outer _tags in the right place.
Another solution would be to move the code into its own little helper
function. The patch below does the former.

Bye
  Sven

Index: Completion/X/Command/_netscape
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/X/Command/_netscape,v
retrieving revision 1.3
diff -u -r1.3 _netscape
--- Completion/X/Command/_netscape	2002/01/02 14:45:22	1.3
+++ Completion/X/Command/_netscape	2002/01/07 14:38:33
@@ -1,6 +1,6 @@
 #compdef netscape
 
-local curcontext="$curcontext" state line ret=1 suf
+local curcontext="$curcontext" state line ret=1 suf files
 typeset -A opt_args
 
 _x_arguments -C \
@@ -68,7 +68,7 @@
 if [[ "$state" = "urls" ]]; then
   _tags files urls
   while _tags; do
-    _requested files expl 'file' _files "$@" && ret=0
+    _requested files expl 'file' _files "$@" && files=yes ret=0
     if _requested urls; then
       # Complete netscape urls
       if compset -P about: ; then
@@ -87,6 +87,7 @@
 	  done
 	  (( ret )) || return 0
 	done
+        [[ -z "$files" ]] && _tags files
       fi
     fi
     (( ret )) || return 0

-- 
Sven Wischnowsky                           wischnow@berkom.de


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

end of thread, other threads:[~2002-01-07 14:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-11 17:17 _urls -f Oliver Kiddle
2001-12-11 17:28 ` Clint Adams
2001-12-12  4:34 ` Tanaka Akira
2001-12-12 11:24   ` Oliver Kiddle
2002-01-07 14:37     ` 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).