zsh-workers
 help / color / mirror / code / Atom feed
* compadd option passing (Re: Completion function for bitkeeper?)
       [not found]                     ` <29608.1069237406@gmcs3.local>
@ 2003-11-19 17:18                       ` Bart Schaefer
  2003-12-05 11:08                         ` Oliver Kiddle
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Schaefer @ 2003-11-19 17:18 UTC (permalink / raw)
  To: zsh-workers

[redirected to zsh-workers]

On Nov 19, 11:23am, Oliver Kiddle wrote:
}
} I agree that it isn't ideal. The best alternative I can think of would
} be to pass compadd options to the various tag handling functions
} instead of the completion functions.

That makes it harder for people writing simple completion functions to
make use of the compadd options, though.  Maybe that never comes up, but
it seems an unnecessary limitation.

I suggest instead that we choose a single option (or other syntactic
marker) that is documented as being passed to completion functions to
delimit the compadd options from the any options of the function itself.
E.g. soemthing like "everything between -o and a bare '-' is a compadd
option":

	completion_func ... -o compadd options here - ...

That specific suggestion probably won't work because a hyphen may appear
as an argument to -S or -P or -r etc., but you get the idea.

Alternately always pass the compadd options in an array parameter, and
use such a "reserved option" of completion_func to specify the name of
that parameter:

	compaddopts=( ... )
	completion_func ... -o compaddopts ...

In either of the above scenarios, completion functions can avoid name
clashes by extracting the -o option with zparseopts and storing the
resuting array in a local before declaring any other locals whose names
might conflict.  The docs could include sample code for this that could
be cut'n'pasted into new completion functions.


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

* Re: compadd option passing (Re: Completion function for bitkeeper?)
  2003-11-19 17:18                       ` compadd option passing (Re: Completion function for bitkeeper?) Bart Schaefer
@ 2003-12-05 11:08                         ` Oliver Kiddle
  0 siblings, 0 replies; 2+ messages in thread
From: Oliver Kiddle @ 2003-12-05 11:08 UTC (permalink / raw)
  To: zsh-workers

I sent this two weeks ago and just realised that it never turned up on
the mailing list.

Bart wrote:

> } I agree that it isn't ideal. The best alternative I can think of would
> } be to pass compadd options to the various tag handling functions
> } instead of the completion functions.
> 
> That makes it harder for people writing simple completion functions to
> make use of the compadd options, though.  Maybe that never comes up, but
> it seems an unnecessary limitation.

True. But it could help other issues by doing more of the hard work
with picking out suffixes and descriptions and passing on only the
right stuff. Auto-removable suffixes especially stand to benefit if we
can store them at each stage. It needs a lot more thought though. 

> I suggest instead that we choose a single option (or other syntactic
> marker) that is documented as being passed to completion functions to
> delimit the compadd options from the any options of the function itself.
> E.g. soemthing like "everything between -o and a bare '-' is a compadd
> option":

> Alternately always pass the compadd options in an array parameter, and

Either do avoid name clashes but, to be honest, with all of this I think
either of those solutions are uglier than the situation we have at the
moment.

If we really want to clear it up in such a way, How about a
single `-' argument be defined as the start of (or end of?) compadd
options.

So you have to use for example.
  _sccs_files -e - -X 'sccs file'

If there is no `-' argument, it can assume that all options are compadd
options (which will be most function calls anyway).

_all_labels already looks for `-' in deciding where to put compadd
options so it'd also be the easiest to implement.

A possibility included in this is that we only do anything special for
`-' in _arguments actions (to clear up our initial space vs. { ... }
confusion).

Oliver


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

end of thread, other threads:[~2003-12-05 11:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20031106153225.GA491@lorien.emufarm.org>
     [not found] ` <1281.1068232665@athlon>
     [not found]   ` <20031110182013.GA20547@lorien.emufarm.org>
     [not found]     ` <9219.1068538977@gmcs3.local>
     [not found]       ` <20031111162338.GD23138@lorien.emufarm.org>
     [not found]         ` <901.1068577572@athlon>
     [not found]           ` <20031111212828.GA28125@lorien.emufarm.org>
     [not found]             ` <29114.1068797096@gmcs3.local>
     [not found]               ` <20031114154608.GA6959@lorien.emufarm.org>
     [not found]                 ` <15744.1069084060@gmcs3.local>
     [not found]                   ` <20031117175151.GA24060@lorien.emufarm.org>
     [not found]                     ` <29608.1069237406@gmcs3.local>
2003-11-19 17:18                       ` compadd option passing (Re: Completion function for bitkeeper?) Bart Schaefer
2003-12-05 11:08                         ` Oliver Kiddle

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