[PATCH 2/4] emacs: adjust all types of notmuch show buffers
Ioan-Adrian Ratiu
adi at adirat.com
Sat Sep 17 01:21:06 PDT 2016
Hi and thank you for the feedback!
On Fri, 16 Sep 2016, Mark Walters <markwalters1009 at gmail.com> wrote:
> 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?
Good catch.
If one of the windows has focus, its point gets reset to the message
containing point before the refresh call (the standard notmuch-show
current refresh behaviour). The windows which don't have focus get reset
to the first message.
We want to make all windows showing a buffer get adjusted, right?
I can add this to v2.
>
> 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.
Yes, this is much clearer, I will update in v2.
>
> 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