From: Mark Walters <markwalters1009@gmail.com>
To: Ioan-Adrian Ratiu <adi@adirat.com>, notmuch@notmuchmail.org
Subject: Re: [PATCH v2 3/4] emacs: add refresh buffer optional no-display arg
Date: Sun, 25 Sep 2016 12:07:25 +0100 [thread overview]
Message-ID: <87wpi0utjm.fsf@qmul.ac.uk> (raw)
In-Reply-To: <20160924200735.25425-4-adi@adirat.com>
On Sat, 24 Sep 2016, Ioan-Adrian Ratiu <adi@adirat.com> wrote:
> Add an optional no-display arg to the generic buffer refresh function,
> notmuch-refresh-this-buffer, which works the same way as notmuch-hello
> mode's notmuch-hello-update no-display arg.
>
> The idea is for the generic notmuch-refresh-this-buffer to pass down
> this arg to the "mode-specific" refresh functions to be able to update
> buffers without bringing them to the foreground (if they are already
> foregrounded, i.e. displayed in a window, this has no effect).
>
> When updating a search buffer, notmuch currently always brings results
> in a window to the foreground. Perhaps counter-intuitively, we do not
> want this behaviour necessarily, because we want to auto-refresh any
> kind of search buffers, even those backgrounded (not displayed in any
> window/frame) from previous searches. This is why we add a no-display
> arg to notmuch-search.
>
> We do this to show which mails have appeard or dissapeared since the
> last search refresh and have this information updated in real time
> even when switching buffers. The ultimate goal of this is to have all
> notmuch buffers auto-refresh when the email client syncs (this function
> is added in the next patch).
>
> Signed-off-by: Ioan-Adrian Ratiu <adi@adirat.com>
> ---
> emacs/notmuch-lib.el | 10 +++++++---
> emacs/notmuch.el | 17 ++++++++++++-----
> 2 files changed, 19 insertions(+), 8 deletions(-)
I feel I am missing something here: why do you not need to change
notmuch-show-refresh-view and notmuch-tree-refresh-view as well? Note
notmuch-show-refresh-view already has an optional argument.
Best wishes
Mark
>
> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> index 2f015b0..6618365 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -409,14 +409,18 @@ of its command symbol."
> "Function to call to refresh the current buffer.")
> (make-variable-buffer-local 'notmuch-buffer-refresh-function)
>
> -(defun notmuch-refresh-this-buffer ()
> - "Refresh the current buffer."
> +(defun notmuch-refresh-this-buffer (&optional no-display)
> + "Refresh the current buffer.
> +
> +If no-display is non-nil do not try to bring the buffer to the
> +foreground. If the buffer is already foregrounded i.e. displayed
> +in a window on screen, no-display has no effect."
> (interactive)
> (when notmuch-buffer-refresh-function
> (if (commandp notmuch-buffer-refresh-function)
> ;; Pass prefix argument, etc.
> (call-interactively notmuch-buffer-refresh-function)
> - (funcall notmuch-buffer-refresh-function))))
> + (funcall notmuch-buffer-refresh-function no-display))))
>
> (defun notmuch-poll-and-refresh-this-buffer ()
> "Invoke `notmuch-poll' to import mail, then refresh the current buffer."
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index 05687b7..ec7a242 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -924,7 +924,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.
> @@ -935,6 +935,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."
> @@ -948,7 +951,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)
> @@ -981,21 +986,23 @@ the configured default sort order."
> (set-process-query-on-exit-flag proc nil))))
> (run-hooks 'notmuch-search-hook)))
>
> -(defun notmuch-search-refresh-view ()
> +(defun notmuch-search-refresh-view (&optional no-display)
> "Refresh the current view.
>
> 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
> -same relative position within the new buffer."
> +same relative position within the new buffer. If no-display is
> +non-nil, the search results buffer will not be foregrounded, if
> +it already is displayed in a window, then no-display has no effect."
> (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)
> (inhibit-read-only t))
> (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
next prev parent reply other threads:[~2016-09-25 11:07 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-24 20:07 [PATCH v2 0/4] Add refresh all buffers functionality Ioan-Adrian Ratiu
2016-09-24 20:07 ` [PATCH v2 1/4] emacs: reuse buffer when refreshing searches Ioan-Adrian Ratiu
2016-09-25 10:17 ` Mark Walters
2016-09-24 20:07 ` [PATCH v2 2/4] emacs: notmuch-show: refresh all windows showing a buffer Ioan-Adrian Ratiu
2016-09-25 10:14 ` Mark Walters
2016-09-25 12:28 ` Ioan-Adrian Ratiu
2016-09-24 20:07 ` [PATCH v2 3/4] emacs: add refresh buffer optional no-display arg Ioan-Adrian Ratiu
2016-09-25 11:07 ` Mark Walters [this message]
2016-10-06 12:25 ` Ioan-Adrian Ratiu
2016-09-24 20:07 ` [PATCH v2 4/4] emacs: notmuch-lib: add refresh all buffers function Ioan-Adrian Ratiu
2016-09-25 11:11 ` Mark Walters
2016-09-24 20:23 ` [PATCH v2 0/4] Add refresh all buffers functionality Ioan-Adrian Ratiu
2016-09-24 21:02 ` Ioan-Adrian Ratiu
2016-09-25 0:09 ` David Bremner
2016-09-25 0:20 ` Ioan-Adrian Ratiu
2016-09-25 6:20 ` Mark Walters
2016-09-25 7:32 ` Tomi Ollila
2016-10-06 13:59 ` Daniel Kahn Gillmor
2016-10-06 14:32 ` Tomi Ollila
2016-10-06 15:00 ` 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=87wpi0utjm.fsf@qmul.ac.uk \
--to=markwalters1009@gmail.com \
--cc=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).