From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Zsh workers <zsh-workers@zsh.org>
Subject: Re: PATCH: git subcommand completion formatting
Date: Fri, 19 Jun 2015 16:54:10 +0200 [thread overview]
Message-ID: <6200.1434725650@thecus.kiddle.eu> (raw)
In-Reply-To: <150617154809.ZM1651@torch.brasslantern.com>
Bart wrote:
> I see you handled the list-separator style.
There are, however, a few other functions with a hard coded list
separators. This fixes them.
Oliver
diff --git a/Completion/Unix/Type/_email_addresses b/Completion/Unix/Type/_email_addresses
index 926e8b4..7d5c942 100644
--- a/Completion/Unix/Type/_email_addresses
+++ b/Completion/Unix/Type/_email_addresses
@@ -88,7 +88,7 @@ _email-local() {
_email_addresses() {
local -a plugins reply list args
local -A opts files
- local plugin rcfile muttrc expl ret fret
+ local plugin rcfile muttrc expl sep ret fret
local __specialx='][()<>@,;:\\".'
local __spacex=" " # Space, tab
@@ -159,7 +159,8 @@ _email_addresses() {
if (( fret == 300 )); then
if (( ! $+opts[-c] )) && [[ $opts[-n] = $plugin ]]; then
- zformat -a list ' -- ' "${reply[@]}"
+ zstyle -s ":completion:${curcontext}:$curtag" list-separator sep || sep=--
+ zformat -a list " $sep " "${reply[@]}"
_wanted mail-aliases expl 'alias' compadd "$@" \
-d list - ${reply%%:*} && ret=0
else
diff --git a/Completion/Zsh/Command/_fc b/Completion/Zsh/Command/_fc
index 1589244..68456cc 100644
--- a/Completion/Zsh/Command/_fc
+++ b/Completion/Zsh/Command/_fc
@@ -1,7 +1,7 @@
#compdef fc history r
local curcontext="$curcontext" state state_descr line ret=1
-local list events num cmd
+local events num cmd sep
typeset -A opt_args
local fc_common fc_hist fc_r
@@ -67,21 +67,20 @@ case $service in
esac
if [[ -n $state ]]; then
+ zstyle -s ":completion:${curcontext}:" list-separator sep || sep=--
if [[ -z ${line:#*=*} ]] && compset -P '*='; then
_message -e replacements 'replacement'
elif [[ -prefix [0-9] ]]; then
- events=( ${(ps.\0.)"$(printf '%s:%s\0' ${(kv)history})"} )
- zformat -a list " -- " "$events[@]"
- _wanted -2V events expl "$state_descr" compadd -M "B:0=" -ld list - \
- "${events[@]%%:*}"
+ events=( ${(0)"$(printf "%-${#HISTNO}.${#HISTNO}s $sep %s\0" "${(kv)history[@]}")"} )
+ _wanted -2V events expl "$state_descr" compadd -M "B:0=" -ld events - \
+ "${events[@]%% *}"
elif [[ -prefix - ]]; then
- for num cmd in ${(kv)history}; do
+ for num cmd in "${(kv@)history}"; do
(( num=num - HISTNO ))
- events+=( $num:$cmd )
+ events+=( "${(r.1+$#HISTNO.)num} $sep $cmd" )
done
- zformat -a list " -- " "$events[@]"
- _wanted -2V events expl "$state_descr" compadd -ld list - \
- "${events[@]%%:*}"
+ _wanted -2V events expl "$state_descr" compadd -ld events - \
+ "${events[@]%% *}"
else
_wanted events expl "$state_descr" compadd -S '' - \
${${history%%[=[:IFS:]]*}:#[0-9-]*} || _guard "[0-9]#" event
diff --git a/Completion/Zsh/Command/_zpty b/Completion/Zsh/Command/_zpty
index ef4ac4b..99251aa 100644
--- a/Completion/Zsh/Command/_zpty
+++ b/Completion/Zsh/Command/_zpty
@@ -1,6 +1,6 @@
#compdef zpty
-local state line list names expl curcontext="$curcontext"
+local state line list names expl sep curcontext="$curcontext"
typeset -A opt_args
_arguments -C -s -S \
@@ -50,8 +50,9 @@ if [[ $state = name ]]; then
fi
list=( ${${(f)"$(zpty)"}#*\) } )
names=( ${list%%:*} )
- if zstyle -T ":completion:${curcontext}" verbose; then
- zformat -a list ' --' ${${(f)"$(zpty)"}#*\) }
+ if zstyle -T ":completion:${curcontext}:" verbose; then
+ zstyle -s ":completion:${curcontext}:" list-separator sep || sep=--
+ zformat -a list " $sep" ${${(f)"$(zpty)"}#*\) }
_wanted names expl 'zpty command name' compadd -d list -a names
else
_wanted names expl 'zpty command name' compadd -a names
prev parent reply other threads:[~2015-06-19 15:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-17 22:32 Oliver Kiddle
2015-06-17 22:48 ` Bart Schaefer
2015-06-17 23:05 ` Oliver Kiddle
2015-06-19 14:54 ` Oliver Kiddle [this message]
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=6200.1434725650@thecus.kiddle.eu \
--to=okiddle@yahoo.co.uk \
--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).