Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: completion files sensitive to user options like RC_QUOTES



Bart wrote:
> There would be a case for wrapping the "eval" expressions in _expand
> with temporary restoration of $_comp_caller_options, because of the
> effects of NO_ksharrays etc.  There might be a few other similar
> situations.

Yes:
  var=yyyyy
  setopt histsubstpattern
  : ${var:s/y*/X}<tab> → yyyyy

Similar problems for kshglob, norcexpandparam and others
For csh_junkie_quotes, it looks like the completion internals aren't
handling it anyway.

To restore $_comp_caller_options it is still best to limit the range of
options. Is there a simple way to restore it for that matter, best I can
come up with is the following which ends up duplicating the selection of
options.

optkeys=( ${(k)options[(I)(${(@~j.|.)_comp_options#NO_})]} )
set ${${${(v)options[(I)(${(@~j.|.)_comp_options#NO_})]:/on/-o}:/off/+o}:^optkeys}

> We have the "sticky emulation" mechanism.  Entry to completion could
> save the current option state before invoking the user-defined code,
> and then compadd could temporarily revert to that saved state.

Internally to the C code it needn't really use the sticky emulation
feature. Judging from a grep of the source, there's about a dozen
options that should perhaps have their values saved on entry to the
completion widgets with the code then checking those saved values
instead of the current state.

> On a side note, maybe we need a special keyword for "emulate" that
> means "make sticky whatever the current options are" -- right now
> you would have to spell that out explicitly, relative to some base
> emulation such as zsh or sh.

How about some way to create a custom emulation. So _main_complete does
something like:
  emulate -C _useropts
Then, wherever we need to, we can use sticky emulation to get the user's
setup:
  emulate _useropts -c 'var=( $expn )'
Is a pity we have to quote everything to -c.

The first feature could use current options as the default base but
allow something like:
  emulate -C bash sh -o kshglob +o shglob -o braceexpand

Oliver



Messages sorted by: Reverse Date, Date, Thread, Author