* [BUG] _expand completer's all-expansions tag format style does not expand %o
@ 2016-10-19 22:19 Alex George
2016-10-23 4:46 ` Bart Schaefer
0 siblings, 1 reply; 4+ messages in thread
From: Alex George @ 2016-10-19 22:19 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 1267 bytes --]
I have found a bug with the _expand completer regarding the format style.
zshcompsys(1) states the following about the _expand completer:
The format string for all-expansions and for expansions may contain the
sequence `%o' which will be replaced by the original string from the
line.
However, the all-expansions tag does not actually expand %o unlike the
expansions tag. I am using zsh v5.2, but have confirmed the bug's presence
upstream as well. This behavior can be reproduced as follows:
* Include the _expand completer in your completer style
* bindkey '^I' complete-word
* zstyle ':completions:*:*expansions' format '>%d for [%o]'
% cd $(mktemp -d)
% touch foo bar
% print *<TAB>
>expansions for [*]
bar foo
>all-expansions for []
bar foo
I believe the problem is the lack of a
_description all-expansions expl all-expansions "o:$word"
line in Completion/Base/Completer/_expand. I was able to fix the issue by
adding
that line under line 210 of the _expand completer, but I don't know enough
about the completion system guts to determine if this is the ideal solution
or
not.
I don't believe I have received a subscription confirmation email yet, so
would
you kindly CC replies to xzeroknightx [AT] gmail [DOT] com ?
Regards,
Alex George
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [BUG] _expand completer's all-expansions tag format style does not expand %o
2016-10-19 22:19 [BUG] _expand completer's all-expansions tag format style does not expand %o Alex George
@ 2016-10-23 4:46 ` Bart Schaefer
2016-10-23 10:27 ` Daniel Shahaf
0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2016-10-23 4:46 UTC (permalink / raw)
To: zsh-workers; +Cc: Alex George
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} ..." )
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [BUG] _expand completer's all-expansions tag format style does not expand %o
2016-10-23 4:46 ` Bart Schaefer
@ 2016-10-23 10:27 ` Daniel Shahaf
2016-10-23 16:34 ` Bart Schaefer
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Shahaf @ 2016-10-23 10:27 UTC (permalink / raw)
To: zsh-workers; +Cc: Alex George
Bart Schaefer wrote on Sat, Oct 22, 2016 at 21:46:28 -0700:
> 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?
To avoid redundancy? When there's one match, without that condition
the [expansions] and [all-expansions] group would have exactly the same
matches.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [BUG] _expand completer's all-expansions tag format style does not expand %o
2016-10-23 10:27 ` Daniel Shahaf
@ 2016-10-23 16:34 ` Bart Schaefer
0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2016-10-23 16:34 UTC (permalink / raw)
To: zsh-workers; +Cc: Alex George
On Oct 23, 10:27am, Daniel Shahaf wrote:
}
} Bart Schaefer wrote on Sat, Oct 22, 2016 at 21:46:28 -0700:
} > 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?
}
} To avoid redundancy? When there's one match, without that condition
} the [expansions] and [all-expansions] group would have exactly the same
} matches.
True, but that happens in other completers without being special-cased
this way, and unless doing menu-selection or a listing the duplicate
is eliminated anyway. If one has a tag-order style that selects only
one of the two groups and the match is not in both, it may be lost.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-10-23 17:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-19 22:19 [BUG] _expand completer's all-expansions tag format style does not expand %o Alex George
2016-10-23 4:46 ` Bart Schaefer
2016-10-23 10:27 ` Daniel Shahaf
2016-10-23 16:34 ` 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).