[PATCH 2/4] emacs: adjust all types of notmuch show buffers

Mark Walters markwalters1009 at gmail.com
Fri Sep 16 13:34:12 PDT 2016


On Sat, 10 Sep 2016, Ioan-Adrian Ratiu <adi at adirat.com> wrote:
> The current notmuch-show-message-adjust logic only adjusts the buffer
> focused in the current window. Extend it to adjust any kind of buffer,
> even buffers in a window without focus or in a different frame or even
> not shown at all.
>
> This new logic is very useful to build upon for the auto-refresh all
> buffers feature because you can use similar code to refresh any buffer:
>
> (with-current-buffer "*random show buffer*"
>   (notmuch-refresh-this-buffer))
>
> Signed-off-by: Ioan-Adrian Ratiu <adi at adirat.com>
> ---
>  emacs/notmuch-show.el | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 6d3149b..74818cc 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1505,7 +1505,16 @@ All currently available key bindings:
>    (goto-char (notmuch-show-message-bottom)))
>  
>  (defun notmuch-show-message-adjust ()
> -  (recenter 0))
> +  (let ((buffer-window (get-buffer-window (current-buffer) t))
> +	(msg-position (point)))
> +    (if buffer-window
> +	(with-selected-window buffer-window
> +	  (goto-char msg-position)
> +	  (recenter 0))
> +      (save-window-excursion
> +	(select-window (display-buffer (current-buffer)))
> +	(goto-char msg-position)
> +	(recenter 0)))))

Hi

I haven't tested things yet, but what happens if the buffer is open in
multiple windows?

I think it would be worth adding something to the commit message along
the lines of

    notmuch-show-refresh-view calls notmuch-show-message-adjust in its
    call chain. Since we want to call notmuch-show-refresh-view on
    buffers than are not displayed we need to modify
    notmuch-show-message-adjust to work in this case.

Best wishes

Mark


>  ;; Movement related functions.
>  
> -- 
> 2.9.3
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch


More information about the notmuch mailing list