Re: [feature request] emacs: use `notmuch insert` for FCC
[notmuch-archives.git] / 44 / 83d409166854dd0380b62677ba77ca262384d6
1 Return-Path: <prvs=jrosenthal=65281eaca@jhu.edu>\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 6BB3E431FBC\r
6         for <notmuch@notmuchmail.org>; Fri, 12 Feb 2010 14:19:27 -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: -4.617\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-4.617 tagged_above=-999 required=5 tests=[AWL=1.982,\r
12         BAYES_00=-2.599, RCVD_IN_DNSWL_MED=-4] 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 5giOg-ynv2iE for <notmuch@notmuchmail.org>;\r
16         Fri, 12 Feb 2010 14:19:25 -0800 (PST)\r
17 Received: from ipex2.johnshopkins.edu (ipex2.johnshopkins.edu [162.129.8.151])\r
18         by olra.theworths.org (Postfix) with ESMTP id DD97B431FAE\r
19         for <notmuch@notmuchmail.org>; Fri, 12 Feb 2010 14:19:24 -0800 (PST)\r
20 X-IronPort-Anti-Spam-Filtered: true\r
21 X-IronPort-Anti-Spam-Result: AvsEAN9idUuA3DZF/2dsb2JhbACbBHSyD4QtiFWEWASDEw\r
22 X-IronPort-AV: E=Sophos;i="4.49,463,1262581200"; d="scan'208";a="303224352"\r
23 Received: from watt.gilman.jhu.edu ([128.220.54.69])\r
24         by ipex2.johnshopkins.edu with ESMTP/TLS/ADH-AES256-SHA;\r
25         12 Feb 2010 17:19:24 -0500\r
26 Received: by watt.gilman.jhu.edu (Postfix, from userid 502)\r
27         id DA5B13FC031; Fri, 12 Feb 2010 17:19:23 -0500 (EST)\r
28 From: Jesse Rosenthal <jrosenthal@jhu.edu>\r
29 To: notmuch@notmuchmail.org\r
30 In-Reply-To: <m1y6iybc5h.fsf@watt.gilman.jhu.edu>\r
31 References: <m1y6iybc5h.fsf@watt.gilman.jhu.edu>\r
32 Date: Fri, 12 Feb 2010 17:19:23 -0500\r
33 Message-ID: <m1wryiayhg.fsf@watt.gilman.jhu.edu>\r
34 MIME-Version: 1.0\r
35 Content-Type: text/plain; charset=us-ascii\r
36 Subject: [notmuch] [PATCH v2] notmuch.el: Make notmuch-show buffer name\r
37         first subject, instead of thread-id\r
38 X-BeenThere: notmuch@notmuchmail.org\r
39 X-Mailman-Version: 2.1.13\r
40 Precedence: list\r
41 List-Id: "Use and development of the notmuch mail system."\r
42         <notmuch.notmuchmail.org>\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
46 List-Post: <mailto:notmuch@notmuchmail.org>\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
50 X-List-Received-Date: Fri, 12 Feb 2010 22:19:27 -0000\r
51 \r
52 \r
53 Change the buffer name to a uniquified subject of the thread (i.e. the\r
54 subject of the first message in the thread) instead of the thread-id. This\r
55 is more meaningful to the user, and will make it easier to scroll through\r
56 numerous open buffers.\r
57 \r
58 Note that this patch adds an optionsal `buffer-name' argument to notmuch\r
59 show.\r
60 \r
61 This version of the patch improves on the first version by ensuring that\r
62 the buffer names are unique, and that the `notmuch-show' command can\r
63 still be used interactively.\r
64 \r
65 Signed-off-by: Jesse Rosenthal <jrosenthal@jhu.edu>\r
66 ---\r
67  notmuch.el |   25 +++++++++++++++++++------\r
68  1 files changed, 19 insertions(+), 6 deletions(-)\r
69 \r
70 diff --git a/notmuch.el b/notmuch.el\r
71 index 040997e..9667320 100644\r
72 --- a/notmuch.el\r
73 +++ b/notmuch.el\r
74 @@ -1041,7 +1041,7 @@ All currently available key bindings:\r
75           (lambda()\r
76             (hl-line-mode 1) ))\r
77  \r
78 -(defun notmuch-show (thread-id &optional parent-buffer query-context)\r
79 +(defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name)\r
80    "Run \"notmuch show\" with the given thread ID and display results.\r
81  \r
82  The optional PARENT-BUFFER is the notmuch-search buffer from\r
83 @@ -1051,7 +1051,8 @@ thread from that buffer can be show when done with this one).\r
84  The optional QUERY-CONTEXT is a notmuch search term. Only messages from the thread\r
85  matching this search term are shown if non-nil. "\r
86    (interactive "sNotmuch show: ")\r
87 -  (let ((buffer (get-buffer-create (concat "*notmuch-show-" thread-id "*"))))\r
88 +  (let* ((thread-buffer-name (generate-new-buffer-name buffer-name))\r
89 +        (buffer (get-buffer-create thread-buffer-name)))\r
90      (switch-to-buffer buffer)\r
91      (notmuch-show-mode)\r
92      (set (make-local-variable 'notmuch-show-parent-buffer) parent-buffer)\r
93 @@ -1063,8 +1064,10 @@ matching this search term are shown if non-nil. "\r
94        (erase-buffer)\r
95        (goto-char (point-min))\r
96        (save-excursion\r
97 -       (let* ((basic-args (list notmuch-command nil t nil "show" "--entire-thread" thread-id))\r
98 -               (args (if query-context (append basic-args (list "and (" query-context ")")) basic-args)))\r
99 +       (let* ((basic-args (list notmuch-command nil t nil "show" "--entire-thread" "\'" thread-id))\r
100 +               (args (if query-context\r
101 +                         (append basic-args (list "and (" query-context ")\'"))\r
102 +                       (append basic-args (list "\'")))))\r
103           (apply 'call-process args)\r
104           (when (and (eq (buffer-size) 0) query-context)\r
105             (apply 'call-process basic-args)))\r
106 @@ -1242,9 +1245,19 @@ Complete list of currently available key bindings:\r
107  (defun notmuch-search-show-thread ()\r
108    "Display the currently selected thread."\r
109    (interactive)\r
110 -  (let ((thread-id (notmuch-search-find-thread-id)))\r
111 +  (let ((thread-id (notmuch-search-find-thread-id))\r
112 +       (subject (notmuch-search-find-subject))\r
113 +       buffer-name)\r
114 +    (when (string-match "^[ \t]*$" subject)\r
115 +      (setq subject "[No Subject]"))\r
116 +    (setq buffer-name (concat "*"\r
117 +                             (truncate-string-to-width subject 32 nil nil t)\r
118 +                             "*"))\r
119      (if (> (length thread-id) 0)\r
120 -       (notmuch-show thread-id (current-buffer) notmuch-search-query-string)\r
121 +       (notmuch-show thread-id\r
122 +                     (current-buffer)\r
123 +                     notmuch-search-query-string\r
124 +                     buffer-name)\r
125        (error "End of search results"))))\r
126  \r
127  (defun notmuch-search-reply-to-thread ()\r
128 -- \r
129 1.6.5.3\r
130 \r