zsh-workers
 help / color / mirror / code / Atom feed
From: Marlon <marlon.richert@gmail.com>
To: Oliver Kiddle <opk@zsh.org>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Feature Patch: Use completion to view parameter values
Date: Mon, 12 Apr 2021 23:22:55 +0300	[thread overview]
Message-ID: <E4631DCC-BAB2-4FA7-9373-008EC55E581F@gmail.com> (raw)
In-Reply-To: <18618-1617324651.844569@tLsN.0hLE.FeTt>

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


> On 2 Apr 2021, at 03:50, Oliver Kiddle <opk@zsh.org> wrote:
> 
> Following is a review of the patch:

Attached is a new version of the patch that hopefully addresses the concerns you raised. Please review.


> And, thanks. This looks useful.

Great, I’m happy to hear that. :)


—Marlon


[-- Attachment #2: 0001-Let-extra-verbose-completion-show-parameter-values.txt --]
[-- Type: text/plain, Size: 4489 bytes --]

From ddc538f39966abecca8938464e8b9cee82c56a43 Mon Sep 17 00:00:00 2001
From: Marlon Richert <marlon.richert@gmail.com>
Date: Mon, 12 Apr 2021 23:17:23 +0300
Subject: [PATCH] Let extra-verbose completion show parameter values

---
 Completion/Zsh/Type/_parameters | 44 ++++++++++++++++++++++-----------
 Test/Y01completion.ztst         | 29 +++++++++++++++++++++-
 2 files changed, 58 insertions(+), 15 deletions(-)

diff --git a/Completion/Zsh/Type/_parameters b/Completion/Zsh/Type/_parameters
index 207e5cf78..00c181e11 100644
--- a/Completion/Zsh/Type/_parameters
+++ b/Completion/Zsh/Type/_parameters
@@ -6,18 +6,39 @@
 # If you specify a -g option with a pattern, the pattern will be used to
 # restrict the type of parameters matched.
 
-local expl pattern fakes faked tmp i pfilt
-
 if compset -P '*:'; then
   _history_modifiers p
   return
 fi
 
-pattern=(-g \*)
+local MATCH i pfilt
+local -i MBEGIN MEND nm=$compstate[nmatches]
+local -a expl pattern=(-g \*) normal described verbose faked fakes tmp
+
+zstyle -t ":completion:${curcontext}:parameters" prefix-needed &&
+    [[ $PREFIX != [_.]* ]] &&
+        pfilt='[^_.]'
+_description parameters expl parameter
 zparseopts -D -K -E g:=pattern
 
-fakes=()
-faked=()
+if zstyle -t ":completion:${curcontext}:parameters" extra-verbose; then
+  described=(
+      "${(@M)${(@k)parameters[(R)$~pattern[2]~*(hideval|local|special)*]}:#$~pfilt*}"
+  )
+  compadd "$@" "$expl[@]" -D described -a - described
+  if (( $#described )); then
+    verbose=(
+        ${described[@]:/(#m)*/"${MATCH}:${(@q+)${(Pkv@q+)MATCH}//\\/\\\\}"} )
+    _describe -t parameters parameter verbose "$@" "$expl[@]"
+  fi
+
+  normal=(
+      "${(@M)${(@k)parameters[(R)$~pattern[2]~^(*(hideval|special)*)~*local*]}:#$~pfilt*}"
+  )
+else
+  normal=( "${(@M)${(@k)parameters[(R)$~pattern[2]~*local*]}:#$~pfilt*}" )
+fi
+
 if zstyle -a ":completion:${curcontext}:" fake-parameters tmp; then
   for i in "$tmp[@]"; do
     if [[ "$i" = *:* ]]; then
@@ -27,13 +48,8 @@ if zstyle -a ":completion:${curcontext}:" fake-parameters tmp; then
     fi
   done
 fi
+compadd "$@" "$expl[@]" - "$normal[@]" "${(@)fakes:|described}" \
+    "${(@)${(@)${(@M)faked:#${~pattern[2]}}%%:*}:|described}"
 
-zstyle -t ":completion:${curcontext}:parameters" prefix-needed && \
- [[ $PREFIX != [_.]* ]] && \
- pfilt='[^_.]'
-
-_wanted parameters expl parameter \
-    compadd "$@" -Q - \
-        "${(@M)${(@k)parameters[(R)${pattern[2]}~*local*]}:#${~pfilt}*}" \
-        "$fakes[@]" \
-        "${(@)${(@M)faked:#${~pattern[2]}}%%:*}"
+(( compstate[nmatches] > nm ))
+return 0
diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst
index 858fa7220..2c6d25d9a 100644
--- a/Test/Y01completion.ztst
+++ b/Test/Y01completion.ztst
@@ -240,7 +240,7 @@ F:regression test workers/31611
   comptesteval "zstyle ':completion:*:tst:*' ignored-patterns 2"
   comptest $'tst 1,\t'
   comptesteval "zstyle -d ':completion:*:tst:*' ignored-patterns"
-0:-F doesn't break _sequence
+0:-F does not break _sequence
 >line: {tst 1,}{}
 >DESCRIPTION:{desc}
 >NO:{2}
@@ -255,6 +255,33 @@ F:regression test workers/31611
 >FI:{file1}
 >FI:{file2}
 
+  comptesteval "bar=({$'\\0'..$'\\C-?'}); baz=\$bar"
+  comptesteval 'zstyle ":completion:*:parameters" extra-verbose yes'
+  comptesteval 'zstyle ":completion:*" fake-parameters bar baz:array'
+  comptest $': $ba\t'
+0:extra-verbose shows parameter values
+>line: {: $ba}{}
+>DESCRIPTION:{parameter}
+>NO:{bar  -- '^@' '^A' '^B' '^C' '^D' '^E' '^F' '^G' '^H' '\t' '\n' '^K' '^L' '^M}
+>NO:{baz  -- '^@ ^A ^B ^C ^D ^E ^F ^G ^H \t \n ^K ^L ^M ^N ^O ^P ^Q ^R ^S ^T ^U ^}
+
+  comptesteval "path=( $ZTST_srcdir:A )"
+  comptesteval 'typeset -H paths=HIDDEN'
+  comptest $': $path\t'
+0:extra-verbose doesn't show special or hidden parameter values
+>line: {: $path}{}
+>DESCRIPTION:{parameter}
+>NO:{path}
+>NO:{paths}
+
+  comptesteval 'zstyle -d ":completion:*:parameters" extra-verbose'
+  comptest $': $ba\t'
+0:parameter values not shown without extra-verbose
+>line: {: $ba}{}
+>DESCRIPTION:{parameter}
+>NO:{bar}
+>NO:{baz}
+
   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.31.0


  parent reply	other threads:[~2021-04-12 20:23 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-28 20:53 Marlon Richert
2021-03-29  7:39 ` Daniel Shahaf
2021-03-29 11:55   ` Marlon Richert
2021-03-29 17:11     ` Daniel Shahaf
2021-03-29 17:20       ` Bart Schaefer
2021-03-29 18:14         ` Daniel Shahaf
2021-03-29 20:00           ` Marlon Richert
2021-03-29 20:05             ` Daniel Shahaf
2021-03-29 20:35               ` Marlon Richert
2021-04-01  4:28                 ` Marlon Richert
2021-04-01 18:40                   ` Daniel Shahaf
2021-04-02  0:50                 ` Oliver Kiddle
2021-04-10 20:20                   ` Lawrence Velázquez
2021-04-11 20:06                     ` Marlon Richert
2021-04-11 21:24                     ` Patch bumping (was Re: Feature Patch: Use completion to view parameter values) Bart Schaefer
2021-04-12  8:18                       ` Marlon
2021-04-13 12:32                         ` Daniel Shahaf
2021-04-13 18:08                           ` Lawrence Velázquez
2021-04-15  9:39                             ` [META] Tone of voice / Writing style in patch reviews (was Re: Patch bumping) Marlon
2021-04-15 10:33                               ` zeurkous
2021-04-13 13:35                         ` Patch bumping (was Re: Feature Patch: Use completion to view parameter values) Daniel Shahaf
2021-04-13 21:31                           ` Lawrence Velázquez
2021-04-13 21:50                             ` Bart Schaefer
2021-04-14 12:52                             ` Daniel Shahaf
2021-04-13  2:47                       ` Lawrence Velázquez
2021-04-12 20:22                   ` Marlon [this message]
2021-04-12 21:49                     ` Feature Patch: Use completion to view parameter values Bart Schaefer
2021-04-13  4:50                       ` Marlon Richert
2021-03-30  5:41           ` Mikael Magnusson
2021-03-31 22:55             ` Daniel Shahaf
2021-03-31 23:03               ` Daniel Shahaf
2021-03-29 20:10         ` Peter Stephenson
2021-03-29 11:48 ` Mikael Magnusson
2021-03-29 12:06   ` Marlon Richert
2021-03-29 12:07     ` 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=E4631DCC-BAB2-4FA7-9373-008EC55E581F@gmail.com \
    --to=marlon.richert@gmail.com \
    --cc=opk@zsh.org \
    --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).