On Wed, Jul 28, 2021 at 6:23 AM Bart Schaefer wrote: > > I think it's actually a bit weird to allow _expand_alias to work as a > completer at all, because the completion system generally functions > very badly when the matches do not consist of single words, and > aliases don't usually have one-word replacements. As soon as you > introduce something that contains spaces, completion gets very > confused (unless you force it directly into menu completion or > selection); if (otherwise) you attempt to press TAB twice to enter > menu completion, it'll instead start a new completion based on the > word after the rightmost space that is still to the left of the > cursor. This is especially true when using compadd -U. > > I suspect this may be where Oliver's tests and Marlon's attempt to > reproduce, went astray from one another. In any case, I'm fairly sure > this is the reason that _expand_alias (before the patch) does not > allow other completers to run, and similarly it's why the user is > admonished to place _expand before _complete in the zstyle. > > Looking independently at the two questions, my feeling is I'd avoid > the patch as-is, but it wouldn't be unreasonable for _expand to handle > aliases (under control of a zstyle). Alright, here's a new patch, which moves the alias expansion code from _expand_alias to _expand (and refactors it) and deprecates _expand_alias's use as a completer. I also updated the documentation and added tests. Note that I reused the zstyle names from _expand_alias in _alias. I think their names are less than optimal in _expand, but renaming them would break people's existing zstyle config for _expand_alias.