On Tue, Jul 4, 2023 at 12:06 AM Marlon Richert wrote: > > Perhaps then at least add documentation for _shadow to compsys.yo? I did that the other day (7/26, ChangeLog "unposted (cf. 51899): Doc/Zsh/compsys.yo: document _shadow") and after reading my own documentation, decided I didn't like what it said. Consequently I've produced the attached patch. The most significant visible change is that _unshadow no longer requires any arguments (and ignores any that it gets), instead it just unwinds anything done by the most recent previous call to _shadow. This includes a special case for more than one call to _shadow with the same -s suffix argument, removing my objection to Marlon's _approximate patch in workers/51861. On Thu, Jun 15, 2023 at 7:29 AM Marlon Richert wrote: > > I would find _shadow useful in my own Zsh code, too, not just completions. How > about moving it from Completion/ to Functions/? To address this, this patch adds Functions/Misc/mkshadow, which defines wrappers around _shadow and _unshadow. Although I didn't explicitly mention the reasoning in the doc, these are "nofork-ready" in that they return the suffix in $REPLY, so once those patches are applied one can do local suffix=${| mkshadow ... } This is actually implemented via _shadow except that it won't clobber an existing $REPLY whereas mkshadow unsets REPLY on the way in. Other changes under the hood: * Use namespaces for the global variables used to track state * Keep track of whether the shadowed command is a function, builtin, or external, so that the placeholder "command@suffix" function is consistently created/removed * Handle many pathological cases such as wanting to shadow the "-" precommand modifier (although there's still no way to fully duplicate the precommand behavior) And, update the doc for all of this.