Re: Emacs: notmuch-show-mode failing to actually update tags
[notmuch-archives.git] / c0 / 0c1f9c4136eb0bd881df11a1fbc192c455db95
1 Return-Path: <prvs=jrosenthal=663949bcc@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 8104D431FBC\r
6         for <notmuch@notmuchmail.org>; Tue, 23 Feb 2010 07:22:42 -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: -3.467\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-3.467 tagged_above=-999 required=5 tests=[AWL=0.718,\r
12         BAYES_40=-0.185, 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 g2dapuNfWKm6 for <notmuch@notmuchmail.org>;\r
16         Tue, 23 Feb 2010 07:22:40 -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 A8147431FAE\r
19         for <notmuch@notmuchmail.org>; Tue, 23 Feb 2010 07:22:40 -0800 (PST)\r
20 X-IronPort-AV: E=Sophos;i="4.49,526,1262581200"; d="scan'208";a="306798320"\r
21 Received: from c-69-255-36-229.hsd1.md.comcast.net (HELO lucky)\r
22         ([69.255.36.229])\r
23         by ipex2.johnshopkins.edu with ESMTP/TLS/AES256-SHA;\r
24         23 Feb 2010 10:22:38 -0500\r
25 Received: from jkr by lucky with local (Exim 4.69)\r
26         (envelope-from <jrosenthal@jhu.edu>)\r
27         id 1Njwa5-0002nM-LD; Tue, 23 Feb 2010 10:21:49 -0500\r
28 From: Jesse Rosenthal <jrosenthal@jhu.edu>\r
29 To: notmuch@notmuchmail.org\r
30 In-Reply-To: <m1wryiayhg.fsf@watt.gilman.jhu.edu>\r
31 References: <m1y6iybc5h.fsf@watt.gilman.jhu.edu>\r
32         <m1wryiayhg.fsf@watt.gilman.jhu.edu>\r
33 Date: Tue, 23 Feb 2010 10:21:49 -0500\r
34 Message-ID: <87ljekq8oi.fsf@jhu.edu>\r
35 MIME-Version: 1.0\r
36 Content-Type: text/plain; charset=us-ascii\r
37 Subject: [notmuch] [PATCH V3] notmuch.el: Make notmuch-show buffer name\r
38         first subject, instead of thread-id (supersedes V1 and V2)\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: Tue, 23 Feb 2010 15:22:42 -0000\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 optional `buffer-name' argument to notmuch\r
59 show.\r
60 \r
61 This version supersedes V1 and V2 of this patch. It is rebased on HEAD,\r
62 ensures that the buffer names are unique, and that the `notmuch-show'\r
63 command can still be used interactively (fixing a clumsy bug in V2 which\r
64 prevented that).\r
65 \r
66 Signed-off-by: Jesse Rosenthal <jrosenthal@jhu.edu>\r
67 ---\r
68  notmuch.el |   21 +++++++++++++++++----\r
69  1 files changed, 17 insertions(+), 4 deletions(-)\r
70 \r
71 diff --git a/notmuch.el b/notmuch.el\r
72 index 6482170..685b2cd 100644\r
73 --- a/notmuch.el\r
74 +++ b/notmuch.el\r
75 @@ -1162,7 +1162,7 @@ All currently available key bindings:\r
76           (lambda()\r
77             (hl-line-mode 1) ))\r
78  \r
79 -(defun notmuch-show (thread-id &optional parent-buffer query-context)\r
80 +(defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name)\r
81    "Run \"notmuch show\" with the given thread ID and display results.\r
82  \r
83  The optional PARENT-BUFFER is the notmuch-search buffer from\r
84 @@ -1172,7 +1172,10 @@ thread from that buffer can be show when done with this one).\r
85  The optional QUERY-CONTEXT is a notmuch search term. Only messages from the thread\r
86  matching this search term are shown if non-nil. "\r
87    (interactive "sNotmuch show: ")\r
88 -  (let ((buffer (get-buffer-create (concat "*notmuch-show-" thread-id "*"))))\r
89 +  (when (null (buffer-name))\r
90 +    (setq buffer-name (concat "*notmuch-" thread-id "*")))\r
91 +  (let* ((thread-buffer-name (generate-new-buffer-name buffer-name))\r
92 +        (buffer (get-buffer-create thread-buffer-name)))\r
93      (switch-to-buffer buffer)\r
94      (notmuch-show-mode)\r
95      (set (make-local-variable 'notmuch-show-parent-buffer) parent-buffer)\r
96 @@ -1363,9 +1366,19 @@ Complete list of currently available key bindings:\r
97  (defun notmuch-search-show-thread ()\r
98    "Display the currently selected thread."\r
99    (interactive)\r
100 -  (let ((thread-id (notmuch-search-find-thread-id)))\r
101 +  (let ((thread-id (notmuch-search-find-thread-id))\r
102 +       (subject (notmuch-search-find-subject))\r
103 +       buffer-name)\r
104 +    (when (string-match "^[ \t]*$" subject)\r
105 +      (setq subject "[No Subject]"))\r
106 +    (setq buffer-name (concat "*"\r
107 +                             (truncate-string-to-width subject 32 nil nil t)\r
108 +                             "*"))\r
109      (if (> (length thread-id) 0)\r
110 -       (notmuch-show thread-id (current-buffer) notmuch-search-query-string)\r
111 +       (notmuch-show thread-id\r
112 +                     (current-buffer)\r
113 +                     notmuch-search-query-string\r
114 +                     buffer-name)\r
115        (error "End of search results"))))\r
116  \r
117  (defun notmuch-search-reply-to-thread ()\r
118 -- \r
119 1.6.3.3\r
120 \r