From 1bdb1a3e4ecea67cdb9b2e6e6eab21830fb8d23c Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sun, 16 Dec 2012 09:30:41 +0000 Subject: [PATCH] [PATCH] contrib: pick: close message pane when quitting from show in the message pane --- a1/e092f6a84334c9db435e7d906e7ac47aeb07f1 | 128 ++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 a1/e092f6a84334c9db435e7d906e7ac47aeb07f1 diff --git a/a1/e092f6a84334c9db435e7d906e7ac47aeb07f1 b/a1/e092f6a84334c9db435e7d906e7ac47aeb07f1 new file mode 100644 index 000000000..917d7dd9e --- /dev/null +++ b/a1/e092f6a84334c9db435e7d906e7ac47aeb07f1 @@ -0,0 +1,128 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id CF919431FC2 + for ; Sun, 16 Dec 2012 01:30:47 -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 UtAoBCWBM8el for ; + Sun, 16 Dec 2012 01:30:47 -0800 (PST) +Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com + [209.85.212.175]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 2EAE2431FB6 + for ; Sun, 16 Dec 2012 01:30:46 -0800 (PST) +Received: by mail-wi0-f175.google.com with SMTP id hm11so1351241wib.2 + for ; Sun, 16 Dec 2012 01:30:44 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; + bh=bst34kfln3z5t1lBP8Rmkjk/Qld78nML4zWKE18xYsg=; + b=Cqx4SrFYFv+21fTYDMp6kuY0UHQ3ip3NuHDXulQvciY1NDp87ejDe/ptqGwo+yrhwv + N13lAN94RrHhwC1iEtTucSMNZxkVeSJco3KkzQWfO7jzmOd+92e2hnuoosJdUl4dzZu4 + Bi8CUMRZRc7GWKL510q6Z30HF9l43+1eN2+kfa2JZLXPHBdWVD5/D+sKaBvvsUEl4gcU + h5ArtlRz8hgaayBZispst79bH0yk1KWmbSsBK1CJSsWuFUBct35jNe2Ibqho7wNWWT3z + Rw82QhKYaYV26RJHxbmhbsQGl3vR7XMeJjrTIbVPQIkdI8ZzpSzggAz3rmi8DhFFjNtL + x+HA== +Received: by 10.194.86.72 with SMTP id n8mr11374134wjz.19.1355650243204; + Sun, 16 Dec 2012 01:30:43 -0800 (PST) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPS id p3sm5649301wic.8.2012.12.16.01.30.41 + (version=TLSv1/SSLv3 cipher=OTHER); + Sun, 16 Dec 2012 01:30:42 -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: Sun, 16 Dec 2012 09:30:41 +0000 +Message-Id: <1355650241-27196-1-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1355391109-4150-1-git-send-email-markwalters1009@gmail.com> +References: <1355391109-4150-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: Sun, 16 Dec 2012 09:30:47 -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 (probably) a rather better version than the previous +attempt. It uses hooks rather than redefining notmuch-kill-this-buffer +and it avoids errors if the user has made the message pane the whole +frame. + +Best wishes + +Mark + + + contrib/notmuch-pick/notmuch-pick.el | 18 ++++++++++++++++++ + 1 files changed, 18 insertions(+), 0 deletions(-) + +diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el +index 043e9e7..8383589 100644 +--- a/contrib/notmuch-pick/notmuch-pick.el ++++ b/contrib/notmuch-pick/notmuch-pick.el +@@ -160,6 +160,9 @@ + (defvar notmuch-pick-message-window nil) + (make-variable-buffer-local 'notmuch-pick-message-window) + (put 'notmuch-pick-message-window 'permanent-local t) ++(defvar notmuch-show-message-window nil) ++(make-variable-buffer-local 'notmuch-show-message-window) ++(put 'notmuch-show-message-window 'permanent-local t) + (defvar notmuch-pick-message-buffer nil) + (make-variable-buffer-local 'notmuch-pick-message-buffer-name) + (put 'notmuch-pick-message-buffer-name 'permanent-local t) +@@ -389,6 +392,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-show-message-window) ++ (eq (window-buffer notmuch-show-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-show-message-window))))) ++ + (defun notmuch-pick-show-message () + "Show the current message (in split-pane)." + (interactive) +@@ -406,6 +419,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-show-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 + -- 2.26.2