From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id A9D466DE0FA5 for ; Thu, 6 Oct 2016 07:39:18 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.546 X-Spam-Level: X-Spam-Status: No, score=0.546 tagged_above=-999 required=5 tests=[AWL=-0.425, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_SOFTFAIL=0.972] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5cP5iSseqwZl for ; Thu, 6 Oct 2016 07:39:18 -0700 (PDT) Received: from ni.com (skprod2.natinst.com [130.164.80.23]) by arlo.cworth.org (Postfix) with ESMTPS id C90CA6DE0C7A for ; Thu, 6 Oct 2016 07:39:17 -0700 (PDT) Received: from us-aus-mgwout1.amer.corp.natinst.com (nb-snip2-1338.natinst.com [130.164.19.135]) by us-aus-skprod2.natinst.com (8.15.0.59/8.15.0.59) with ESMTP id u96Dhxuj022339; Thu, 6 Oct 2016 08:43:59 -0500 Received: from adi-pc-linux.iotechamer.corp.natinst.com ([130.164.14.198]) by us-aus-mgwout1.amer.corp.natinst.com (Lotus Domino Release 8.5.3FP6 HF1218) with ESMTP id 2016100608435947-645259 ; Thu, 6 Oct 2016 08:43:59 -0500 From: Ioan-Adrian Ratiu To: notmuch@notmuchmail.org Subject: [PATCH v3 1/4] emacs: reuse buffer when refreshing searches Date: Thu, 6 Oct 2016 16:42:24 +0300 Message-Id: <20161006134227.17194-2-adi@adirat.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20161006134227.17194-1-adi@adirat.com> References: <20161006134227.17194-1-adi@adirat.com> X-MIMETrack: Itemize by SMTP Server on US-AUS-MGWOut1/AUS/H/NIC(Release 8.5.3FP6 HF1218|December 12, 2014) at 10/06/2016 08:43:59 AM, Serialize by Router on US-AUS-MGWOut1/AUS/H/NIC(Release 8.5.3FP6 HF1218|December 12, 2014) at 10/06/2016 08:44:00 AM, Serialize complete at 10/06/2016 08:44:00 AM X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-10-06_06:, , signatures=0 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 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: Thu, 06 Oct 2016 14:39:18 -0000 There's no reason to completely kill a buffer while refreshing its search results because the buffer name is constant between refreshes (based on the search query), only its contents may change and notmuch search kills all local variables, so it's safe to reuse. Reusing the same buffer also makes it possible to do things like refreshing a buffer which is not focused or even not shown in any window - this will be used in the next commits to add auto-refresh capabilities to all existing notmuch buffers + a function to call after syncing mail to refresh everything. Signed-off-by: Ioan-Adrian Ratiu --- emacs/notmuch.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 888672b..586c84e 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -985,7 +985,7 @@ the configured default sort order." (defun notmuch-search-refresh-view () "Refresh the current view. -Kills the current buffer and runs a new search with the same +Erases the current buffer and runs a new search with the same query string as the current search. If the current thread is in the new search results, then point will be placed on the same thread. Otherwise, point will be moved to attempt to be in the @@ -993,8 +993,10 @@ same relative position within the new buffer." (let ((target-line (line-number-at-pos)) (oldest-first notmuch-search-oldest-first) (target-thread (notmuch-search-find-thread-id 'bare)) - (query notmuch-search-query-string)) - (notmuch-bury-or-kill-this-buffer) + (query notmuch-search-query-string) + (inhibit-read-only t)) + (remove-overlays) + (erase-buffer) (notmuch-search query oldest-first target-thread target-line) (goto-char (point-min)))) -- 2.10.0