--- /dev/null
+Return-Path: <simon_notmuch@phis.me>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 856B36DE19E9\r
+ for <notmuch@notmuchmail.org>; Sat, 2 Jan 2016 14:37:01 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id 9dxEfO8m0p5i for <notmuch@notmuchmail.org>;\r
+ Sat, 2 Jan 2016 14:36:59 -0800 (PST)\r
+X-Greylist: delayed 360 seconds by postgrey-1.35 at arlo;\r
+ Sat, 02 Jan 2016 14:36:59 PST\r
+Received: from labbe.ens-lyon.fr (labbe.ens-lyon.fr [140.77.167.222])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 28AA26DE19CF\r
+ for <notmuch@notmuchmail.org>; Sat, 2 Jan 2016 14:36:59 -0800 (PST)\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by labbe.ens-lyon.fr (Postfix) with ESMTP id 9F83D320BCB\r
+ for <notmuch@notmuchmail.org>; Sat, 2 Jan 2016 23:30:56 +0100 (CET)\r
+X-Virus-Scanned: by amavisd-new-2.10.1 (20141025) (Debian) at ens-lyon.fr\r
+Received: from labbe.ens-lyon.fr ([127.0.0.1])\r
+ by localhost (labbe.ens-lyon.fr [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id SP9a-OwXaIb2; Sat, 2 Jan 2016 23:30:56 +0100 (CET)\r
+Received: from goyave.phis.me (slsu0-06.dsi-ext.ens-lyon.fr [140.77.96.31])\r
+ by labbe.ens-lyon.fr (Postfix) with ESMTP id 8FC9E3206F4;\r
+ Sat, 2 Jan 2016 23:30:55 +0100 (CET)\r
+Received: from goyave.phis.me. (localhost [127.0.0.1])\r
+ by goyave.phis.me (Postfix) with ESMTP id 4850E600524;\r
+ Sat, 2 Jan 2016 23:33:35 +0100 (CET)\r
+From: Simon Castellan <simon_notmuch@phis.me>\r
+To: notmuch@notmuchmail.org\r
+Subject: [BUG] [notmuch-tree] Display problems when database is locked\r
+User-Agent: Notmuch/0.20.2 (http://notmuchmail.org) Emacs/24.4.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Sat, 02 Jan 2016 23:33:35 +0100\r
+Message-ID: <874mev4nnk.fsf@goyave.phis.me>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 02 Jan 2016 22:37:01 -0000\r
+\r
+Hi,\r
+\r
+I'm using notmuch-tree and I encountered a slightly annoying bug. When\r
+browsing through a notmuch-tree buffer, if I open up a message whose\r
+tags needs to be changed (eg. the message needs to be marked read), then\r
+on the /next/ message, the bottom part of the pane does not get killed\r
+and thus, the top part (which is tiny) of the pane gets split again.\r
+\r
+How to reproduce [I'm using notmuch-0.21 and emacs 24.4.1 from debian]\r
+----------------\r
+\r
+1. Mark some messages to be unread and then run (notmuch-tree\r
+"is:unread")\r
+\r
+2. Make sure your notmuch database is locked (for that purpose I run a\r
+ `while true; do notmuch new; done` in a side terminal)\r
+\r
+3. Open the first unread message, then press "n" to go the next one.\r
+ At this point, the screen should be split in three instead of two.\r
+\r
+How to fix it\r
+-------------\r
+\r
+This is due to notmuch-show not returning when the database is locked\r
+and the message cannot be marked read. This results in the end of\r
+notmuch-tree-show-message-in not being executed and some variable\r
+(namely notmuch-tree-message-buffer) having wrong values.\r
+\r
+I am not sure what is the best way to fix it, but what I'm using at a\r
+hack is to wrap around the call to notmuch-show in a\r
+`with-demoted-errors` so that the execution can continue in case of\r
+failure, and close the bottom part in case of a failure. Hence when this\r
+happens, the bottom part disappears which is better than messing up the\r
+window configuration. This is what it looks like:\r
+\r
+ (defun notmuch-tree-show-message-in ()\r
+ "Show the current message (in split-pane)."\r
+ (interactive)\r
+ (let ((id (notmuch-tree-get-message-id))\r
+ (inhibit-read-only t)\r
+ buffer)\r
+ (when id\r
+ ;; We close and reopen the window to kill off un-needed buffers\r
+ ;; this might cause flickering but seems ok.\r
+ (notmuch-tree-close-message-window)\r
+ (setq notmuch-tree-message-window\r
+ (split-window-vertically (/ (window-height) 4)))\r
+ (with-selected-window notmuch-tree-message-window\r
+ ;; Since we are only displaying one message do not indent.\r
+ (let ((notmuch-show-indent-messages-width 0)\r
+ (notmuch-show-only-matching-messages t))\r
+ (setq buffer (with-demoted-errors (notmuch-show id)))))\r
+ (unless buffer\r
+ (delete-window notmuch-tree-message-window))\r
+ (when buffer\r
+ ;; We need the `let' as notmuch-tree-message-window is buffer local.\r
+ (let ((window notmuch-tree-message-window))\r
+ (with-current-buffer buffer\r
+ (setq notmuch-tree-message-window window)\r
+ (add-hook 'kill-buffer-hook 'notmuch-tree-message-window-kill-hook)))\r
+ (setq notmuch-tree-message-buffer buffer)\r
+ (when notmuch-show-mark-read-tags\r
+ (notmuch-tree-tag-update-display notmuch-show-mark-read-tags))\r
+ ))))\r
+ \r
+\r
+Cheers,\r
+\r
+Simon.\r