From: Marko Myllynen <myllynen@redhat.com>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: zsh-workers@zsh.org
Subject: Re: [PATCH] zsh locale completion
Date: Tue, 10 May 2016 18:32:04 +0300 [thread overview]
Message-ID: <5731FEF4.7000306@redhat.com> (raw)
In-Reply-To: <20160509221458.GA30922@tarsus.local2>
Hi,
On 2016-05-10 01:14, Daniel Shahaf wrote:
> Marko Myllynen wrote on Mon, May 09, 2016 at 15:55:00 +0300:
>> +++ b/Completion/Unix/Command/_locale
>> @@ -0,0 +1,28 @@
>> +local curcontext="$curcontext" state line expl ret=1
> ⋮
>> +_arguments -A -C -S -s \
> ⋮
>> + '*:name:->catkey' \
>> + && return=0
>
> Typo: s/return/ret/
Good catch - updated patch below. It seems that using return is
required as otherwise we end up inside the if-statement even in
cases like locale -<tab>.
---
Completion/Unix/Command/_locale | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
create mode 100644 Completion/Unix/Command/_locale
diff --git a/Completion/Unix/Command/_locale b/Completion/Unix/Command/_locale
new file mode 100644
index 0000000..af6e90c
--- /dev/null
+++ b/Completion/Unix/Command/_locale
@@ -0,0 +1,28 @@
+#compdef locale
+
+local curcontext="$curcontext" state line expl ret=1
+local exargs="-? --help --usage -V --version"
+
+_arguments -A -C -S -s \
+ '(- *)'{-\?,--help}'[display help information]' \
+ '(- *)--usage[display a short usage message]' \
+ '(- *)'{-V,--version}'[print program version]' \
+ - set1 \
+ "(-a --all-locales $exargs)"{-a,--all-locales}'[list all available locales]' \
+ "(-v --verbose $exargs)"{-v,--verbose}'[display additional information]' \
+ - set2 \
+ "(-m --charmaps $exargs)"{-m,--charmaps}'[list all available charmaps]' \
+ - set3 \
+ "(-c --category-name $exargs)"{-c,--category-name}'[print also locale category]' \
+ "(-k --keyword-name $exargs)"{-k,--keyword-name}'[print also keyword of each value]' \
+ '*:name:->catkey' \
+ && return 0
+
+if [[ $state == catkey ]]; then
+ typeset -a cats keys
+ cats=( ${${${(f)"$(locale)"}%=*}%(LANG|LANGUAGE|LC_ALL)} )
+ keys=( ${${(f)"$(locale -k $cats 2>/dev/null)"}%=*} )
+ _wanted values expl name compadd "$@" -a - cats keys && ret=0
+fi
+
+return ret
Thanks,
--
Marko Myllynen
next prev parent reply other threads:[~2016-05-10 15:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-09 12:55 Marko Myllynen
2016-05-09 22:14 ` Daniel Shahaf
2016-05-10 15:32 ` Marko Myllynen [this message]
2016-05-28 14:38 ` Eric Cook
2016-05-28 14:49 ` Eric Cook
2016-05-29 15:50 ` Marko Myllynen
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=5731FEF4.7000306@redhat.com \
--to=myllynen@redhat.com \
--cc=d.s@daniel.shahaf.name \
--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).