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

Re: completion files sensitive to user options like RC_QUOTES



On Dec 7,  4:45am, Oliver Kiddle wrote:
} Subject: Re: completion files sensitive to user options like RC_QUOTES
}
} Bart wrote:
} > There would be a case for wrapping the "eval" expressions in _expand
} 
} 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

Just assign to $options?

  () {
    options=( "${(kv)_comp_caller_options[@]}" )
    setopt localoptions
    eval ...
  }

(But possibly even better below.)

} Internally to the C code it needn't really use the sticky emulation
} feature.

True; I just meant that we have working code for a similar situation,
which can be cannibalized.

} > On a side note, maybe we need a special keyword for "emulate" that
} > means "make sticky whatever the current options are"
} 
} How about some way to create a custom emulation.

Now that you suggest it, I realize you can do that already, because of
the way sticky emulations propagate.  To borrow your example:

  emulate sh -o kshglob +o shglob -o braceexpand -c \
    'emulate_bash() { eval "$*" }'

  emulate_bash 'show_bash_opts() { set -o }'

  show_bash_opts

You can prove this works by doing e.g.

  emulate zsh -c show_bash_opts

and noting that in spite of forcing zsh emulation outside, set -o prints
the bash options inside.

The missing bit is being able to snapshot the current state.  Which of
course you can also do with gymnastics on $options.

  emulate zsh -${(k)^options[(R)on]} +${(k)^options[(R)off]} -c \
    'emulate_useropts() { eval "$*" }'

And now Ray can shake his head some more at the emergent behavior ...



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