1 |
commit: fd8e5c19b8ae8742886e62d9ec4609dacd97f4c0 |
2 |
Author: Vadim A. Misbakh-Soloviov <mva <AT> mva <DOT> name> |
3 |
AuthorDate: Mon Aug 25 12:35:30 2014 +0000 |
4 |
Commit: Vadim A. Misbakh-Soloviov <mva <AT> mva <DOT> name> |
5 |
CommitDate: Mon Aug 25 12:38:03 2014 +0000 |
6 |
URL: http://sources.gentoo.org/gitweb/?p=proj/zsh-completion.git;a=commit;h=fd8e5c19 |
7 |
|
8 |
_eselect: news support |
9 |
|
10 |
Signed-off-by: Vadim A. Misbakh-Soloviov <mva <AT> mva.name> |
11 |
|
12 |
--- |
13 |
_eselect | 42 +++++++++++++++++++++++++++++++++++++++--- |
14 |
1 file changed, 39 insertions(+), 3 deletions(-) |
15 |
|
16 |
diff --git a/_eselect b/_eselect |
17 |
index 1c1f6ec..796a819 100644 |
18 |
--- a/_eselect |
19 |
+++ b/_eselect |
20 |
@@ -112,6 +112,42 @@ _eselect_vi () { |
21 |
"update[Automatically update the vi provider]" |
22 |
} |
23 |
|
24 |
+_eselect_news() { |
25 |
+ |
26 |
+ ## TODO: Normal numeric sorting. |
27 |
+ ## I've spent many time on trying to rewrite this |
28 |
+ ## function to normally sort (to DO NOT sort, actually) items, |
29 |
+ ## but it growing bigger and bigger and going to be too complicated. |
30 |
+ ## So, I (mva) either need to help to make it in the "right way". |
31 |
+ ## Or, maybe, to completely rewrite this compdef. |
32 |
+ |
33 |
+ local -a newslist; |
34 |
+ if ((CURRENT == 3)); then |
35 |
+ _values 'news options' $stdopts[@] \ |
36 |
+ 'list[List news items]' \ |
37 |
+ 'count[Display number of news items]' \ |
38 |
+ 'purge[Purge read news]' \ |
39 |
+ 'read[Read news items]' \ |
40 |
+ 'unread[Mark read news items as unread again]' && return 0 |
41 |
+ elif ((CURRENT == 4)); then |
42 |
+ if (( $words[(I)(count)] )); then |
43 |
+ _values -w 'news' 'new[Count only new news items]' 'all[Count all news items]' && return 0 |
44 |
+ fi |
45 |
+ |
46 |
+ newslist=(${${${${${${${(M)${(f)"$(eselect --color=no news list)"}## *}// \**/}/ \[/}/\] ##/\[}/%/]}/ \[/ (}/\] /) }) |
47 |
+ |
48 |
+ if (( $words[(I)(read)] )); then |
49 |
+ newslist+=( "new[Read unread news items (default)]" "all[Read all news items]" "--mbox[Output in mbox format]" "--quiet[Suppress output, only change status]" "--raw[Output in raw format]" ) |
50 |
+ fi; |
51 |
+ |
52 |
+ if (( $words[(I)(unread)] )); then |
53 |
+ newslist+=( "all[Unread all news items]" ) |
54 |
+ fi |
55 |
+ |
56 |
+ _values -w 'news' $newslist[@] && return 0 |
57 |
+ fi |
58 |
+} |
59 |
+ |
60 |
_eselect () { |
61 |
local globopts modnames modopts |
62 |
|
63 |
@@ -131,7 +167,7 @@ _eselect () { |
64 |
_arguments -s \ |
65 |
"*:portage:_values 'eselect modules' \$modnames[@]" && return 0 |
66 |
elif (( $modnames[(I)$words[2]] )); then |
67 |
- if [[ "$words[2]" == (env|binutils|kernel|ctags|profile|fontconfig|opengl|vi) ]]; then |
68 |
+ if [[ "$words[2]" == (env|binutils|kernel|ctags|profile|fontconfig|opengl|vi|news) ]]; then |
69 |
_eselect_$words[2] "$@" |
70 |
else |
71 |
modopts=(${${${(M)${(f)"$(eselect --brief --color=no $words[2] usage)"}## *}// */}// /}) |
72 |
@@ -142,7 +178,7 @@ _eselect () { |
73 |
elif ((CURRENT >= 4)); then |
74 |
if (( $words[(I)(--color=no|--colour=no)] )); then |
75 |
if (( $modnames[(I)$words[3]] )); then |
76 |
- if [[ "$words[3]" == (env|binutils|kernel|ctags|profile|fontconfig|opengl|vi) ]]; then |
77 |
+ if [[ "$words[3]" == (env|binutils|kernel|ctags|profile|fontconfig|opengl|vi|news) ]]; then |
78 |
_eselect_$words[3] "$@" |
79 |
else |
80 |
modopts=(${${${${(M)${(f)"$(eselect --brief --color=no $words[3] usage)"}## *}// */}// /}// *}) |
81 |
@@ -152,7 +188,7 @@ _eselect () { |
82 |
fi |
83 |
else |
84 |
if (( $modnames[(I)$words[2]] )); then |
85 |
- _eselect_$words[2] "$@" |
86 |
+ (( $+functions[_eselect_$words[2]] )) && _eselect_$words[2] "$@" |
87 |
fi |
88 |
fi |
89 |
fi |