GNU bug report logs -
#36859
Customizable fit-window-to-buffer
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Tue, 30 Jul 2019 20:40:02 UTC
Severity: wishlist
Tags: patch
Merged with 51062,
52855
Fixed in version 29.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
Message #50 received at control <at> debbugs.gnu.org (full text, mbox):
close 51062 29.0.50
thanks
>>> "shrink-buffer-if-larger-than-buffer"? Maybe this should become
>>> 'shrink-buffer-window-if-larger-than-buffer' then.
>>
>> Should such a function be added to window.el?
>
> Maybe. But we could also rename the first argument of
> 'shrink-window-if-larger-than-buffer' to WINDOW-OR-BUFFER.
This can't be generalized because vc uses specific logic:
(let ((window (get-buffer-window buffer t)))
(with-current-buffer buffer
...
(when window
(shrink-window-if-larger-than-buffer window))))
>>> With the usual problem what to do when there are two windows showing
>>> that buffer.
>>
>> It's understandable why vc-diff-internal and vc-diff-finish
>> use get-buffer-window to get a window:
>>
>> vc-diff-internal:
>> (pop-to-buffer (current-buffer))
>> (let ((buf (current-buffer)))
>> (vc-run-delayed (vc-diff-finish buf ...
>>
>> vc-diff-finish:
>> (let ((window (get-buffer-window buffer t)))
>> (with-current-buffer buffer
>> ...
>> (when window
>> (shrink-window-if-larger-than-buffer window))))
>>
>> This is needed to handle the case when the window was deleted
>> before the vc command finished.
>>
>> But why vc-log-internal-common doesn't so the same?
>>
>> vc-log-internal-common:
>> (pop-to-buffer buffer)
>> (vc-run-delayed
>> ...
>> (shrink-window-if-larger-than-buffer)
>>
>> So I posted a patch in bug#52855 to use the same function
>> that relies on get-buffer-window in both cases.
>>
>> But it seems you propose to remember the window with e.g.
>>
>> (setq window (pop-to-buffer (current-buffer)))
>>
>> then to use it in:
>>
>> (run-hook-with-args 'vc-diff-finish-functions window)
>>
>> where the defalut value of 'vc-diff-finish-functions' is:
>>
>> '(shrink-window-if-larger-than-buffer)
>>
>> Then 'shrink-buffer-window-if-larger-than-buffer' is not needed.
>
> Personally I dislike abusing hooks like that. But I probably do not use
> vc-... much either.
And it would require a weird condition:
(when window
(run-hook-with-args 'vc-diff-finish-functions window))
> So do whatever you like more.
So instead of above, I pushed the original patch with a better function name
'vc-shrink-buffer-window'.
This bug report was last modified 3 years and 131 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.