From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id B23C1431FB6 for ; Tue, 25 Dec 2012 03:47:20 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.201 X-Spam-Level: X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HbaoozFY4dIU for ; Tue, 25 Dec 2012 03:47:20 -0800 (PST) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 0A902431FAE for ; Tue, 25 Dec 2012 03:47:19 -0800 (PST) Received: by mail-wi0-f181.google.com with SMTP id hm9so4396319wib.14 for ; Tue, 25 Dec 2012 03:47:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=x86aCTQG0pbWn0QDbnfFRqxURSBPbhK0zoZ1d/q7F50=; b=bGxfB0gK2EradHRJQuKzIMPq5IsNI7Kaww/MeBOyb0BzlK2T+R8dB6ONZ1YWbhoKjA Jwcvl7uDFXAacUJbmvllbRqFOhrhbhTdisLYHB7xyfXSPmoiiKZkioO/2g2Jg0WJYwyZ 6FIiBGTO0PPkbrdUZD3lVEedRGp+w5QSUBxYhOia1eArwXlLbIxJtT1gYtrGdjJ0dXmL IkdTb5o5mOU041jdYlktFml095ZusL3bVXREiB0oiHUx+JmSm3cJyjUn5E7HO6oCCqTc P8gGfgDO9ocTwrVP/DHfjlDXSrBhatExBbtcsZa+HKvseyZYKtkXBJebCfspGL86THEd R4vw== X-Received: by 10.194.71.140 with SMTP id v12mr39400114wju.36.1356436038906; Tue, 25 Dec 2012 03:47:18 -0800 (PST) Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) by mx.google.com with ESMTPS id bw9sm20886001wib.5.2012.12.25.03.47.17 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 25 Dec 2012 03:47:18 -0800 (PST) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH] contrib: pick: close message pane when quitting from show in the message pane Date: Tue, 25 Dec 2012 11:47:17 +0000 Message-Id: <1356436037-15597-1-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1355650241-27196-1-git-send-email-markwalters1009@gmail.com> References: <1355650241-27196-1-git-send-email-markwalters1009@gmail.com> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Dec 2012 11:47:20 -0000 We add a hook to the show buffer in the message window to close the message window when that buffer quits. It checks that the message-window is still displaying the show-message buffer and then closes it. --- This is just a slightly tidier version of the previous patch. It is more natural to reuse the nomuch-pick-message-window variable (as it serves the same pupose) rather than adding a new variable and cluttering up the name space (and it also keeps the clutter in the notmuch-pick namespace). I think this a good candidate for 0.15: it fixes an annoying bug in pick. Best wishes Mark contrib/notmuch-pick/notmuch-pick.el | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el index 1a553d4..7d01f4c 100644 --- a/contrib/notmuch-pick/notmuch-pick.el +++ b/contrib/notmuch-pick/notmuch-pick.el @@ -157,6 +157,10 @@ (make-variable-buffer-local 'notmuch-pick-query-context) (defvar notmuch-pick-buffer-name nil) (make-variable-buffer-local 'notmuch-pick-buffer-name) +;; This variable is the window used for the message pane. It is set +;; in both the parent pick buffer and the child show buffer. It is +;; used to try and close the message pane when quitting pick or the +;; child show buffer. (defvar notmuch-pick-message-window nil) (make-variable-buffer-local 'notmuch-pick-message-window) (put 'notmuch-pick-message-window 'permanent-local t) @@ -324,6 +328,16 @@ Does NOT change the database." (notmuch-prettify-subject (notmuch-search-find-subject))) (notmuch-pick-show-match-message-with-wait)) +(defun notmuch-pick-message-window-kill-hook () + (let ((buffer (current-buffer))) + (when (and (window-live-p notmuch-pick-message-window) + (eq (window-buffer notmuch-pick-message-window) buffer)) + ;; We do not want an error if this is the sole window in the + ;; frame and I do not know how to test for that in emacs pre + ;; 24. Hence we just ignore-errors. + (ignore-errors + (delete-window notmuch-pick-message-window))))) + (defun notmuch-pick-show-message () "Show the current message (in split-pane)." (interactive) @@ -341,6 +355,11 @@ Does NOT change the database." (let ((notmuch-show-indent-messages-width 0)) (setq current-prefix-arg '(4)) (setq buffer (notmuch-show id nil nil nil)))) + ;; We need the `let' as notmuch-pick-message-window is buffer local. + (let ((window notmuch-pick-message-window)) + (with-current-buffer buffer + (setq notmuch-pick-message-window window) + (add-hook 'kill-buffer-hook 'notmuch-pick-message-window-kill-hook))) (notmuch-pick-tag-update-display (list "-unread")) (setq notmuch-pick-message-buffer buffer)))) -- 1.7.9.1