zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Make _expand_alias more usable as a completer
@ 2021-05-28 21:59 Marlon Richert
  2021-06-02 23:23 ` Oliver Kiddle
  0 siblings, 1 reply; 14+ messages in thread
From: Marlon Richert @ 2021-05-28 21:59 UTC (permalink / raw)
  To: Zsh hackers list

[-- Attachment #1: Type: text/plain, Size: 494 bytes --]

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.

[-- Attachment #2: 0001-Make-_expand_alias-more-usable-as-a-completer.txt --]
[-- Type: text/plain, Size: 2590 bytes --]

From 7722347b8e408413f7b49af5e16b1b4a518c1aa9 Mon Sep 17 00:00:00 2001
From: Marlon Richert <marlon.richert@gmail.com>
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)


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-05-11  7:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-28 21:59 [PATCH] Make _expand_alias more usable as a completer Marlon Richert
2021-06-02 23:23 ` Oliver Kiddle
2021-06-03 21:42   ` Marlon Richert
2021-06-20 19:49     ` Lawrence Velázquez
2021-06-20 21:08       ` Mikael Magnusson
2021-06-20 22:24         ` Marlon Richert
2021-07-18 23:34           ` Lawrence Velázquez
2021-07-28  3:23             ` Bart Schaefer
2021-08-01 18:50               ` [PATCH] Make _expand handle aliases (was Re: [PATCH] Make _expand_alias more usable as a completer) Marlon Richert
2022-03-31 22:35                 ` Lawrence Velázquez
2022-04-01  0:37                   ` Bart Schaefer
2022-05-06  5:57                     ` Marlon Richert
2022-05-07 20:39                       ` Bart Schaefer
2022-05-11  7:32                         ` Marlon Richert

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).