* [PATCH] Let 'extra-verbose' completion show alias values
@ 2021-05-28 22:02 Marlon Richert
2021-06-07 22:27 ` Lawrence Velázquez
0 siblings, 1 reply; 6+ messages in thread
From: Marlon Richert @ 2021-05-28 22:02 UTC (permalink / raw)
To: Zsh hackers list
[-- Attachment #1: Type: text/plain, Size: 16 bytes --]
See attachment.
[-- Attachment #2: 0001-Let-extra-verbose-completion-show-alias-values.txt --]
[-- Type: text/plain, Size: 7165 bytes --]
From 5743dc5ef34e94944ff0de7929f261f5d1d8b0d8 Mon Sep 17 00:00:00 2001
From: Marlon Richert <marlon.richert@gmail.com>
Date: Sat, 29 May 2021 00:56:02 +0300
Subject: [PATCH] Let 'extra-verbose' completion show alias values
---
Completion/Base/Completer/_expand_alias | 3 +-
Completion/Zsh/Command/_disable | 6 ++--
Completion/Zsh/Command/_enable | 6 ++--
Completion/Zsh/Type/_aliases | 40 +++++++++++++++----------
Completion/Zsh/Type/_command_names | 2 +-
Test/Y01completion.ztst | 23 ++++++++++++++
6 files changed, 55 insertions(+), 25 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/Completion/Zsh/Command/_disable b/Completion/Zsh/Command/_disable
index 52b82a6e9..2dceeb6c8 100644
--- a/Completion/Zsh/Command/_disable
+++ b/Completion/Zsh/Command/_disable
@@ -2,15 +2,13 @@
local -a ali_arr sali_arr func_arr
-ali_arr=(${(k)aliases} ${(k)galiases})
-sali_arr=(${(k)saliases})
func_arr=(${(k)functions})
_arguments -C -s -A "-*" -S \
- "(-f -r -s -p)-a[act on regular or global aliases]:*:regular or global aliases:compadd -k ali_arr" \
+ "(-f -r -s -p)-a[act on regular or global aliases]:*:regular or global aliases:_aliases -s rg" \
"(-a -r -s -p)-f[act on functions]:*:functions:compadd -k func_arr" \
"(-a -f -s -p)-r[act on reserved words]:*:reserved-words:compadd -k reswords" \
- "(-a -f -r -p)-s[act on suffix aliases]:*:suffix aliases:compadd -k sali_arr" \
+ "(-a -f -r -p)-s[act on suffix aliases]:*:suffix aliases:_aliases -s s" \
"(-a -f -r -s)-p[act on pattern characters]:*:pattern characters:compadd -k patchars" \
'-m[treat arguments as patterns]' \
"*:builtin command:(${(k)builtins})"
diff --git a/Completion/Zsh/Command/_enable b/Completion/Zsh/Command/_enable
index 9410651b7..53a9e36db 100644
--- a/Completion/Zsh/Command/_enable
+++ b/Completion/Zsh/Command/_enable
@@ -2,15 +2,13 @@
local -a ali_arr sali_arr func_arr
-ali_arr=(${(k)dis_aliases} ${(k)dis_galiases})
-sali_arr=(${(k)dis_saliases})
func_arr=(${(k)dis_functions})
_arguments -C -s -A "-*" -S \
- "(-f -r -s -p)-a[act on regular or global aliases]:*:aliases:compadd -k ali_arr" \
+ "(-f -r -s -p)-a[act on regular or global aliases]:*:regular or global aliases:_aliases -s RG" \
"(-a -r -s -p)-f[act on functions]:*:functions:compadd -k func_arr" \
"(-a -f -s -p)-r[act on reserved words]:*:reserved-words:compadd -k dis_reswords" \
- "(-a -f -r -p)-s[act on suffix aliases]:*:suffix aliases:compadd -k sali_arr" \
+ "(-a -f -r -p)-s[act on suffix aliases]:*:suffix aliases:_aliases -s S" \
"(-a -f -r -s)-p[act on pattern characters]:*:pattern characters:compadd -k dis_patchars" \
'-m[treat arguments as patterns]' \
"*:builtin command:(${(k)dis_builtins})"
diff --git a/Completion/Zsh/Type/_aliases b/Completion/Zsh/Type/_aliases
index 6506ece13..c4d5abac1 100644
--- a/Completion/Zsh/Type/_aliases
+++ b/Completion/Zsh/Type/_aliases
@@ -1,19 +1,29 @@
#compdef unalias
-local expl sel args opts
+_aliases_add() {
+ if zstyle -t ":completion:${curcontext}:$2" extra-verbose; then
+ local -a items=()
+ printf -v items "%s\:%s" "${(@q)${(@kvq)${(PAA)1}}}"
+ args+=( "${2}:${3}:(( ${items:#'\:'} ))" )
+ else
+ args+=( "${2}:${3}:compadd -k $1" )
+ fi
+}
-zparseopts -E -D s:=sel
+_aliases() {
+ local -a args=() sel=( -s rgs )
+ zparseopts -D -E -K s:=sel
+ shift sel
+ case $sel in
+ ( *r* ) _aliases_add aliases aliases 'regular alias' ;|
+ ( *g* ) _aliases_add galiases global-aliases 'global alias' ;|
+ ( *s* ) _aliases_add saliases suffix-aliases 'suffix alias' ;|
+ ( *R* ) _aliases_add dis_aliases disabled-aliases 'disabled regular alias' ;|
+ ( *G* ) _aliases_add dis_galiases disabled-global-aliases 'disabled global alias' ;|
+ ( *S* ) _aliases_add dis_saliases disabled-suffix-aliases 'disabled suffix alias' ;|
+ esac
+ local -a opts=( "$@" )
+ _alternative -O opts "$args[@]"
+}
-[[ -z $sel ]] && sel=rgs
-
-opts=( "$@" )
-
-args=()
-[[ $sel = *r* ]] && args=( $args 'aliases:regular alias:compadd -k aliases' )
-[[ $sel = *g* ]] && args=( $args 'global-aliases:global alias:compadd -k galiases' )
-[[ $sel = *s* ]] && args=( $args 'suffix-aliases:suffix alias:compadd -k saliases' )
-[[ $sel = *R* ]] && args=( $args 'disabled-aliases:disabled regular alias:compadd -k dis_aliases' )
-[[ $sel = *G* ]] && args=( $args 'disabled-global-aliases:disabled global alias:compadd -k dis_galiases' )
-[[ $sel = *S* ]] && args=( $args 'disabled-suffix-aliases:disabled suffix alias:compadd -k dis_saliases' )
-
-_alternative -O opts $args
+_aliases "$@"
diff --git a/Completion/Zsh/Type/_command_names b/Completion/Zsh/Type/_command_names
index b1c35f013..874c564a4 100644
--- a/Completion/Zsh/Type/_command_names
+++ b/Completion/Zsh/Type/_command_names
@@ -29,7 +29,7 @@ else
defs=( "$defs[@]"
'builtins:builtin command:compadd -Qk builtins'
"functions:shell function:compadd -k 'functions$ffilt'"
- 'aliases:alias:compadd -Qk aliases'
+ 'aliases:alias:_aliases -s r'
'suffix-aliases:suffix alias:_suffix_alias_files'
'reserved-words:reserved word:compadd -Qk reswords'
'jobs:: _jobs -t'
diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst
index 882a0adc4..ae5b15204 100644
--- a/Test/Y01completion.ztst
+++ b/Test/Y01completion.ztst
@@ -286,6 +286,29 @@ F:regression test workers/31611
>NO:{bat}
>NO:{bay}
+ comptesteval "alias tst1='\tst1 tst2'; alias -g tst2=; alias -s tst3=tst3"
+ comptesteval 'zstyle ":completion:*:*aliases" extra-verbose yes'
+ comptest $'unalias tst\t'
+0:extra-verbose shows alias values
+>line: {unalias tst}{}
+>DESCRIPTION:{regular alias}
+>NO:{tst1 -- \tst1 tst2}
+>DESCRIPTION:{global alias}
+>NO:{tst2 -- ''}
+>DESCRIPTION:{suffix alias}
+>NO:{tst3 -- tst3}
+
+ comptesteval 'zstyle -d ":completion:*:*aliases" extra-verbose'
+ comptest $'unalias tst\t'
+0:alias values not shown without extra-verbose
+>line: {unalias tst}{}
+>DESCRIPTION:{regular alias}
+>NO:{tst1}
+>DESCRIPTION:{global alias}
+>NO:{tst2}
+>DESCRIPTION:{suffix alias}
+>NO:{tst3}
+
comptesteval '_tst() { local disp=( {a..z} ); compadd -ld disp $disp[@]; comppostfuncs=( _pst ) }'
comptesteval '_pst() { local disp=( "<INSERT>$compstate[insert]</INSERT>" ); compadd -Qld disp $disp }'
comptesteval "zstyle ':completion:*' menu select=long-list"
--
2.30.1 (Apple Git-130)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Let 'extra-verbose' completion show alias values
2021-05-28 22:02 [PATCH] Let 'extra-verbose' completion show alias values Marlon Richert
@ 2021-06-07 22:27 ` Lawrence Velázquez
2021-06-08 20:11 ` Bart Schaefer
0 siblings, 1 reply; 6+ messages in thread
From: Lawrence Velázquez @ 2021-06-07 22:27 UTC (permalink / raw)
To: zsh-workers; +Cc: Marlon Richert
On Fri, May 28, 2021, at 6:02 PM, Marlon Richert wrote:
> See attachment.
>
> Attachments:
> * 0001-Let-extra-verbose-completion-show-alias-values.txt
Any feedback on this?
--
vq
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Let 'extra-verbose' completion show alias values
2021-06-07 22:27 ` Lawrence Velázquez
@ 2021-06-08 20:11 ` Bart Schaefer
2021-06-09 13:27 ` Marlon Richert
0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2021-06-08 20:11 UTC (permalink / raw)
To: Lawrence Velázquez; +Cc: Zsh hackers list, Marlon Richert
On Mon, Jun 7, 2021 at 3:29 PM Lawrence Velázquez <larryv@zsh.org> wrote:
>
> On Fri, May 28, 2021, at 6:02 PM, Marlon Richert wrote:
> > See attachment.
> >
> > Attachments:
> > * 0001-Let-extra-verbose-completion-show-alias-values.txt
>
> Any feedback on this?
I'm probably not going to take responsibility for committing this, but:
If you do NOT have { zstyle ':completion:*' group-name '' } this
behaves a bit oddly. External, builtin, and alias are all grouped
together, causing strange layout (the descriptions line up for
everything but the alias):
valgrind -- a suite of tools for debugging and profiling programs
valgrind.bin -- a suite of tools for debugging and profiling programs
valgrind-di-server -- Experimental debuginfo server for valgrind
valgrind-listener -- listens on a socket for Valgrind commentary
vared -- noglob vared
vdir -- list directory contents
vftovp -- convert virtual font (vf) files to virtual property li...
vgdb -- intermediary between Valgrind and GDB or a shell
(etc.)
Also the set of names is not unique-ified, so if "vared" is an alias
(as in my test case) it also re-appears in the multi-column listing of
external commands because of the presence of the vared function in the
fpath. Both of these issues go away with group-name styled.
I have no opinion on whether these effects are significant enough to
be in need of repair, just making mention.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Let 'extra-verbose' completion show alias values
2021-06-08 20:11 ` Bart Schaefer
@ 2021-06-09 13:27 ` Marlon Richert
2021-07-18 23:13 ` Lawrence Velázquez
0 siblings, 1 reply; 6+ messages in thread
From: Marlon Richert @ 2021-06-09 13:27 UTC (permalink / raw)
To: Bart Schaefer; +Cc: Lawrence Velázquez, Zsh hackers list
On Tue, Jun 8, 2021 at 11:11 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> On Mon, Jun 7, 2021 at 3:29 PM Lawrence Velázquez <larryv@zsh.org> wrote:
> >
> > On Fri, May 28, 2021, at 6:02 PM, Marlon Richert wrote:
> > > See attachment.
> > >
> > > Attachments:
> > > * 0001-Let-extra-verbose-completion-show-alias-values.txt
> >
> > Any feedback on this?
>
> I'm probably not going to take responsibility for committing this, but:
>
> If you do NOT have { zstyle ':completion:*' group-name '' } this
> behaves a bit oddly. External, builtin, and alias are all grouped
> together, causing strange layout (the descriptions line up for
> everything but the alias):
>
> valgrind -- a suite of tools for debugging and profiling programs
> valgrind.bin -- a suite of tools for debugging and profiling programs
> valgrind-di-server -- Experimental debuginfo server for valgrind
> valgrind-listener -- listens on a socket for Valgrind commentary
> vared -- noglob vared
> vdir -- list directory contents
> vftovp -- convert virtual font (vf) files to virtual property li...
> vgdb -- intermediary between Valgrind and GDB or a shell
> (etc.)
>
> Also the set of names is not unique-ified, so if "vared" is an alias
> (as in my test case) it also re-appears in the multi-column listing of
> external commands because of the presence of the vared function in the
> fpath. Both of these issues go away with group-name styled.
>
> I have no opinion on whether these effects are significant enough to
> be in need of repair, just making mention.
This also happens if you have extra-verbose but no group-name and you
get both command & parameter completions in the same list:
% v
vared -- vared
vim -- Vi IMproved, a programmer's text editor
vim -- vim
vimdiff -- edit two, three or four versions of a file with Vim and
show differences
vimtutor -- the Vim tutor
vis -- display non-printable characters in a visual format
vm_stat -- show Mach virtual memory statistics
vmmap -- Display the virtual memory regions allocated in a process
vtool -- Mach-O version number utility
vared venc_data_dump vi view visualinfo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Let 'extra-verbose' completion show alias values
2021-06-09 13:27 ` Marlon Richert
@ 2021-07-18 23:13 ` Lawrence Velázquez
2021-07-28 3:26 ` Bart Schaefer
0 siblings, 1 reply; 6+ messages in thread
From: Lawrence Velázquez @ 2021-07-18 23:13 UTC (permalink / raw)
To: zsh-workers; +Cc: Marlon Richert
On Wed, Jun 9, 2021, at 9:27 AM, Marlon Richert wrote:
> On Tue, Jun 8, 2021 at 11:11 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
> > I'm probably not going to take responsibility for committing this, but:
> >
> > If you do NOT have { zstyle ':completion:*' group-name '' } this
> > behaves a bit oddly. External, builtin, and alias are all grouped
> > together, causing strange layout (the descriptions line up for
> > everything but the alias):
> >
> > valgrind -- a suite of tools for debugging and profiling programs
> > valgrind.bin -- a suite of tools for debugging and profiling programs
> > valgrind-di-server -- Experimental debuginfo server for valgrind
> > valgrind-listener -- listens on a socket for Valgrind commentary
> > vared -- noglob vared
> > vdir -- list directory contents
> > vftovp -- convert virtual font (vf) files to virtual property li...
> > vgdb -- intermediary between Valgrind and GDB or a shell
> > (etc.)
> >
> > Also the set of names is not unique-ified, so if "vared" is an alias
> > (as in my test case) it also re-appears in the multi-column listing of
> > external commands because of the presence of the vared function in the
> > fpath. Both of these issues go away with group-name styled.
> >
> > I have no opinion on whether these effects are significant enough to
> > be in need of repair, just making mention.
>
> This also happens if you have extra-verbose but no group-name and you
> get both command & parameter completions in the same list:
>
> % v
> vared -- vared
> vim -- Vi IMproved, a programmer's text editor
> vim -- vim
> vimdiff -- edit two, three or four versions of a file with Vim and
> show differences
> vimtutor -- the Vim tutor
> vis -- display non-printable characters in a visual format
> vm_stat -- show Mach virtual memory statistics
> vmmap -- Display the virtual memory regions allocated in a process
> vtool -- Mach-O version number utility
> vared venc_data_dump vi view visualinfo
Any other feedback on 48947?
--
vq
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-07-28 3:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-28 22:02 [PATCH] Let 'extra-verbose' completion show alias values Marlon Richert
2021-06-07 22:27 ` Lawrence Velázquez
2021-06-08 20:11 ` Bart Schaefer
2021-06-09 13:27 ` Marlon Richert
2021-07-18 23:13 ` Lawrence Velázquez
2021-07-28 3:26 ` Bart Schaefer
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).