From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id oIXSNCbQLV9HEAAA0tVLHw (envelope-from ) for ; Fri, 07 Aug 2020 22:05:26 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id qNWXMCbQLV8FFAAA1q6Kng (envelope-from ) for ; Fri, 07 Aug 2020 22:05:26 +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 D4ED2940630 for ; Fri, 7 Aug 2020 22:05:24 +0000 (UTC) Received: from [144.217.243.247] (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id CCFB229A81; Fri, 7 Aug 2020 18:05:13 -0400 (EDT) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by mail.notmuchmail.org (Postfix) with ESMTPS id C12FD2711E for ; Fri, 7 Aug 2020 18:05:10 -0400 (EDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 8CB085C00A2; Fri, 7 Aug 2020 18:05:09 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 07 Aug 2020 18:05:09 -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=ARM43cXBHdt9zDRVn9hcM/WI4K Jj88Jw+66VU0EKZzU=; b=YHCPlZhOTPzfVmTK58/9BlyyGijSDBAwRJ/HqsVxEg np1gCYHuxA1P0Xr1Ey5cG8ttPF0L6fBkVB/iPb/KZS7sk3qSId6bLfv+vEw4Q9AV jzWzO6rZu7TMXdDsRsz1F0yU5/QmA6zAOC7+xP0eoPT/05n4ZAGcBqFRYIsqc1/+ 1E/9dsTkkCworHLE1ieIlCif2R6jiGZ+eiA1DoT2pADHcSBMu85QTgtGTfE7zPd3 NcfuOJ6T9KPAeSPEY16byH//69YFBXqV3i7qvPspOl6xbx2uOgZ0/LAYa2dIef9a 5SQhuL3rMdkg8XMzSh46PFfPARaPsX1T0lembqZJh2cA== 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=ARM43cXBHdt9zDRVn 9hcM/WI4KJj88Jw+66VU0EKZzU=; b=VGPvoFY9+n1auoCi7P8ln33+KHPEtcn5u qXjCOFSM0Zc4m1xwg45b/auXhej93udmu3GHOoVqFpvC5TI9rjVjNevKM/EGCKSn NQMToHx+o1docnlBduOXuvVhpYOPGr8y2uovWI78qBJT834BT9/JrZ7zLCwRdbp7 RE5oJee2ho5aErDVbAH3OT3Q5XVt1ga3tWNCXkdh0K9ZphPJaunZZ1YHPBhwV8Qw rUpeeqVO9MZ5nDJlUUzzbPX6qdovQRt8K9OEFxw5nOtp/vz0OAFy7zpF/+xw2o+p ryALKzroPVAGxS/ir7Tsq4fOGTUnszwcO/lwXUwapZAm/N/Khhnyw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrkeefgddthecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkfgggfestdekredttddttd enucfhrhhomhepufgvrghnucghhhhithhtohhnuceoshhpfihhihhtthhonhesshhpfihh ihhtthhonhdrnhgrmhgvqeenucggtffrrghtthgvrhhnpeegtdeuueefleduhedtvdehge evuddtfefhheffteevgeejiedtgefhjeegtdetueenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpehsphifhhhithhtohhnsehsphifhhhithhtoh hnrdhnrghmvg X-ME-Proxy: From: Sean Whitton To: notmuch@notmuchmail.org Cc: Sean Whitton Subject: [PATCH] emacs: Use pop-to-buffer-same-window rather than switch-to-buffer Date: Fri, 7 Aug 2020 15:05:05 -0700 Message-Id: <20200807220505.11274-1-spwhitton@spwhitton.name> MIME-Version: 1.0 Message-ID-Hash: 7632L2MMVOWPBTKGJXHKXPVMPO45K7FD X-Message-ID-Hash: 7632L2MMVOWPBTKGJXHKXPVMPO45K7FD 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=YHCPlZhO; dkim=fail (body hash did not verify) header.d=messagingengine.com header.s=fm3 header.b=VGPvoFY9; 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: 1.03 X-TUID: UAi5DXWiZoUf 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. --- 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 27abc7d9..3a9750e1 100644 --- a/emacs/notmuch-draft.el +++ b/emacs/notmuch-draft.el @@ -228,7 +228,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 0ff5aaff..3b4ed2b7 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -967,7 +967,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 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index c9170466..4ee34f8e 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1270,7 +1270,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) @@ -2039,7 +2039,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)) @@ -2095,7 +2095,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)))))))) @@ -2503,7 +2503,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 ab90f652..7ed06ffd 100644 --- a/emacs/notmuch-tree.el +++ b/emacs/notmuch-tree.el @@ -527,9 +527,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)) @@ -1061,7 +1066,7 @@ The arguments are: 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) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index c97997fe..c76861c7 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -986,7 +986,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 @@ -1126,7 +1126,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