zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Cc: Alex George <xzeroknightx@gmail.com>
Subject: Re: [BUG] _expand completer's all-expansions tag format style does not expand %o
Date: Sat, 22 Oct 2016 21:46:28 -0700	[thread overview]
Message-ID: <161022214628.ZM7665@torch.brasslantern.com> (raw)
In-Reply-To: <CANKG6XqAmBFKHbmWjCGyNyXhU129p7eHLaF0oV9Ebk-a7=tmjw@mail.gmail.com>

On Oct 19, 10:19pm, Alex George wrote:
}
} [...] the all-expansions tag does not actually expand %o unlike the
} expansions tag.
} 
} I believe the problem is the lack of a
} 
}      _description all-expansions expl all-expansions "o:$word"
} 
} line in Completion/Base/Completer/_expand.

Yes, that's essentially correct.  However, there are a few nuances.

The _requested call at line 210 makes a call to _description, passing
along the (expl 'all expansions') arguments.  However, _requested doesn't
handle passing the additional formatting strings along to _description,
so it's necessary to drop those two arguments from _requested and make
an explicit call to _description instead, handling the "menu" style as
is done for "_requested expansions".

I note in passing that it doesn't make sense to have a tag-specific
format style unless one also has a group-name style, because in the
absence of group-name all the matches end up in group "-default-"
and all the format strings get displayed together above that, and
not necessarily in related order, which can be quite distracting.

As mentioned in users/21955, I don't understand why a single match was
being excluded from the expansions tag but included in all-expansions?


diff --git a/Completion/Base/Completer/_expand b/Completion/Base/Completer/_expand
index e52144c..a6e30e8 100644
--- a/Completion/Base/Completer/_expand
+++ b/Completion/Base/Completer/_expand
@@ -181,7 +181,7 @@ if [[ -z "$compstate[insert]" ]] ;then
 else
   _tags all-expansions expansions original
 
-  if [[ $#exp -gt 1 ]] && _requested expansions; then
+  if [[ $#exp -ge 1 ]] && _requested expansions; then
     local i j normal space dir
 
     if [[ "$sort" = menu ]]; then
@@ -207,9 +207,14 @@ else
     (( $#space ))  && compadd "$expl[@]" -UQ -qS " " -a space
     (( $#normal )) && compadd "$expl[@]" -UQ -qS "" -a normal
   fi
-  if _requested all-expansions expl 'all expansions'; then
+  if _requested all-expansions; then
     local disp dstr
 
+    if [[ "$sort" = menu ]]; then
+      _description all-expansions expl 'all expansions' "o:$word"
+    else
+      _description -V all-expansions expl 'all expansions' "o:$word"
+    fi
     if [[ "${#${exp}}" -ge COLUMNS ]]; then
       disp=( -ld dstr )
       dstr=( "${(r:COLUMNS-5:)exp} ..." )
diff --git a/Completion/Base/Completer/_user_expand b/Completion/Base/Completer/_user_expand
index 066e2e8..ee39bb1 100644
--- a/Completion/Base/Completer/_user_expand
+++ b/Completion/Base/Completer/_user_expand
@@ -121,9 +121,14 @@ else
     (( $#space ))  && compadd "$expl[@]" -UQ -qS " " -a space
     (( $#normal )) && compadd "$expl[@]" -UQ -qS "" -a normal
   fi
-  if _requested all-expansions expl "all expansions${REPLY:+: $REPLY}"; then
+  if _requested all-expansions; then
     local disp dstr
 
+    if [[ "$sort" = menu ]]; then
+      _description all-expansions expl "all expansions${REPLY:+: $REPLY}" "o:$word"
+    else
+      _description -V all-expansions expl "all expansions${REPLY:+: $REPLY}" "o:$word"
+    fi
     if [[ "${#${exp}}" -ge COLUMNS ]]; then
       disp=( -ld dstr )
       dstr=( "${(r:COLUMNS-5:)exp} ..." )


  reply	other threads:[~2016-10-23  4:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-19 22:19 Alex George
2016-10-23  4:46 ` Bart Schaefer [this message]
2016-10-23 10:27   ` Daniel Shahaf
2016-10-23 16:34     ` Bart Schaefer

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=161022214628.ZM7665@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=xzeroknightx@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).