Re: [PATCH 1/2] Add Google Inc. to AUTHORS as a contributor.
[notmuch-archives.git] / 11 / fe2a0ca7a4b8c065df7a145905192eaaed568e
1 Return-Path: <pieter@praet.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 95F3A42117E\r
6         for <notmuch@notmuchmail.org>; Sun, 29 Jan 2012 23:15:11 -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.677\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.677 tagged_above=-999 required=5\r
12         tests=[HS_INDEX_PARAM=0.023, RCVD_IN_DNSWL_LOW=-0.7]\r
13         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 VMzreRimSV0J for <notmuch@notmuchmail.org>;\r
17         Sun, 29 Jan 2012 23:15:08 -0800 (PST)\r
18 Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
19         [209.85.212.181]) (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 AD707429E4E\r
22         for <notmuch@notmuchmail.org>; Sun, 29 Jan 2012 23:15:04 -0800 (PST)\r
23 Received: by mail-wi0-f181.google.com with SMTP id hi8so3322964wib.26\r
24         for <notmuch@notmuchmail.org>; Sun, 29 Jan 2012 23:15:04 -0800 (PST)\r
25 Received: by 10.180.93.194 with SMTP id cw2mr8490259wib.0.1327907704403;\r
26         Sun, 29 Jan 2012 23:15:04 -0800 (PST)\r
27 Received: from localhost ([109.131.39.11])\r
28         by mx.google.com with ESMTPS id eq5sm49621542wib.2.2012.01.29.23.15.03\r
29         (version=TLSv1/SSLv3 cipher=OTHER);\r
30         Sun, 29 Jan 2012 23:15:04 -0800 (PST)\r
31 From: Pieter Praet <pieter@praet.org>\r
32 To: David Edmondson <dme@dme.org>\r
33 Subject: [PATCH v2 2/2] emacs: add `notmuch-show-stash-mlarchive-link{,\r
34         -and-go}'\r
35 Date: Mon, 30 Jan 2012 08:12:54 +0100\r
36 Message-Id: <1327907574-12760-2-git-send-email-pieter@praet.org>\r
37 X-Mailer: git-send-email 1.7.8.1\r
38 In-Reply-To: <1327397873-20596-1-git-send-email-dme@dme.org>\r
39 References: <1327397873-20596-1-git-send-email-dme@dme.org>\r
40 Cc: Notmuch Mail <notmuch@notmuchmail.org>\r
41 X-BeenThere: notmuch@notmuchmail.org\r
42 X-Mailman-Version: 2.1.13\r
43 Precedence: list\r
44 List-Id: "Use and development of the notmuch mail system."\r
45         <notmuch.notmuchmail.org>\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
49 List-Post: <mailto:notmuch@notmuchmail.org>\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
53 X-List-Received-Date: Mon, 30 Jan 2012 07:15:11 -0000\r
54 \r
55 * emacs/notmuch-show.el\r
56 \r
57   (notmuch-show-stash-mlarchive-link-alist):\r
58     New defcustom of type `alist' (key = name, value = URI),\r
59     containing Mailing List Archive URI's for searching by Message-Id.\r
60 \r
61   (notmuch-show-stash-mlarchive-link-default):\r
62     New defcustom, default MLA to use when `notmuch-show-stash-mlarchive-link'\r
63     received no user input whatsoever.  Available choices are generated using\r
64     the contents of `notmuch-show-stash-mlarchive-link-alist'.\r
65 \r
66   (notmuch-show-stash-map):\r
67     Added keybinds "l" and "L" for `notmuch-show-stash-mlarchive-link'\r
68     respectively `notmuch-show-stash-mlarchive-link-and-go'.\r
69 \r
70   (notmuch-show-stash-mlarchive-link):\r
71     New function, stashes a URI pointing to the current message at one\r
72     of the MLAs configured in `notmuch-show-stash-mlarchive-link-alist'.\r
73     Prompts user with `completing-read' if not provided with an MLA key.\r
74 \r
75   (notmuch-show-stash-mlarchive-link-and-go):\r
76     New function, uses `notmuch-show-stash-mlarchive-link' to\r
77     stash a URI, and then visits it using the browser configured\r
78     in `browse-url-browser-function'.\r
79 \r
80 * test/emacs\r
81 \r
82   Expanded subtest "Stashing in notmuch-show" wrt new functions\r
83   `notmuch-show-stash-mlarchive-link{,-and-go}'.\r
84 \r
85 \r
86 Based on original work [1] by David Edmondson <dme@dme.org>.\r
87 \r
88 [1] id:"1327397873-20596-1-git-send-email-dme@dme.org"\r
89 \r
90 ---\r
91 \r
92 Addressed comments by David Edmondson [2] and Dmitry Kurochkin [3].\r
93 \r
94 [2] id:"cunsjj1jyfj.fsf@hotblack-desiato.hh.sledj.net"\r
95 [3] id:"87zkd9je5j.fsf@gmail.com"\r
96 \r
97  emacs/notmuch-show.el |   61 +++++++++++++++++++++++++++++++++++++++++++++++++\r
98  test/emacs            |    8 +++++-\r
99  2 files changed, 68 insertions(+), 1 deletions(-)\r
100 \r
101 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
102 index b13d088..3d1312c 100644\r
103 --- a/emacs/notmuch-show.el\r
104 +++ b/emacs/notmuch-show.el\r
105 @@ -124,6 +124,35 @@ indentation."\r
106                  (const :tag "View interactively"\r
107                         notmuch-show-interactively-view-part)))\r
108  \r
109 +(defcustom notmuch-show-stash-mlarchive-link-alist\r
110 +  '(("Gmane" . "http://mid.gmane.org/")\r
111 +    ("MARC" . "http://marc.info/?i=")\r
112 +    ("Mail Archive, The" . "http://mail-archive.com/search?l=mid&q=")\r
113 +    ;; FIXME: can these services be searched by `Message-Id' ?\r
114 +    ;; ("MarkMail" . "http://markmail.org/")\r
115 +    ;; ("Nabble" . "http://nabble.com/")\r
116 +    ;; ("opensubscriber" . "http://opensubscriber.com/")\r
117 +    )\r
118 +  "List of Mailing List Archives to use when stashing links.\r
119 +\r
120 +These URIs are concatenated with the current message's\r
121 +Message-Id in `notmuch-show-stash-mlarchive-link'."\r
122 +  :type '(alist :key-type (string :tag "Name")\r
123 +               :value-type (string :tag "URL"))\r
124 +  :group 'notmuch-show)\r
125 +\r
126 +(defcustom notmuch-show-stash-mlarchive-link-default "Gmane"\r
127 +  "Default Mailing List Archive to use when stashing links.\r
128 +\r
129 +This is used when `notmuch-show-stash-mlarchive-link' isn't\r
130 +provided with an MLA argument nor `completing-read' input."\r
131 +  :type `(choice\r
132 +         ,@(mapcar\r
133 +            (lambda (mla)\r
134 +              (list 'const :tag (car mla) :value (car mla)))\r
135 +            notmuch-show-stash-mlarchive-link-alist))\r
136 +  :group 'notmuch-show)\r
137 +\r
138  (defmacro with-current-notmuch-show-message (&rest body)\r
139    "Evaluate body with current buffer set to the text of current message"\r
140    `(save-excursion\r
141 @@ -1048,6 +1077,8 @@ thread id.  If a prefix is given, crypto processing is toggled."\r
142      (define-key map "s" 'notmuch-show-stash-subject)\r
143      (define-key map "T" 'notmuch-show-stash-tags)\r
144      (define-key map "t" 'notmuch-show-stash-to)\r
145 +    (define-key map "l" 'notmuch-show-stash-mlarchive-link)\r
146 +    (define-key map "L" 'notmuch-show-stash-mlarchive-link-and-go)\r
147      map)\r
148    "Submap for stash commands")\r
149  (fset 'notmuch-show-stash-map notmuch-show-stash-map)\r
150 @@ -1640,6 +1671,36 @@ buffer."\r
151    (interactive)\r
152    (notmuch-common-do-stash (notmuch-show-get-to)))\r
153  \r
154 +(defun notmuch-show-stash-mlarchive-link (&optional mla)\r
155 +  "Copy an ML Archive URI for the current message to the kill-ring.\r
156 +\r
157 +This presumes that the message is available at the selected Mailing List Archive.\r
158 +\r
159 +If optional argument MLA is non-nil, use the provided key instead of prompting\r
160 +the user (see `notmuch-show-stash-mlarchive-link-alist')."\r
161 +  (interactive)\r
162 +  (notmuch-common-do-stash\r
163 +   (concat (cdr (assoc\r
164 +                (or mla\r
165 +                    (let ((completion-ignore-case t))\r
166 +                      (completing-read\r
167 +                       "Mailing List Archive: "\r
168 +                       notmuch-show-stash-mlarchive-link-alist\r
169 +                       nil t nil nil notmuch-show-stash-mlarchive-link-default)))\r
170 +                notmuch-show-stash-mlarchive-link-alist))\r
171 +          (notmuch-show-get-message-id t))))\r
172 +\r
173 +(defun notmuch-show-stash-mlarchive-link-and-go (&optional mla)\r
174 +  "Copy an ML Archive URI for the current message to the kill-ring and visit it.\r
175 +\r
176 +This presumes that the message is available at the selected Mailing List Archive.\r
177 +\r
178 +If optional argument MLA is non-nil, use the provided key instead of prompting\r
179 +the user (see `notmuch-show-stash-mlarchive-link-alist')."\r
180 +  (interactive)\r
181 +  (notmuch-show-stash-mlarchive-link mla)\r
182 +  (browse-url (current-kill 0 t)))\r
183 +\r
184  ;; Commands typically bound to buttons.\r
185  \r
186  (defun notmuch-show-part-button-default (&optional button)\r
187 diff --git a/test/emacs b/test/emacs\r
188 index 8ca4c8a..38df3a3 100755\r
189 --- a/test/emacs\r
190 +++ b/test/emacs\r
191 @@ -382,9 +382,12 @@ test_emacs '(notmuch-show "id:\"bought\"")\r
192         (notmuch-show-stash-message-id-stripped)\r
193         (notmuch-show-stash-tags)\r
194         (notmuch-show-stash-filename)\r
195 +       (notmuch-show-stash-mlarchive-link "Gmane")\r
196 +       (notmuch-show-stash-mlarchive-link "MARC")\r
197 +       (notmuch-show-stash-mlarchive-link "Mail Archive, The")\r
198         (switch-to-buffer\r
199           (generate-new-buffer "*test-stashing*"))\r
200 -       (dotimes (i 9)\r
201 +       (dotimes (i 12)\r
202           (yank)\r
203           (insert "\n")\r
204           (rotate-yank-pointer 1))\r
205 @@ -400,6 +403,9 @@ id:"bought"\r
206  bought\r
207  inbox,stashtest\r
208  ${gen_msg_filename}\r
209 +http://mid.gmane.org/bought\r
210 +http://marc.info/?i=bought\r
211 +http://mail-archive.com/search?l=mid&q=bought\r
212  EOF\r
213  test_expect_equal_file OUTPUT EXPECTED\r
214  \r
215 -- \r
216 1.7.8.1\r
217 \r