zsh-workers
 help / color / mirror / code / Atom feed
From: Marlon Richert <marlon.richert@gmail.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: [PATCH] Make _expand_alias more usable as a completer
Date: Sat, 29 May 2021 00:59:37 +0300	[thread overview]
Message-ID: <CAHLkEDvg5-vdd_AHeiR9-TstXUh2-5j9yQNDns1mC2qR3zM_Tw@mail.gmail.com> (raw)

[-- 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)


             reply	other threads:[~2021-05-28 22:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-28 21:59 Marlon Richert [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHLkEDvg5-vdd_AHeiR9-TstXUh2-5j9yQNDns1mC2qR3zM_Tw@mail.gmail.com \
    --to=marlon.richert@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).