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 68D3F431FD2 for ; Wed, 29 Oct 2014 07:19:04 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.699 X-Spam-Level: X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7, UNPARSEABLE_RELAY=0.001] 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 hVREQkypuBHG for ; Wed, 29 Oct 2014 07:18:59 -0700 (PDT) Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com [209.85.212.171]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 7F107431FC7 for ; Wed, 29 Oct 2014 07:18:55 -0700 (PDT) Received: by mail-wi0-f171.google.com with SMTP id q5so1825165wiv.16 for ; Wed, 29 Oct 2014 07:18:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:user-agent:from:to:subject:date:message-id :in-reply-to:references; bh=3t6o74ayQMiwaxEy7OOv4p8ZHhInL1Ew8Mz4BejQ9bc=; b=FcfnKnLb+hs4rfw8tMGaPl7qJ/pjQSD+jWySZk9I4iPq2NsWeisBRLWpxs8RanejkK 9Ua8BsR8oaZssNi8AdDyt00rVg0RoX9E/EPTkhGmn2JVQygiY4V7kLhDN/i5eIqaTCQh uWW7/SP1DRrfOYsqFZgQB/G+6g9ZiOFjKMAy9FtePmSWz7SOWGTOrUgUjfPdHWf86xBA IORhz6VWPP+W6emiMtGIXbiZoj+aElwzO2ABfpr2xBrtjTq7oXFBE3F852UOD55UfvC+ vRQQwrUqEdfcAotfL3Un1StQdwNXnbwHOa+fzMVQg/C61/TyFCukkJXOGue+WO0jK11B O2lg== X-Gm-Message-State: ALoCoQmRD++vCZoAMmkO8B5MTAFf7ECIkHyc8IcgLdqf51dYqLEAdJtyfqh8wnasl3MiPcnPaT48 X-Received: by 10.194.24.197 with SMTP id w5mr13151329wjf.71.1414592333942; Wed, 29 Oct 2014 07:18:53 -0700 (PDT) Received: from disaster-area.hh.sledj.net ([2a01:348:1a2:1:ea39:35ff:fe2c:a227]) by mx.google.com with ESMTPSA id dr5sm5701390wib.4.2014.10.29.07.18.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Oct 2014 07:18:53 -0700 (PDT) Received: from localhost (30000@localhost [local]); by localhost (OpenSMTPD) with ESMTPA id 3af29b73; for ; Wed, 29 Oct 2014 14:18:49 +0000 (UTC) User-Agent: OpenSMTPD enqueuer (Demoostik) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH v2] emacs: Improve the behaviour of the 'q' binding. Date: Wed, 29 Oct 2014 14:18:49 +0000 Message-Id: <1414592329-15899-2-git-send-email-dme@dme.org> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1414592329-15899-1-git-send-email-dme@dme.org> References: <1414592329-15899-1-git-send-email-dme@dme.org> 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: Wed, 29 Oct 2014 14:19:04 -0000 When a user hits 'q' in a notmuch buffer, kill the buffer only if there are no other windows currently showing it. --- emacs/notmuch-lib.el | 13 +++++++++---- emacs/notmuch-show.el | 2 +- emacs/notmuch-tree.el | 2 +- emacs/notmuch.el | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index 1e166c6..fd25f7c 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -135,7 +135,7 @@ For example, if you wanted to remove an \"inbox\" tag and add an (defvar notmuch-common-keymap (let ((map (make-sparse-keymap))) (define-key map "?" 'notmuch-help) - (define-key map "q" 'notmuch-kill-this-buffer) + (define-key map "q" 'notmuch-bury-or-kill-this-buffer) (define-key map "s" 'notmuch-search) (define-key map "z" 'notmuch-tree) (define-key map "m" 'notmuch-mua-new-mail) @@ -239,10 +239,15 @@ depending on the value of `notmuch-poll-script'." (call-process notmuch-poll-script nil nil)) (call-process notmuch-command nil nil nil "new"))) -(defun notmuch-kill-this-buffer () - "Kill the current buffer." +(defun notmuch-bury-or-kill-this-buffer () + "Undisplay the current buffer. + +Bury the current buffer, unless there is only one window showing +it, in which case it is killed." (interactive) - (kill-buffer (current-buffer))) + (if (> (length (get-buffer-window-list nil nil t)) 1) + (bury-buffer) + (kill-buffer))) (defun notmuch-documentation-first-line (symbol) "Return the first line of the documentation string for SYMBOL." diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index a997482..6e03f1e 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1956,7 +1956,7 @@ buffer. If PREVIOUS is non-nil, move to the previous item in the search results instead." (interactive "P") (let ((parent-buffer notmuch-show-parent-buffer)) - (notmuch-kill-this-buffer) + (notmuch-bury-or-kill-this-buffer) (when (buffer-live-p parent-buffer) (switch-to-buffer parent-buffer) (and (if previous diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el index e859cc2..8b6cd51 100644 --- a/emacs/notmuch-tree.el +++ b/emacs/notmuch-tree.el @@ -234,7 +234,7 @@ FUNC." ;; Override because we want to close message pane first. (define-key map [remap notmuch-help] (notmuch-tree-close-message-pane-and #'notmuch-help)) ;; Override because we first close message pane and then close tree buffer. - (define-key map [remap notmuch-kill-this-buffer] 'notmuch-tree-quit) + (define-key map [remap notmuch-bury-or-kill-this-buffer] 'notmuch-tree-quit) ;; Override because we close message pane after the search query is entered. (define-key map [remap notmuch-search] 'notmuch-tree-to-search) ;; Override because we want to close message pane first. diff --git a/emacs/notmuch.el b/emacs/notmuch.el index b44a907..218486a 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -153,7 +153,7 @@ there will be called at other points of notmuch execution." (defvar notmuch-search-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map notmuch-common-keymap) - (define-key map "x" 'notmuch-kill-this-buffer) + (define-key map "x" 'notmuch-bury-or-kill-this-buffer) (define-key map (kbd "") 'notmuch-search-scroll-down) (define-key map "b" 'notmuch-search-scroll-down) (define-key map " " 'notmuch-search-scroll-up) @@ -961,7 +961,7 @@ same relative position within the new buffer." (oldest-first notmuch-search-oldest-first) (target-thread (notmuch-search-find-thread-id 'bare)) (query notmuch-search-query-string)) - (notmuch-kill-this-buffer) + (notmuch-bury-or-kill-this-buffer) (notmuch-search query oldest-first target-thread target-line) (goto-char (point-min)))) -- 2.1.1