unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Ioan-Adrian Ratiu <adi@adirat.com>
To: notmuch@notmuchmail.org
Subject: [PATCH v4 3/6] emacs: notmuch-search: add no-display functionality
Date: Sun,  9 Oct 2016 00:01:36 +0300	[thread overview]
Message-ID: <20161008210139.25322-4-adi@adirat.com> (raw)
In-Reply-To: <20161008210139.25322-1-adi@adirat.com>

If no-display is non-nil when updating a notmuch-search buffer, do not
force bring to foreground in a window said search results buffer.

Signed-off-by: Ioan-Adrian Ratiu <adi@adirat.com>
---
 emacs/notmuch.el | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 17a784d..8d5e20c 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -925,7 +925,7 @@ PROMPT is the string to prompt with."
 
 ;;;###autoload
 (put 'notmuch-search 'notmuch-doc "Search for messages.")
-(defun notmuch-search (&optional query oldest-first target-thread target-line)
+(defun notmuch-search (&optional query oldest-first target-thread target-line no-display)
   "Display threads matching QUERY in a notmuch-search buffer.
 
 If QUERY is nil, it is read interactively from the minibuffer.
@@ -936,6 +936,9 @@ Other optional parameters are used as follows:
                  current if it appears in the search results.
   TARGET-LINE: The line number to move to if the target thread does not
                appear in the search results.
+  NO-DISPLAY: Do not try to foreground the search results buffer. If it is
+              already foregrounded i.e. displayed in a window, this has no
+              effect, meaning the buffer will remain visible.
 
 When called interactively, this will prompt for a query and use
 the configured default sort order."
@@ -949,7 +952,9 @@ the configured default sort order."
 
   (let* ((query (or query (notmuch-read-query "Notmuch search: ")))
 	 (buffer (get-buffer-create (notmuch-search-buffer-title query))))
-    (switch-to-buffer buffer)
+    (if no-display
+	(set-buffer buffer)
+      (switch-to-buffer buffer))
     (notmuch-search-mode)
     ;; Don't track undo information for this buffer
     (set 'buffer-undo-list t)
@@ -982,7 +987,7 @@ the configured default sort order."
 	  (set-process-query-on-exit-flag proc nil))))
     (run-hooks 'notmuch-search-hook)))
 
-(defun notmuch-search-refresh-view (&rest ignore)
+(defun notmuch-search-refresh-view (&optional ignore no-display)
   "Refresh the current view.
 
 Erases the current buffer and runs a new search with the same
@@ -997,7 +1002,7 @@ same relative position within the new buffer."
 	(inhibit-read-only t))
     (remove-overlays)
     (erase-buffer)
-    (notmuch-search query oldest-first target-thread target-line)
+    (notmuch-search query oldest-first target-thread target-line no-display)
     (goto-char (point-min))))
 
 (defun notmuch-search-toggle-order ()
-- 
2.10.0

  parent reply	other threads:[~2016-10-08 21:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-08 21:01 [PATCH v4 0/6] Add refresh all buffers functionality Ioan-Adrian Ratiu
2016-10-08 21:01 ` [PATCH v4 1/6] emacs: make the refresh code more consistent Ioan-Adrian Ratiu
2016-10-09 16:19   ` Tomi Ollila
2016-10-08 21:01 ` [PATCH v4 2/6] emacs: notmuch-search-refresh-view: reuse buffer Ioan-Adrian Ratiu
2016-10-08 21:01 ` Ioan-Adrian Ratiu [this message]
2016-10-08 21:01 ` [PATCH v4 4/6] emacs: notmuch-show: refresh all windows displaying buffer Ioan-Adrian Ratiu
2016-10-08 21:01 ` [PATCH v4 5/6] emacs: add no-display arg to generic refresh functions Ioan-Adrian Ratiu
2016-10-08 21:01 ` [PATCH v4 6/6] emacs: notmuch-lib: add refresh all buffers function Ioan-Adrian Ratiu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161008210139.25322-4-adi@adirat.com \
    --to=adi@adirat.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).