[PATCH 08/11] cli: add thread recipients to search output
[notmuch-archives.git] / 88 / be75ae901ecc93080592b58b4aa2159a72ba06
1 Return-Path: <servilio@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 6F32B4196F0\r
6         for <notmuch@notmuchmail.org>; Sun, 18 Apr 2010 20:55:52 -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.999\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.999 tagged_above=-999 required=5\r
12         tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,\r
13         DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001] autolearn=ham\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 NEVh95mp3GGU for <notmuch@notmuchmail.org>;\r
17         Sun, 18 Apr 2010 20:55:51 -0700 (PDT)\r
18 Received: from mail-ww0-f53.google.com (mail-ww0-f53.google.com\r
19  [74.125.82.53])        by olra.theworths.org (Postfix) with ESMTP id 41651431FC1       for\r
20  <notmuch@notmuchmail.org>; Sun, 18 Apr 2010 20:55:51 -0700 (PDT)\r
21 Received: by wwg30 with SMTP id 30so188831wwg.26\r
22         for <notmuch@notmuchmail.org>; Sun, 18 Apr 2010 20:55:50 -0700 (PDT)\r
23 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
24         h=domainkey-signature:mime-version:received:date:received:message-id\r
25         :subject:from:to:content-type;\r
26         bh=uxthqHz+FzT3KOu66gIWgpHcKGV4tKZ+OzYhtV6U3t4=;\r
27         b=t7Kww4dNj7WhZhKEBoxVvtsuhEy/Zi/yzH+NoUPJ0iFF17AlhDBTj4nnqGAOXaaOat\r
28         FNmEwycIJEwfbCiukUFIVhI6F5CH0NyDkFpEktsS6I0C8C+ovjWGPw2x7Iq3TEaxCZdL\r
29         FORRbCRv3udJnA/kOWuW/tLEYW9XobSPiN3f4=\r
30 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
31         h=mime-version:date:message-id:subject:from:to:content-type;\r
32         b=bRMMircUZ0BDawRSjsSBOd62kdyOk8sdV0uJ+tXePbAO5j0cfMVcxFT9lF7UA4nDLE\r
33         0aJao6jnnSu6S/LeMi5d+oPZOnpYLmZN5rbKgK2/KKXOZo71rbOwC1IcdxTbqGn8+bau\r
34         f1k+HEiB8cr4AWW4eT0ErxaepN7hh2/YDPhqY=\r
35 MIME-Version: 1.0\r
36 Received: by 10.216.89.140 with HTTP; Sun, 18 Apr 2010 20:55:50 -0700 (PDT)\r
37 Date: Sun, 18 Apr 2010 23:55:50 -0400\r
38 Received: by 10.216.87.147 with SMTP id y19mr6270358wee.136.1271649350308; \r
39         Sun, 18 Apr 2010 20:55:50 -0700 (PDT)\r
40 Message-ID: <x2hb22065d01004182055vc111d42az357076f93b6cb72a@mail.gmail.com>\r
41 Subject: [PATCH] emacs: Try to name search buffers using info in \r
42         notmuch-folders\r
43 From: Servilio Afre Puentes <servilio@gmail.com>\r
44 To: notmuch <notmuch@notmuchmail.org>\r
45 Content-Type: text/plain; charset=ISO-8859-1\r
46 X-BeenThere: notmuch@notmuchmail.org\r
47 X-Mailman-Version: 2.1.13\r
48 Precedence: list\r
49 List-Id: "Use and development of the notmuch mail system."\r
50         <notmuch.notmuchmail.org>\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
54 List-Post: <mailto:notmuch@notmuchmail.org>\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
58 X-List-Received-Date: Mon, 19 Apr 2010 03:55:52 -0000\r
59 \r
60 This patch obsoletes the one sent in message:\r
61 \r
62 r2sb22065d01004150516jf099f3dcw180a7db0dc972c76@mail.gmail.com\r
63 \r
64 8<------\r
65 \r
66 As the user has already defined aliases for certain searches in\r
67 notmuch-folders, search buffer names that use these aliases will\r
68 be easier to identify.\r
69 ---\r
70  emacs/notmuch.el |   23 ++++++++++++++++++++++-\r
71  1 files changed, 22 insertions(+), 1 deletions(-)\r
72 \r
73 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
74 index 0adaf8b..f18b1ac 100644\r
75 --- a/emacs/notmuch.el\r
76 +++ b/emacs/notmuch.el\r
77 @@ -695,6 +695,27 @@ characters as well as `_.+-'.\r
78      (apply 'notmuch-call-notmuch-process "tag"\r
79            (append action-split (list notmuch-search-query-string) nil))))\r
80 \r
81 +(defun notmuch-search-buffer-title (query)\r
82 +  "Returns the title for a buffer with notmuch search results."\r
83 +  (let* ((folder (rassoc-if (lambda (key)\r
84 +                             (string-match (concat "^" (regexp-quote key))\r
85 +                                           query))\r
86 +                           notmuch-folders))\r
87 +        (folder-name (car folder))\r
88 +        (folder-query (cdr folder)))\r
89 +    (cond ((and folder (equal folder-query query))\r
90 +          ;; Query is the same as folder search (ignoring case)\r
91 +          (concat "*notmuch-folder-" folder-name "*"))\r
92 +         (folder\r
93 +          (concat "*notmuch-search-"\r
94 +                  (replace-regexp-in-string (concat "^" (regexp-quote folder-query))\r
95 +                                            (concat "[ " folder-name " ]")\r
96 +                                            query)\r
97 +                  "*"))\r
98 +         (t\r
99 +          (concat "*notmuch-search-" query "*"))\r
100 +         )))\r
101 +\r
102  ;;;###autoload\r
103  (defun notmuch-search (query &optional oldest-first target-thread target-line)\r
104    "Run \"notmuch search\" with the given query string and display results.\r
105 @@ -707,7 +728,7 @@ The optional parameters are used as follows:\r
106    target-line: The line number to move to if the target thread does not\r
107                 appear in the search results."\r
108    (interactive "sNotmuch search: ")\r
109 -  (let ((buffer (get-buffer-create (concat "*notmuch-search-" query "*"))))\r
110 +  (let ((buffer (get-buffer-create (notmuch-search-buffer-title query))))\r
111      (switch-to-buffer buffer)\r
112      (notmuch-search-mode)\r
113      (set 'notmuch-search-query-string query)\r
114 -- \r
115 1.7.0.4\r