Re: [PATCH] completion: update bash completion
[notmuch-archives.git] / 33 / 2d537ff738ae5dd9546b9982c4c5b9ce8cf565
1 Return-Path: <tomi.ollila@iki.fi>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 19C2B431FBD\r
6         for <notmuch@notmuchmail.org>; Thu,  7 Nov 2013 05:30:23 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id mxKTJLGo4FJi for <notmuch@notmuchmail.org>;\r
16         Thu,  7 Nov 2013 05:30:15 -0800 (PST)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id 44171431FAE\r
19         for <notmuch@notmuchmail.org>; Thu,  7 Nov 2013 05:30:15 -0800 (PST)\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
21         by guru.guru-group.fi (Postfix) with ESMTP id C095D100051;\r
22         Thu,  7 Nov 2013 15:30:10 +0200 (EET)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
25 Subject: Re: [PATCH] completion: update bash completion\r
26 In-Reply-To: <1383765937-20921-1-git-send-email-jani@nikula.org>\r
27 References: <1383765937-20921-1-git-send-email-jani@nikula.org>\r
28 User-Agent: Notmuch/0.16+119~g219c55f (http://notmuchmail.org) Emacs/24.3.1\r
29         (x86_64-unknown-linux-gnu)\r
30 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
31         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
32         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
33 Date: Thu, 07 Nov 2013 15:30:10 +0200\r
34 Message-ID: <m24n7o9w65.fsf@guru.guru-group.fi>\r
35 MIME-Version: 1.0\r
36 Content-Type: text/plain\r
37 X-BeenThere: notmuch@notmuchmail.org\r
38 X-Mailman-Version: 2.1.13\r
39 Precedence: list\r
40 List-Id: "Use and development of the notmuch mail system."\r
41         <notmuch.notmuchmail.org>\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
45 List-Post: <mailto:notmuch@notmuchmail.org>\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
49 X-List-Received-Date: Thu, 07 Nov 2013 13:30:23 -0000\r
50 \r
51 On Wed, Nov 06 2013, Jani Nikula <jani@nikula.org> wrote:\r
52 \r
53 > Update bash completion to cover new commands and options:\r
54 >\r
55 > notmuch compact --quiet --backup=DIR\r
56 > notmuch count --output=files --batch --input=FILE\r
57 > notmuch insert --folder=DIR --create-folder\r
58 > notmuch search --exclude=all --duplicate=N\r
59 > notmuch show --include-html\r
60 > notmuch tag --batch --input=FILE --remove-all\r
61 \r
62 These changes looks sensible and consistent to me. +1\r
63 \r
64 Tomi\r
65 \r
66 \r
67 >\r
68 > ---\r
69 >\r
70 > This logically depends on id:cover.1383481295.git.jani@nikula.org\r
71 > which adds --quiet and --backup=DIR parameters to compact.\r
72 > ---\r
73 >  completion/notmuch-completion.bash | 89 +++++++++++++++++++++++++++++++++++---\r
74 >  1 file changed, 82 insertions(+), 7 deletions(-)\r
75 >\r
76 > diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash\r
77 > index 7bd7745..04324bb 100644\r
78 > --- a/completion/notmuch-completion.bash\r
79 > +++ b/completion/notmuch-completion.bash\r
80 > @@ -59,6 +59,29 @@ _notmuch_search_terms()\r
81 >      __ltrim_colon_completions "${cur}"\r
82 >  }\r
83 >  \r
84 > +_notmuch_compact()\r
85 > +{\r
86 > +    local cur prev words cword split\r
87 > +    _init_completion -s || return\r
88 > +\r
89 > +    $split &&\r
90 > +    case "${prev}" in\r
91 > +     --backup)\r
92 > +         _filedir\r
93 > +         return\r
94 > +         ;;\r
95 > +    esac\r
96 > +\r
97 > +    ! $split &&\r
98 > +    case "${cur}" in\r
99 > +     -*)\r
100 > +         local options="--backup= --quiet"\r
101 > +         compopt -o nospace\r
102 > +         COMPREPLY=( $(compgen -W "$options" -- ${cur}) )\r
103 > +         ;;\r
104 > +    esac\r
105 > +}\r
106 > +\r
107 >  _notmuch_config()\r
108 >  {\r
109 >      local cur prev words cword split\r
110 > @@ -89,19 +112,23 @@ _notmuch_count()\r
111 >      $split &&\r
112 >      case "${prev}" in\r
113 >       --output)\r
114 > -         COMPREPLY=( $( compgen -W "messages threads" -- "${cur}" ) )\r
115 > +         COMPREPLY=( $( compgen -W "messages threads files" -- "${cur}" ) )\r
116 >           return\r
117 >           ;;\r
118 >       --exclude)\r
119 >           COMPREPLY=( $( compgen -W "true false" -- "${cur}" ) )\r
120 >           return\r
121 >           ;;\r
122 > +     --input)\r
123 > +         _filedir\r
124 > +         return\r
125 > +         ;;\r
126 >      esac\r
127 >  \r
128 >      ! $split &&\r
129 >      case "${cur}" in\r
130 >       -*)\r
131 > -         local options="--output= --exclude="\r
132 > +         local options="--output= --exclude= --batch --input="\r
133 >           compopt -o nospace\r
134 >           COMPREPLY=( $(compgen -W "$options" -- ${cur}) )\r
135 >           ;;\r
136 > @@ -141,6 +168,39 @@ _notmuch_dump()\r
137 >      esac\r
138 >  }\r
139 >  \r
140 > +_notmuch_insert()\r
141 > +{\r
142 > +    local cur prev words cword split\r
143 > +    # handle tags with colons and equal signs\r
144 > +    _init_completion -s -n := || return\r
145 > +\r
146 > +    $split &&\r
147 > +    case "${prev}" in\r
148 > +     --folder)\r
149 > +         _filedir\r
150 > +         return\r
151 > +         ;;\r
152 > +    esac\r
153 > +\r
154 > +    ! $split &&\r
155 > +    case "${cur}" in\r
156 > +     --*)\r
157 > +         local options="--create-folder --folder="\r
158 > +         compopt -o nospace\r
159 > +         COMPREPLY=( $(compgen -W "$options" -- ${cur}) )\r
160 > +         return\r
161 > +         ;;\r
162 > +     +*)\r
163 > +         COMPREPLY=( $(compgen -P "+" -W "`notmuch search --output=tags \*`" -- ${cur##+}) )\r
164 > +         ;;\r
165 > +     -*)\r
166 > +         COMPREPLY=( $(compgen -P "-" -W "`notmuch search --output=tags \*`" -- ${cur##-}) )\r
167 > +         ;;\r
168 > +    esac\r
169 > +    # handle tags with colons\r
170 > +    __ltrim_colon_completions "${cur}"\r
171 > +}\r
172 > +\r
173 >  _notmuch_new()\r
174 >  {\r
175 >      local cur prev words cword split\r
176 > @@ -231,7 +291,7 @@ _notmuch_search()\r
177 >           return\r
178 >           ;;\r
179 >       --exclude)\r
180 > -         COMPREPLY=( $( compgen -W "true false flag" -- "${cur}" ) )\r
181 > +         COMPREPLY=( $( compgen -W "true false flag all" -- "${cur}" ) )\r
182 >           return\r
183 >           ;;\r
184 >      esac\r
185 > @@ -239,7 +299,7 @@ _notmuch_search()\r
186 >      ! $split &&\r
187 >      case "${cur}" in\r
188 >       -*)\r
189 > -         local options="--format= --output= --sort= --offset= --limit= --exclude="\r
190 > +         local options="--format= --output= --sort= --offset= --limit= --exclude= --duplicate="\r
191 >           compopt -o nospace\r
192 >           COMPREPLY=( $(compgen -W "$options" -- ${cur}) )\r
193 >           ;;\r
194 > @@ -273,7 +333,7 @@ _notmuch_show()\r
195 >      ! $split &&\r
196 >      case "${cur}" in\r
197 >       -*)\r
198 > -         local options="--entire-thread= --format= --exclude= --body= --format-version= --part= --verify --decrypt"\r
199 > +         local options="--entire-thread= --format= --exclude= --body= --format-version= --part= --verify --decrypt --include-html"\r
200 >           compopt -o nospace\r
201 >           COMPREPLY=( $(compgen -W "$options" -- ${cur}) )\r
202 >           ;;\r
203 > @@ -287,9 +347,24 @@ _notmuch_tag()\r
204 >  {\r
205 >      local cur prev words cword split\r
206 >      # handle tags with colons and equal signs\r
207 > -    _init_completion -n := || return\r
208 > +    _init_completion -s -n := || return\r
209 > +\r
210 > +    $split &&\r
211 > +    case "${prev}" in\r
212 > +     --input)\r
213 > +         _filedir\r
214 > +         return\r
215 > +         ;;\r
216 > +    esac\r
217 >  \r
218 > +    ! $split &&\r
219 >      case "${cur}" in\r
220 > +     --*)\r
221 > +         local options="--batch --input= --remove-all"\r
222 > +         compopt -o nospace\r
223 > +         COMPREPLY=( $(compgen -W "$options" -- ${cur}) )\r
224 > +         return\r
225 > +         ;;\r
226 >       +*)\r
227 >           COMPREPLY=( $(compgen -P "+" -W "`notmuch search --output=tags \*`" -- ${cur##+}) )\r
228 >           ;;\r
229 > @@ -307,7 +382,7 @@ _notmuch_tag()\r
230 >  \r
231 >  _notmuch()\r
232 >  {\r
233 > -    local _notmuch_commands="config count dump help new reply restore search setup show tag"\r
234 > +    local _notmuch_commands="compact config count dump help insert new reply restore search setup show tag"\r
235 >      local arg cur prev words cword split\r
236 >      _init_completion || return\r
237 >  \r
238 > -- \r
239 > 1.8.4.rc3\r
240 >\r
241 > _______________________________________________\r
242 > notmuch mailing list\r
243 > notmuch@notmuchmail.org\r
244 > http://notmuchmail.org/mailman/listinfo/notmuch\r