zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: Re: problem with _arguments
@ 2000-07-27  7:17 Sven Wischnowsky
  2000-07-27  8:10 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Sven Wischnowsky @ 2000-07-27  7:17 UTC (permalink / raw)
  To: zsh-workers


Adam Spiers wrote:

> I'm trying to write a very simple completion for a function, with the
> following requirements:
> 
>  - the function has one optional option '-l' with no parameter
>  - the first parameter can't be completed
>  - subsequent parameters are files
> 
> AFAICS from the docs, the completion function should be something
> like:
> 
> _foo () {
>   _arguments \
>     '-l[message for option]' \
>     ':description for first param: ' \
>     '*:description for files:_files'
> }
> 
> But with the latest CVS:
> 
> $ foo -<TAB>
> $ foo -
> ---- description for first param
> 
> What am I doing wrong, or is it a bug?

Au, verflucht. _main_complete forced listing when a _message was added 
and there were less than two matches. Unfortunately, it forced
message-only listing, so the option just wasn't shown.

The patch will make it show the message and the option, which is what
should have been done before. If this is good or if it should only
complete the option is a different question. Hm. Hm?

Bye
 Sven

Index: Completion/Core/_main_complete
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_main_complete,v
retrieving revision 1.37
diff -u -r1.37 _main_complete
--- Completion/Core/_main_complete	2000/07/13 11:04:00	1.37
+++ Completion/Core/_main_complete	2000/07/27 07:16:39
@@ -266,7 +266,7 @@
   fi
 elif [[ nm -le 1 && -n "$_comp_mesg" ]]; then
   compstate[insert]=''
-  compstate[list]='list force messages'
+  compstate[list]='list force'
 elif [[ nm -eq 0 && -z "$_comp_mesg" &&
         $#_lastdescr -ne 0 && $compstate[old_list] != keep ]] &&
      zstyle -s ":completion:${curcontext}:warnings" format format; then

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


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

* Re: PATCH: Re: problem with _arguments
  2000-07-27  7:17 PATCH: Re: problem with _arguments Sven Wischnowsky
@ 2000-07-27  8:10 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2000-07-27  8:10 UTC (permalink / raw)
  To: zsh-workers

On Jul 27,  9:17am, Sven Wischnowsky wrote:
}
} The patch will make it show the message and the option, which is what
} should have been done before. If this is good or if it should only
} complete the option is a different question. Hm. Hm?

Recalling that the original spec was:

 - the function has one optional option '-l' with no parameter
 - the first parameter can't be completed
 - subsequent parameters are files

I think _arguments has done the right thing, because any string other than
"-l" might just be a first parameter that happens to begin with hyphen.

However, if the spec had been "the first parameter must not begin with a
hyphen but cannot be completed" then I don't know how to express that in
the current _arguments syntax without using a state machine, which seems
like overkill in this situation.

-- 
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] 2+ messages in thread

end of thread, other threads:[~2000-07-27  8:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-27  7:17 PATCH: Re: problem with _arguments Sven Wischnowsky
2000-07-27  8:10 ` Bart Schaefer

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