From 7722347b8e408413f7b49af5e16b1b4a518c1aa9 Mon Sep 17 00:00:00 2001 From: Marlon Richert Date: Sat, 29 May 2021 00:16:22 +0300 Subject: [PATCH] Make _expand_alias more usable as a completer When _expand_alias is invoked as a completer, if 'complete' is set to 'true', let _expand_alias always return 1. This is analogous to how this style behaves when _expand_alias is invoked as a widget or when the _expand completer's 'accept-exact' style is set to 'continue', which allows you to put it at the start of the 'completer' list. Additionally, tag alias expansions as 'expansions', rather than as 'aliases', to prevent aliases & alias expansion from being lumped into the same group. --- Completion/Base/Completer/_expand_alias | 3 ++- Doc/Zsh/compsys.yo | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Completion/Base/Completer/_expand_alias b/Completion/Base/Completer/_expand_alias index 8240e4162..275da157c 100644 --- a/Completion/Base/Completer/_expand_alias +++ b/Completion/Base/Completer/_expand_alias @@ -59,7 +59,8 @@ if [[ -n $tmp ]]; then fi fi zstyle -T ":completion:${curcontext}:" add-space || suf=( -S '' ) - $pre _wanted aliases expl alias compadd -UQ "$suf[@]" -- ${tmp%%[[:blank:]]##} + $pre _wanted expansions expl expansion compadd -UQ "$suf[@]" -- ${tmp%%[[:blank:]]##} && + ! zstyle -t ":completion:${curcontext}:" complete elif (( $#pre )) && zstyle -t ":completion:${curcontext}:" complete; then $pre _aliases -s "$sel" -S '' else diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index 89b918d60..1b01f09a8 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -1295,10 +1295,12 @@ the two strings `tt(start)' and `tt(stop)'. ) kindex(complete, completion style) item(tt(complete))( -This is used by the tt(_expand_alias) function when invoked as a -bindable command. If set to `true' and the word on the command -line is not the name of an alias, matching alias names will be -completed. +This is used by the tt(_expand_alias) function. When tt(_expand_alias) is +invoked as a bindable command, if tt(complete) is set to `true' and the word on +the command line is not the name of an alias, matching alias names will be +completed. When tt(_expand_alias) is invoked as a completer, if tt(complete) is +set to `true', tt(_expand_alias) will add the expansion as a match and the +completion system will also be allowed to continue. ) kindex(complete-options, completion style) item(tt(complete-options))( -- 2.30.1 (Apple Git-130)