Re: Applying patches directly from emails?
[notmuch-archives.git] / f2 / 7bfb56e83b6bac728314e3ecc794b47711a6c4
1 Return-Path: <dme@dme.org>\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 7BC834196F2\r
6         for <notmuch@notmuchmail.org>; Mon, 12 Apr 2010 03:13:38 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.9\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
12         tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=ham\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 lJ8wu9IcUIuF for <notmuch@notmuchmail.org>;\r
16         Mon, 12 Apr 2010 03:13:37 -0700 (PDT)\r
17 Received: from mail-bw0-f210.google.com (mail-bw0-f210.google.com\r
18         [209.85.218.210])\r
19         by olra.theworths.org (Postfix) with ESMTP id 21519431FC1\r
20         for <notmuch@notmuchmail.org>; Mon, 12 Apr 2010 03:13:36 -0700 (PDT)\r
21 Received: by bwz2 with SMTP id 2so4083417bwz.30\r
22         for <notmuch@notmuchmail.org>; Mon, 12 Apr 2010 03:13:36 -0700 (PDT)\r
23 Received: by 10.204.83.26 with SMTP id d26mr4353701bkl.157.1271067215944;\r
24         Mon, 12 Apr 2010 03:13:35 -0700 (PDT)\r
25 Received: from ut.hh.sledj.net (gmp-ea-fw-1b.sun.com [192.18.8.1])\r
26         by mx.google.com with ESMTPS id d5sm36761027bkd.13.2010.04.12.03.13.34\r
27         (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
28         Mon, 12 Apr 2010 03:13:35 -0700 (PDT)\r
29 Received: by ut.hh.sledj.net (Postfix, from userid 1000)\r
30         id 6CEE65941E1; Mon, 12 Apr 2010 11:13:30 +0100 (BST)\r
31 To: notmuch <notmuch@notmuchmail.org>\r
32 Subject: [PATCH] emacs: Add notmuch-hello.el, a friendly frontend to notmuch\r
33 From: David Edmondson <dme@dme.org>\r
34 Date: Mon, 12 Apr 2010 11:13:30 +0100\r
35 Message-ID: <87fx31j7w5.fsf@ut.hh.sledj.net>\r
36 MIME-Version: 1.0\r
37 Content-Type: text/plain; charset=utf-8\r
38 Content-Transfer-Encoding: quoted-printable\r
39 X-BeenThere: notmuch@notmuchmail.org\r
40 X-Mailman-Version: 2.1.13\r
41 Precedence: list\r
42 List-Id: "Use and development of the notmuch mail system."\r
43         <notmuch.notmuchmail.org>\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
45         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
47 List-Post: <mailto:notmuch@notmuchmail.org>\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
51 X-List-Received-Date: Mon, 12 Apr 2010 10:13:38 -0000\r
52 \r
53 commit e55dc251b9e8001fe16873fadac565563e606d69\r
54 Author: David Edmondson <dme@dme.org>\r
55 Date:   Mon Apr 12 11:12:23 2010 +0100\r
56 \r
57     emacs: Add notmuch-hello.el, a friendly frontend to notmuch\r
58 \r
59         New      emacs/notmuch-hello.el\r
60 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
61 new file mode 100644\r
62 index 0000000..279c424\r
63 --- /dev/null\r
64 +++ b/emacs/notmuch-hello.el\r
65 @@ -0,0 +1,122 @@\r
66 +;; notmuch-hello.el --- welcome to notmuch, a frontend\r
67 +;;\r
68 +;; Copyright =C2=A9 David Edmondson\r
69 +;;\r
70 +;; This file is part of Notmuch.\r
71 +;;\r
72 +;; Notmuch is free software: you can redistribute it and/or modify it\r
73 +;; under the terms of the GNU General Public License as published by\r
74 +;; the Free Software Foundation, either version 3 of the License, or\r
75 +;; (at your option) any later version.\r
76 +;;\r
77 +;; Notmuch is distributed in the hope that it will be useful, but\r
78 +;; WITHOUT ANY WARRANTY; without even the implied warranty of\r
79 +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
80 +;; General Public License for more details.\r
81 +;;\r
82 +;; You should have received a copy of the GNU General Public License\r
83 +;; along with Notmuch.  If not, see <http://www.gnu.org/licenses/>.\r
84 +;;\r
85 +;; Authors: David Edmondson <dme@dme.org>\r
86 +\r
87 +(require 'widget)\r
88 +\r
89 +(require 'notmuch-lib)\r
90 +\r
91 +(defvar notmuch-hello-searches-to-save 10)\r
92 +(defvar notmuch-hello-search-width 60)\r
93 +\r
94 +(defvar notmuch-hello-recent-searches nil)\r
95 +\r
96 +(defun notmuch-hello-save-search (search)\r
97 +  (if (not (memq search notmuch-hello-recent-searches))\r
98 +      (push search notmuch-hello-recent-searches))\r
99 +  (if (> (length notmuch-hello-recent-searches)\r
100 +        notmuch-hello-searches-to-save)\r
101 +      (setq notmuch-hello-recent-searches (butlast notmuch-hello-recent-se=\r
102 arches))))\r
103 +\r
104 +(defun notmuch-hello-trim (search)\r
105 +  "Trim whitespace."\r
106 +  (if (string-match "^[[:space:]]*\\(.*[^[:space:]]\\)[[:space:]]*$" searc=\r
107 h)\r
108 +      (match-string 1 search)\r
109 +    search))\r
110 +\r
111 +(defun notmuch-hello-search (search)\r
112 +  (let ((search (notmuch-hello-trim search)))\r
113 +    (notmuch-hello-save-search search)\r
114 +    (notmuch-search search)))\r
115 +\r
116 +(defun notmuch-hello ()\r
117 +  (interactive)\r
118 +\r
119 +  (switch-to-buffer "*notmuch-hello*")\r
120 +  (kill-all-local-variables)\r
121 +  (let ((inhibit-read-only t))\r
122 +    (erase-buffer))\r
123 +\r
124 +  (let ((all (overlay-lists)))\r
125 +    ;; Delete all the overlays.\r
126 +    (mapcar 'delete-overlay (car all))\r
127 +    (mapcar 'delete-overlay (cdr all)))\r
128 +\r
129 +  (widget-insert "\nWelcome to notmuch.\n\n")\r
130 +  (let ((start (point)))\r
131 +    (widget-insert "Search: ")\r
132 +    (widget-create 'editable-field\r
133 +                  :size notmuch-hello-search-width\r
134 +                  :action (lambda (widget &rest ignore)\r
135 +                            (let ((search (widget-value widget)))\r
136 +                              (notmuch-hello-search search))))\r
137 +    (widget-insert "\n")\r
138 +    (indent-rigidly start (point) 4))\r
139 +\r
140 +  (when notmuch-hello-recent-searches\r
141 +    (widget-insert "\nRecent searches:\n\n")\r
142 +    (let ((start (point)))\r
143 +      (mapcar '(lambda (search)\r
144 +                (widget-create 'editable-field\r
145 +                               :size notmuch-hello-search-width\r
146 +                               :action (lambda (widget &rest ignore)\r
147 +                                         (let ((search (widget-value widget)))\r
148 +                                           (notmuch-hello-search search)))\r
149 +                               search)\r
150 +                (widget-insert "\n"))\r
151 +             notmuch-hello-recent-searches)\r
152 +      (indent-rigidly start (point) 4)))\r
153 +\r
154 +  (widget-insert "\nFolders:\n\n")\r
155 +  (let ((start (point)))\r
156 +    (mapcar '(lambda (folder)\r
157 +              (let ((w (widget-create 'push-button\r
158 +                                      :notify (lambda (widget &rest ignore)\r
159 +                                                (notmuch-search (widget-get widget :notmuch-search-terms)))\r
160 +                                      "open")))\r
161 +                (widget-put w :notmuch-search-terms (cdr folder)))\r
162 +              (widget-insert (format " %6s %s\n" (notmuch-folder-count (cdr fold=\r
163 er)) (car folder))))\r
164 +           notmuch-folders)\r
165 +    (indent-rigidly start (point) 4))\r
166 +\r
167 +  (widget-insert "\nAll tags:\n\n")\r
168 +  (let ((start (point)))\r
169 +    (mapcar '(lambda (tag)\r
170 +              (let ((w (widget-create 'push-button\r
171 +                                      :notify (lambda (widget &rest ignore)\r
172 +                                                (notmuch-search (widget-get widget :notmuch-search-terms)))\r
173 +                                      "open")))\r
174 +                (widget-put w :notmuch-search-terms (concat "tag:" tag)))\r
175 +              (widget-insert (format " %6s %s\n" (notmuch-folder-count\r
176 +                                                  (concat "tag:" tag))\r
177 +                                     tag)))\r
178 +           (process-lines notmuch-command "search-tags"))\r
179 +    (indent-rigidly start (point) 4))\r
180 +\r
181 +  (use-local-map widget-keymap)\r
182 +  (local-set-key "=3D" 'notmuch-hello)\r
183 +  (local-set-key "q" '(lambda () (interactive) (kill-buffer (current-buffe=\r
184 r))))\r
185 +\r
186 +  (widget-setup)\r
187 +\r
188 +  ;; Always put point inside the `search' widget, which we know is\r
189 +  ;; first.\r
190 +  (goto-char (point-min))\r
191 +  (widget-forward 1))\r
192 \r
193 \r
194 dme.\r
195 --=20\r
196 David Edmondson, http://dme.org\r