From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 2QvKI3bOMl+CBgAA0tVLHw (envelope-from ) for ; Tue, 11 Aug 2020 16:59:34 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id mDNiHXbOMl8WQQAAbx9fmQ (envelope-from ) for ; Tue, 11 Aug 2020 16:59:34 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B62E09404E2 for ; Tue, 11 Aug 2020 16:59:32 +0000 (UTC) Received: from [144.217.243.247] (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 398C628389; Tue, 11 Aug 2020 12:59:22 -0400 (EDT) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by mail.notmuchmail.org (Postfix) with ESMTPS id 226E11F9DC for ; Tue, 11 Aug 2020 12:59:20 -0400 (EDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 6F40DDE4; Tue, 11 Aug 2020 12:59:16 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 11 Aug 2020 12:59:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm3; bh=zoFq5sPCFrRmt2eD+80Y3Ly8dz U+CxxaXJZPeGqE/5E=; b=Puvy0/6hAR2wOU9HpWTLT/Z1UHmm9aC7lFvcgMy2LD ffrVqKDmEsnJYgHuVz8v0FTWHSOiQXHBiPr2YTBqZXbqMaVIdpUIPEooUAeYj6yh JizODEe8e4ITNWdl4oBWlTdV7nfUJpTYGsX+USJBnp/7HB1fNNhwptDX/PJoGfT1 b4+pA7xeCITZ5dft1XQgiqaiFSJw9aZOhZmofbhvNGIH05khnH4wBBDng88OWN6E Rw3F+hg2LDmCf/8k4JDa4XHcRHLf6oSm8s4F/Fz2iVL659jPtwefnxVGFO5ijhcL xFg5HWlw+m/uq9mmDXrWjSt/2c9Y+MTHjvTxCdwAE1tg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=zoFq5sPCFrRmt2eD+ 80Y3Ly8dzU+CxxaXJZPeGqE/5E=; b=JP/kx0lX51932o0wtiBAHRhvgS7T9DNVt INatJv2z9TaMwaK453lO3zgkpyitzmpmf/4mkdSJrGR1PJdp8q5YPOAssNi0aNAX IcLpKdqvwCwlOcDHySq4NSavWToMdng537sV8d9WF4oFmgmOBYDsYcYE4S8k2KgZ cJ3LhuecFwWoHJLH1WWZ+9GpNQTKKvtX/8GIK7ivwG7Ka7bu9aFfmu4ymVjhvL2T x9BLgiqngPfCG/CJc8n878Q3On5BDKA2o+uGZFKcxZweZY2wc3YWpafo0UUy2Zik sZN4Rx6q6AtjFTx2F8nPNwiQFjEFW/gCbSvJ2NI6DKK8KTs8Qy2lg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrledtgddutdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkggfgsedtkeertddttd dtnecuhfhrohhmpefuvggrnhcuhghhihhtthhonhcuoehsphifhhhithhtohhnsehsphif hhhithhtohhnrdhnrghmvgeqnecuggftrfgrthhtvghrnhepgedtueeufeeludehtddvhe egvedutdefhfehffetveegjeeitdeghfejgedtteeunecuvehluhhsthgvrhfuihiivgep tdenucfrrghrrghmpehmrghilhhfrhhomhepshhpfihhihhtthhonhesshhpfihhihhtth honhdrnhgrmhgv X-ME-Proxy: From: Sean Whitton To: notmuch@notmuchmail.org Cc: Sean Whitton Subject: [PATCH v2] emacs: Use pop-to-buffer-same-window rather than switch-to-buffer Date: Tue, 11 Aug 2020 09:59:13 -0700 Message-Id: <20200811165913.4459-1-spwhitton@spwhitton.name> MIME-Version: 1.0 Message-ID-Hash: FGL73NDPETYKYE2WGJG4Y6T3QKAYJ5UB X-Message-ID-Hash: FGL73NDPETYKYE2WGJG4Y6T3QKAYJ5UB X-MailFrom: spwhitton@spwhitton.name X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (body hash did not verify) header.d=spwhitton.name header.s=fm3 header.b=Puvy0/6h; dkim=fail (body hash did not verify) header.d=messagingengine.com header.s=fm3 header.b=JP/kx0lX; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Spam-Score: 2.53 X-TUID: 6Vy7fNmygG/9 This means that notmuch commands obey display-buffer-alist so the user can customize how buffers show up. It also permits the use of C-x 4 4, C-x 5 5 and C-x t t, available in Emacs 28. For example, one can use C-x 4 4 M-x notmuch-jump-search RET to open a saved search in another window rather than the current window. Or in notmuch-search mode, C-x 5 5 RET to view the message at point in a new frame. notmuch-tree has custom buffer display logic, so bind display-buffer-overriding-action to make pop-to-buffer-same-window behave exactly as switch-to-buffer while that function is running. --- Changes since v1: rebased onto latest master. emacs/notmuch-draft.el | 3 ++- emacs/notmuch-hello.el | 2 +- emacs/notmuch-show.el | 8 ++++---- emacs/notmuch-tree.el | 13 +++++++++---- emacs/notmuch.el | 4 ++-- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el index 759e6c9e..283830ad 100644 --- a/emacs/notmuch-draft.el +++ b/emacs/notmuch-draft.el @@ -232,7 +232,8 @@ applied to newly inserted messages)." (draft (equal tags (notmuch-update-tags tags notmuch-draft-tags)))) (when (or draft (yes-or-no-p "Message does not appear to be a draft: edit as new? ")) - (switch-to-buffer (get-buffer-create (concat "*notmuch-draft-" id "*"))) + (pop-to-buffer-same-window + (get-buffer-create (concat "*notmuch-draft-" id "*"))) (setq buffer-read-only nil) (erase-buffer) (let ((coding-system-for-read 'no-conversion)) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index c127bba9..bb60a890 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -973,7 +973,7 @@ following: (let ((notmuch-hello-auto-refresh nil)) (if no-display (set-buffer "*notmuch-hello*") - (switch-to-buffer "*notmuch-hello*"))) + (pop-to-buffer-same-window "*notmuch-hello*"))) ;; Install auto-refresh hook (when notmuch-hello-auto-refresh (add-hook 'window-configuration-change-hook diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index b0f2d28b..98d9c935 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1241,7 +1241,7 @@ matched." (eval (car (get 'mm-inline-override-types 'standard-value)))) (cons "application/*" mm-inline-override-types) mm-inline-override-types))) - (switch-to-buffer (get-buffer-create buffer-name)) + (pop-to-buffer-same-window (get-buffer-create buffer-name)) ;; No need to track undo information for this buffer. (setq buffer-undo-list t) (notmuch-show-mode) @@ -1998,7 +1998,7 @@ to show, nil otherwise." (let* ((id (notmuch-show-get-message-id)) (buf (get-buffer-create (concat "*notmuch-raw-" id "*"))) (inhibit-read-only t)) - (switch-to-buffer buf) + (pop-to-buffer-same-window buf) (erase-buffer) (let ((coding-system-for-read 'no-conversion)) (call-process notmuch-command nil t nil "show" "--format=raw" id)) @@ -2057,7 +2057,7 @@ message." (set-buffer-modified-p nil) (setq buffer-read-only t) (unless (zerop exit-code) - (switch-to-buffer-other-window buf) + (pop-to-buffer buf) (message (format "Command '%s' exited abnormally with code %d" shell-command exit-code)))))))) @@ -2465,7 +2465,7 @@ If the part is displayed in an external application then close the new buffer." (let ((buf (get-buffer-create (generate-new-buffer-name (concat " *notmuch-internal-part*"))))) - (switch-to-buffer buf) + (pop-to-buffer-same-window buf) (if (eq (mm-display-part handle) 'external) (kill-buffer buf) (goto-char (point-min)) diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el index fbba4bb3..f36a6e72 100644 --- a/emacs/notmuch-tree.el +++ b/emacs/notmuch-tree.el @@ -543,9 +543,14 @@ NOT change the database." (setq notmuch-tree-message-window (split-window-vertically (/ (window-height) 4))) (with-selected-window notmuch-tree-message-window - ;; Since we are only displaying one message do not indent. - (let ((notmuch-show-indent-messages-width 0) - (notmuch-show-only-matching-messages t)) + (let (;; Since we are only displaying one message do not indent. + (notmuch-show-indent-messages-width 0) + (notmuch-show-only-matching-messages t) + ;; Ensure that `pop-to-buffer-same-window' uses the + ;; window we want it to use. + (display-buffer-overriding-action + '((display-buffer-same-window) + (inhibit-same-window . nil)))) (setq buffer (notmuch-show id)))) ;; We need the `let' as notmuch-tree-message-window is buffer local. (let ((window notmuch-tree-message-window)) @@ -1076,7 +1081,7 @@ The arguments are: (if unthreaded "unthreaded-" "tree-") query "*"))))) (inhibit-read-only t)) - (switch-to-buffer buffer)) + (pop-to-buffer-same-window buffer)) ;; Don't track undo information for this buffer (set 'buffer-undo-list t) (notmuch-tree-worker query query-context target open-target unthreaded) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index babddbb6..4e2ea9eb 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -994,7 +994,7 @@ the configured default sort order." (buffer (get-buffer-create (notmuch-search-buffer-title query)))) (if no-display (set-buffer buffer) - (switch-to-buffer buffer)) + (pop-to-buffer-same-window buffer)) ;; avoid wiping out third party buffer-local variables in the case ;; where we're just refreshing or changing the sort order of an ;; existing search results buffer @@ -1134,7 +1134,7 @@ notmuch buffers exist, run `notmuch'." ;; If the first one we found is any other than the starting ;; buffer, switch to it. (unless (eq first start) - (switch-to-buffer first)) + (pop-to-buffer-same-window first)) (notmuch)))) ;;;; Imenu Support -- 2.27.0