From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 4PC0Kc7fQF+8XgAA0tVLHw (envelope-from ) for ; Sat, 22 Aug 2020 09:05:18 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id iFuNJc7fQF9/IAAAB5/wlQ (envelope-from ) for ; Sat, 22 Aug 2020 09:05:18 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (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 48764940606 for ; Sat, 22 Aug 2020 09:05:16 +0000 (UTC) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id D089629BCE; Sat, 22 Aug 2020 05:05:09 -0400 (EDT) Received: from lahtoruutu.iki.fi (unknown [IPv6:2a0b:5c81:1c1::37]) by mail.notmuchmail.org (Postfix) with ESMTPS id 4A9DD29B2A for ; Sat, 22 Aug 2020 05:05:07 -0400 (EDT) Received: from guru.guru-group.fi (unknown [IPv6:2a02:2380:1:9:5054:ff:feb7:a4bc]) (using TLSv1.2 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: too) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id A6FCC1B00431; Sat, 22 Aug 2020 12:04:54 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1598087094; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=g513mNqsMC5aiBEN3IOTvWNrtTh/qamlQ0fdqz/x8Tc=; b=VA2+PZOyMqTwlUUBg7D+tfJ6WpjPhmWxHEr3p3JFT0onCE8CiIODhLQUFlWF8bEioKoJ2V koe0glfsz85yD3HbvDIzc8+xoJNxAZQxUr2giaRaKJ9yJZtXzkVB8PJpa6Wb7fuORtYBBe SvmOzZcaVXDtmbHYAd9jtsuv+5c/IlI61knF96RRfLAtxTJkDTIFnCIehVxImggdyJmDTh 7nfjcUL6u2nGBavjIT+Ivr7p6Gem1jw6oJoJ11JC544yaTYab6ygAtK1kxMNrpewwoQkRz M1wpflgTevRNeqTp37m/ZqlaIiETnllqbYVCDhyHRWN+gWJzsIQtb3U3aqf+AA== From: Tomi Ollila To: Sean Whitton , notmuch@notmuchmail.org Subject: Re: [PATCH v2] emacs: Use pop-to-buffer-same-window rather than switch-to-buffer In-Reply-To: <20200811165913.4459-1-spwhitton@spwhitton.name> References: <20200811165913.4459-1-spwhitton@spwhitton.name> User-Agent: Notmuch/0.31~rc0+3~ge349e17 (https://notmuchmail.org) Emacs/27.1 (x86_64-pc-linux-gnu) X-Face: HhBM'cA~ MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1598087094; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=g513mNqsMC5aiBEN3IOTvWNrtTh/qamlQ0fdqz/x8Tc=; b=D9vX9fxxRjAanyFNzGHo96FEYlqpm8j204B+ZZ1KmMDxQ3pGhI7h55y2HSiQKf1m8WLKeH eFoYv3Wv1yWNYL47Cew87t+ar5oebVh16bLnjuBy1ol3ZzCQp+gPL3CKUb3ga2pQRmkiB/ W3G5BlTuVHfs/n66sJZsvFn10mVZ9bCCGiE0Zeni1aiCiFOWDGR3OE8rerwyPVKMguo8jw IDmMjXf8v5lEKlt5cbq+VkDAlQjrv8GeK+JNu7RDlEYQblGyp14tExnMEyPRV8gdvN/Nsl 2rfjJlBUxoNnwyQF7+7AGboZwIsOJfXvrpnKHeUH242J/XsEznnBSgGm79yt2w== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1598087094; a=rsa-sha256; cv=none; b=O7WjSERmCtZYS2XOiRLjL8kyTq/dlxyAq6KIPBkWzFZr8D/qToefy+pMcHAMIrHyL4E8qe KrxLciwgV4xNnt2VCg78k4UAvsNi+l5jgGXL3sOKM1nwVyIaAcRqq1V9my8KxpMdBQDYQq UpPHZwVep0UXoJ+nzrJwXfxRkdaPXiFsXmUaBqVxlMqzyVw5AQ5rD1CJGeR5NjSjQ05otK AEFSkSSx8dJOwm6UlLuqAvw8hyYe+CveS+fzLVpfpMaeXtER38k5EMJORXS+vb5qGgsg6f 4/N9yVQuV73PU66JqEXo31OPtN/hlvE1z1jUJSDHQvLQQ9qjvZ2UpMJW3LNunw== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=too smtp.mailfrom=tomi.ollila@iki.fi Message-ID-Hash: IT4JL2OWRJSTP3WLN5BNYBYICTM2HYMZ X-Message-ID-Hash: IT4JL2OWRJSTP3WLN5BNYBYICTM2HYMZ X-MailFrom: tomi.ollila@iki.fi 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=iki.fi header.s=lahtoruutu header.b=VA2+PZOy; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Spam-Score: 3.53 X-TUID: /kkj5XJA8AMp On Tue, Aug 11 2020, Sean Whitton wrote: > 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. I've been having this in my emacs setup (one-notmuch.elc =D) couple of days, and haven't seen anything strange. Just now I tested a bit more, tried show and tree modes, with M-x debug-on-entry pop-to-buffer-same-window active and see some call paths (interestingly (or not so), starting this mail composition pop-to-buffer-same-window was not in call path -- but probably switch-to-buffer would be neither and there is no change in status quo) So LGTM. Tomi > > 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