zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: _look
@ 2000-05-05 11:31 Tanaka Akira
  0 siblings, 0 replies; 2+ messages in thread
From: Tanaka Akira @ 2000-05-05 11:31 UTC (permalink / raw)
  To: zsh-workers

This is a completion function for `look'.  It calls `look' itself to
find completions.

Apart from that, I found that some functions using a state of
_arguments such as _gzip declare `curcontext' instead of `context'
which is specified by zshcompsys(1).  Is `curcontext' obsolete?

--- /dev/null	Wed May  6 05:32:27 1998
+++ Completion/User/_look	Fri May  5 18:46:17 2000
@@ -0,0 +1,18 @@
+#compdef look
+
+local context state line
+typeset -A opt_args
+
+_arguments -s \
+  '-t+[termination character]:termination character:' \
+  '-f[case insensitive]' \
+  '-d[dictionary order]' \
+  ':string:->string'
+
+case "$state" in
+string)
+  if [[ -n "$PREFIX" ]]; then
+    compadd - $(_call values $words[1] $PREFIX)
+  fi
+  ;;
+esac
-- 
Tanaka Akira


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

* Re: PATCH: _look
@ 2000-05-05 11:55 Sven Wischnowsky
  0 siblings, 0 replies; 2+ messages in thread
From: Sven Wischnowsky @ 2000-05-05 11:55 UTC (permalink / raw)
  To: zsh-workers


Tanaka Akira wrote:

> This is a completion function for `look'.  It calls `look' itself to
> find completions.
> 
> Apart from that, I found that some functions using a state of
> _arguments such as _gzip declare `curcontext' instead of `context'
> which is specified by zshcompsys(1).  Is `curcontext' obsolete?

No. Functions should either

- Call _arguments as in _gzip, make `context' local and in the
  state-handling make sure that $context is used in the argument field 
  of the context name. This is what functions like _tags do when given 
  the -C option, so:

    local context state line
    typeset -A opt_args

    _arguments '...:->foo' && return 0

    if [[ "$state" = foo ]]; then
      _tags -C "$context"
      ...
    fi

  (That `&& return 0' is missing in _gzip, too.)
  Actually, $state and $context nowadays are arrays, because
  _arguments may return more than one state, but that's only possible
  if the specs make it possible that more than one argument may be
  completed in some place.

- Call _arguments with the -C option and then make `curcontext' local, 
  initialising it to itself, as is done in _gzip. In that case
  _arguments will modify $curcontext without making it local to itself 
  so that the state-handling code doesn't need to care about setting
  up the context. Of course, this only works if only one state can be
  returned by _arguments. This was the case for all completion
  functions when I added the multi-state handling to _arguments.

In other words, there is a `-C' missing in _gzip (and probably in
other functions?).

Bye
 Sven


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


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

end of thread, other threads:[~2000-05-05 11:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-05 11:31 PATCH: _look Tanaka Akira
2000-05-05 11:55 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).