1 Return-Path: <peterjohnhartman@gmail.com>
\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 A0742429E25
\r
6 for <notmuch@notmuchmail.org>; Sat, 1 Oct 2011 07:29:11 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id WRr-rh2U9lHW for <notmuch@notmuchmail.org>;
\r
17 Sat, 1 Oct 2011 07:29:10 -0700 (PDT)
\r
18 Received: from mail-qw0-f53.google.com (mail-qw0-f53.google.com
\r
19 [209.85.216.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 9D017431FB6
\r
22 for <notmuch@notmuchmail.org>; Sat, 1 Oct 2011 07:29:10 -0700 (PDT)
\r
23 Received: by qafi31 with SMTP id i31so1117678qaf.26
\r
24 for <notmuch@notmuchmail.org>; Sat, 01 Oct 2011 07:29:09 -0700 (PDT)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
\r
26 h=date:from:to:subject:message-id:mime-version:content-type
\r
27 :content-disposition:content-transfer-encoding:user-agent;
\r
28 bh=7Z16G0kWwpuK+c9yPTmsU3umWxcJOK2cpgqZtNsGHDg=;
\r
29 b=ACef3DvQsWtCogz+nqTVnPumDuCW905jniOlWQPAyhz/uth5wafaHjCKepatrFs7zC
\r
30 nEogpRCssCOyHKEPHS7s8uFk27A6LYIXxIjXJ6PJ4VbPUYxb5cup+cjdUqRQI8i4V+Ig
\r
31 uvDsTyzZQWnZZoB1N8wtDT7ZFgEj2LciGR7cU=
\r
32 Received: by 10.224.203.196 with SMTP id fj4mr9875374qab.362.1317479348788;
\r
33 Sat, 01 Oct 2011 07:29:08 -0700 (PDT)
\r
34 Received: from localhost (ip-64-134-98-119.public.wayport.net.
\r
35 [64.134.98.119]) by mx.google.com with ESMTPS id
\r
36 du5sm9189819qab.14.2011.10.01.07.29.07 (version=SSLv3 cipher=OTHER); Sat, 01
\r
37 Oct 2011 07:29:08 -0700 (PDT)
\r
38 Date: Sat, 1 Oct 2011 10:29:06 -0400
\r
39 From: Peter John Hartman <peterjohnhartman@gmail.com>
\r
40 To: notmuch@notmuchmail.org
\r
41 Subject: an alternative commandline interface to notmuch
\r
42 Message-ID: <20111001142906.GA635@leneee.sbx07386.newyony.wayport.net>
\r
44 Content-Type: text/plain; charset=iso-8859-1
\r
45 Content-Disposition: inline
\r
46 Content-Transfer-Encoding: 8bit
\r
47 User-Agent: Mutt/1.5.21 (2010-09-15)
\r
48 X-BeenThere: notmuch@notmuchmail.org
\r
49 X-Mailman-Version: 2.1.13
\r
51 List-Id: "Use and development of the notmuch mail system."
\r
52 <notmuch.notmuchmail.org>
\r
53 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
54 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
55 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
56 List-Post: <mailto:notmuch@notmuchmail.org>
\r
57 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
58 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
59 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
60 X-List-Received-Date: Sat, 01 Oct 2011 14:29:11 -0000
\r
64 Rafa released slmenu, a dmenu-clone that runs on the commandline, and I
\r
65 contributed a couple of patches (verticality and tokens) to make it work
\r
66 nice with notmuch. So far, I'm pretty happy. To get slmenu:
\r
68 hg clone http://hg.suckless.org/slmenu
\r
70 You'll need to apply the patch at the bottom of this e-mail[1].
\r
71 You'll also want to use the shell script (nmsl) at the bottom of this e-mail[2].
\r
75 Basically, it pipes output (after being mangled a bit) from notmuch search
\r
76 into slmenu/dmenu (so you can select the thread) and then sends that output
\r
77 to mutt, either via mbox (if notmuch is hosted remote) or maildir (if local).
\r
78 It also allows you to prepend an entry with v (tag viewed), t +tag (tag
\r
79 tag), x (tag x-del).
\r
81 All this will be at:
\r
83 http://durandus.trilidun.org/durandus/code/notmuch-slmenu/
\r
89 [1] token.patch to slmenu
\r
91 diff -r 7896c4e3bf21 slmenu.c
\r
92 --- a/slmenu.c Thu Sep 29 12:45:34 2011 +0200
\r
93 +++ b/slmenu.c Sat Oct 01 10:11:29 2011 -0400
\r
95 static void drawmenu(void);
\r
96 static char *fstrstr(const char*, const char*);
\r
97 static void insert(const char*, ssize_t);
\r
98 -static void match(int);
\r
99 +static void match(void);
\r
100 static size_t nextrune(int);
\r
101 static void readstdin(void);
\r
102 static int run(void);
\r
103 @@ -60,10 +60,10 @@
\r
106 appenditem(Item *item, Item **list, Item **last) {
\r
109 + (*last)->right = item;
\r
113 - (*last)->right = item;
\r
114 item->left = *last;
\r
115 item->right = NULL;
\r
117 @@ -132,13 +132,17 @@
\r
121 + fprintf(stderr, "\033[H");
\r
122 + fprintf(stderr, "\033[2J");
\r
124 /* use default colors */
\r
125 fprintf(stderr, "\033[0m");
\r
127 + putp(clear_screen); */
\r
129 /* place cursor in first column, clear it */
\r
130 fprintf(stderr, "\033[0G");
\r
131 fprintf(stderr, "\033[K");
\r
134 drawtext(prompt, promptw-4, C_Reverse);
\r
136 @@ -188,9 +192,10 @@
\r
138 memcpy(&text[cursor], str, n);
\r
140 - match(n > 0 && text[cursor] == '\0');
\r
147 size_t len = strlen(text);
\r
148 @@ -231,6 +236,60 @@
\r
149 curr = sel = matches;
\r
156 + static char **tokv = NULL;
\r
157 + static int tokn = 0;
\r
159 + char buf[sizeof text], *s;
\r
162 + Item *item, *lprefix, *lsubstr, *prefixend, *substrend;
\r
164 + strcpy(buf, text);
\r
165 + for(s = strtok(buf, " "); s; tokv[tokc-1] = s, s = strtok(NULL, " "))
\r
166 + if(++tokc > tokn && !(tokv = realloc(tokv, ++tokn * sizeof *tokv)))
\r
167 + die("Can't realloc.");
\r
168 +/* fprintf("cannot realloc %u bytes\n", tokn * sizeof *tokv); */
\r
169 + len = tokc ? strlen(tokv[0]) : 0;
\r
171 + matches = lprefix = lsubstr = matchend = prefixend = substrend = NULL;
\r
172 + for(item = items; item && item->text; item++) {
\r
173 + for(i = 0; i < tokc; i++)
\r
174 + if(!fstrstr(item->text, tokv[i]))
\r
178 + if(!tokc || !fstrncmp(tokv[0], item->text, len+1))
\r
179 + appenditem(item, &matches, &matchend);
\r
180 + else if(!strncmp(tokv[0], item->text, len))
\r
181 + appenditem(item, &lprefix, &prefixend);
\r
183 + appenditem(item, &lsubstr, &substrend);
\r
187 + matchend->right = lprefix;
\r
188 + lprefix->left = matchend;
\r
191 + matches = lprefix;
\r
192 + matchend = prefixend;
\r
196 + matchend->right = lsubstr;
\r
197 + lsubstr->left = matchend;
\r
200 + matches = lsubstr;
\r
201 + matchend = substrend;
\r
203 + curr = sel = matches;
\r
208 nextrune(int inc) {
\r
209 @@ -371,7 +430,7 @@
\r
211 if(sel) strncpy(text, sel->text, sizeof text); /* Complete the input first, when hitting return */
\r
212 cursor = strlen(text);
\r
218 @@ -441,11 +500,11 @@
\r
220 strncpy(text, sel->text, sizeof text);
\r
221 cursor = strlen(text);
\r
226 text[cursor] = '\0';
\r
231 insert(NULL, 0 - cursor);
\r
232 @@ -514,7 +573,7 @@
\r
233 lines=MIN(MAX(lines, 0), mh);
\r
234 promptw=(prompt?textw(prompt):0);
\r
235 inputw=MIN(inputw, mw/3);
\r
238 if(barpos!=0) resetline();
\r
241 @@ -542,7 +601,7 @@
\r
242 puts("slmenu, © 2011 slmenu engineers, see LICENSE for details");
\r
243 exit(EXIT_SUCCESS);
\r
245 - else if(!strcmp(argv[i], "-i"))
\r
246 + else if(!strcmp(argv[i], "-i"))
\r
247 fstrncmp = strncasecmp;
\r
248 else if(!strcmp(argv[i], "-t"))
\r
251 [2] nmsl shell script
\r
253 # Copyright (c) Peter John Hartman (peterjohnhartman at gmail dot com)
\r
255 # * Permission to use, copy, modify, and distribute this software for any
\r
256 # * purpose with or without fee is hereby granted, provided that the above
\r
257 # * copyright notice and this permission notice appear in all copies.
\r
259 # * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
\r
260 # * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
\r
261 # * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
\r
262 # * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
\r
263 # * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
\r
264 # * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
\r
265 # * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
\r
267 maildir="/tmp/maildir"
\r
268 slmenu="slmenu -i -l 30 -t -p [vtx]:"
\r
269 #slmenu="dmenu -i -l 30 -p [vtx]:"
\r
270 notmuch="/usr/local/bin/notmuch"
\r
276 Example: nmsl `nmdate 3 days ago`..`nmdate yesterday` tag:inbox
\r
277 Example: nmsl tag:inbox and tag:unread
\r
279 nmdate = echo $(date +%s -d "$*")
\r
282 -h Show this message
\r
287 while getopts "hsd:" OPTION
\r
295 notmuch="ssh trillap /usr/local/bin/notmuch"
\r
301 shift $((OPTIND-1))
\r
304 if [[ $search == "" ]]; then
\r
305 search="tag:inbox and tag:unread"
\r
308 res=$($notmuch search $search |\
\r
309 sed -r 's/([^ ]*) ([^[]*)([^]]*\]) ([^;]*); (.*) (\([^)]*\))/\2\5; \4 \3 \6 \1/' |\
\r
312 if [[ $res != "" ]]; then
\r
313 option=$(echo $res | cut -d' ' -f1)
\r
318 thread=$(echo $res | awk -F' ' '{print $NF}')
\r
319 notmuch tag -unread +x-del $thread
\r
324 thread=$(echo $res | awk -F' ' '{print $NF}')
\r
325 notmuch tag $(echo $res | cut -d' ' -f2) -inbox $thread
\r
330 thread=$(echo $res | awk -F' ' '{print $NF}')
\r
331 notmuch tag -unread $thread
\r
335 thread=$(echo $res | awk -F' ' '{print $NF}')
\r
337 if [[ $use_maildir -eq 1 ]]; then
\r
343 $notmuch search --output=files $thread | sed -e 's: :\\ :g' |\
\r
344 xargs --no-run-if-empty ln -s -t $maildir/cur/
\r
347 $notmuch show --format=mbox $thread > /tmp/nmsearch.$$
\r
348 mutt -f /tmp/nmsearch.$$
\r
349 rm -f -- /tmp/nmsearch.$$
\r
365 sic dicit magister P
\r
366 University of Toronto / Fordham University
\r
367 Collins Hall B06; Office Hours TF10-12
\r
368 http://individual.utoronto.ca/peterjh
\r
369 gpg 1024D/ED6EF59B (7D1A 522F D08E 30F6 FA42 B269 B860 352B ED6E F59B)
\r
370 gpg --keyserver pgp.mit.edu --recv-keys ED6EF59B
\r