[notmuch] [PATCH V4] notmuch.el: Make notmuch-show buffer name first subject, instead...
authorJesse Rosenthal <jrosenthal@jhu.edu>
Sat, 6 Mar 2010 14:20:21 +0000 (09:20 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:36:20 +0000 (09:36 -0800)
d3/0abf72aacd1ff89220a8cab31c65be02ced900 [new file with mode: 0644]

diff --git a/d3/0abf72aacd1ff89220a8cab31c65be02ced900 b/d3/0abf72aacd1ff89220a8cab31c65be02ced900
new file mode 100644 (file)
index 0000000..7a5fb79
--- /dev/null
@@ -0,0 +1,128 @@
+Return-Path: <prvs=jrosenthal=674496b16@jhu.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id D7BC1431FD2\r
+       for <notmuch@notmuchmail.org>; Sat,  6 Mar 2010 06:20:39 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -3.606\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-3.606 tagged_above=-999 required=5 tests=[AWL=0.393,\r
+       BAYES_50=0.001, RCVD_IN_DNSWL_MED=-4] autolearn=ham\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id d2q0132gHv3y for <notmuch@notmuchmail.org>;\r
+       Sat,  6 Mar 2010 06:20:39 -0800 (PST)\r
+Received: from ipex4.johnshopkins.edu (ipex4.johnshopkins.edu\r
+       [128.220.161.141])\r
+       by olra.theworths.org (Postfix) with ESMTP id 0701C431FCF\r
+       for <notmuch@notmuchmail.org>; Sat,  6 Mar 2010 06:20:38 -0800 (PST)\r
+X-IronPort-AV: E=Sophos;i="4.49,594,1262581200"; d="scan'208";a="342733273"\r
+Received: from c-69-255-36-229.hsd1.md.comcast.net (HELO lucky)\r
+       ([69.255.36.229])\r
+       by ipex4.johnshopkins.edu with ESMTP/TLS/AES256-SHA;\r
+       06 Mar 2010 09:20:25 -0500\r
+Received: from jkr by lucky with local (Exim 4.69)\r
+       (envelope-from <jrosenthal@jhu.edu>)\r
+       id 1Nnurd-0001ky-MU; Sat, 06 Mar 2010 09:20:21 -0500\r
+From: Jesse Rosenthal <jrosenthal@jhu.edu>\r
+To: notmuch@notmuchmail.org\r
+In-Reply-To: <87ljekq8oi.fsf@jhu.edu>\r
+References: <m1y6iybc5h.fsf@watt.gilman.jhu.edu>\r
+       <m1wryiayhg.fsf@watt.gilman.jhu.edu> <87ljekq8oi.fsf@jhu.edu>\r
+Date: Sat, 06 Mar 2010 09:20:21 -0500\r
+Message-ID: <876359cz16.fsf@jhu.edu>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Subject: [notmuch] [PATCH V4] notmuch.el: Make notmuch-show buffer name\r
+       first subject, instead of thread-id (supersedes V1--3)\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 06 Mar 2010 14:20:40 -0000\r
+\r
+(Embarassing -- this should be the last fix.)\r
+\r
+Change the buffer name to a uniquified subject of the thread (i.e. the\r
+subject of the first message in the thread) instead of the thread-id. This\r
+is more meaningful to the user, and will make it easier to scroll through\r
+numerous open buffers.\r
+\r
+Note that this patch adds an optional `buffer-name' argument to notmuch\r
+show.\r
+\r
+This version supersedes V1--3 of this patch. It is rebased on HEAD,\r
+ensures that the buffer names are unique, and that the `notmuch-show'\r
+command can still be used interactively (fixing embarassing bugs in V2\r
+and V3 which prevented that)\r
+\r
+Signed-off-by: Jesse Rosenthal <jrosenthal@jhu.edu>\r
+---\r
+ notmuch.el |   25 ++++++++++++++++++++-----\r
+ 1 files changed, 20 insertions(+), 5 deletions(-)\r
+\r
+diff --git a/notmuch.el b/notmuch.el\r
+index 5577dde..5a893da 100644\r
+--- a/notmuch.el\r
++++ b/notmuch.el\r
+@@ -1172,7 +1172,7 @@ All currently available key bindings:\r
+         (lambda()\r
+           (hl-line-mode 1) ))\r
\r
+-(defun notmuch-show (thread-id &optional parent-buffer query-context)\r
++(defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name)\r
+   "Run \"notmuch show\" with the given thread ID and display results.\r
\r
+ The optional PARENT-BUFFER is the notmuch-search buffer from\r
+@@ -1180,9 +1180,14 @@ which this notmuch-show command was executed, (so that the next\r
+ thread from that buffer can be show when done with this one).\r
\r
+ The optional QUERY-CONTEXT is a notmuch search term. Only messages from the thread\r
+-matching this search term are shown if non-nil. "\r
++matching this search term are shown if non-nil. \r
++\r
++The optional BUFFER-NAME provides the neame of the buffer in which the message thread is shown. If it is nil (which occurs when the command is called interactively) the argument to the function is used. "\r
+   (interactive "sNotmuch show: ")\r
+-  (let ((buffer (get-buffer-create (concat "*notmuch-show-" thread-id "*"))))\r
++  (when (null buffer-name)\r
++    (setq buffer-name (concat "*notmuch-" thread-id "*")))\r
++  (let* ((thread-buffer-name (generate-new-buffer-name buffer-name))\r
++       (buffer (get-buffer-create thread-buffer-name)))\r
+     (switch-to-buffer buffer)\r
+     (notmuch-show-mode)\r
+     (set (make-local-variable 'notmuch-show-parent-buffer) parent-buffer)\r
+@@ -1373,9 +1378,19 @@ Complete list of currently available key bindings:\r
+ (defun notmuch-search-show-thread ()\r
+   "Display the currently selected thread."\r
+   (interactive)\r
+-  (let ((thread-id (notmuch-search-find-thread-id)))\r
++  (let ((thread-id (notmuch-search-find-thread-id))\r
++      (subject (notmuch-search-find-subject))\r
++      buffer-name)\r
++    (when (string-match "^[ \t]*$" subject)\r
++      (setq subject "[No Subject]"))\r
++    (setq buffer-name (concat "*"\r
++                            (truncate-string-to-width subject 32 nil nil t)\r
++                            "*"))\r
+     (if (> (length thread-id) 0)\r
+-      (notmuch-show thread-id (current-buffer) notmuch-search-query-string)\r
++      (notmuch-show thread-id\r
++                    (current-buffer)\r
++                    notmuch-search-query-string\r
++                    buffer-name)\r
+       (error "End of search results"))))\r
\r
+ (defun notmuch-search-reply-to-thread ()\r
+-- \r
+1.6.3.3\r
+\r