* display-buffer and temp-buffer-resize-mode
@ 2022-02-16 17:52 martin rudalics
2022-02-16 18:38 ` Juri Linkov
0 siblings, 1 reply; 2+ messages in thread
From: martin rudalics @ 2022-02-16 17:52 UTC (permalink / raw)
To: emacs-devel; +Cc: Juri Linkov
With the customization
(customize-set-variable
'display-buffer-alist
'(("*shell*" display-buffer-in-direction (direction . bottom))))
M-x shell will display a three lines high *shell* window on the bottom
of the frame and not - as probably expected - a window that occupies
about half of the root's height.
The reason is that 'display-buffer-in-direction' unconditionally asks
for resizing the new window via
(setq alist
(append alist
`(,(if temp-buffer-resize-mode
'(window-height . resize-temp-buffer-window)
'(window-height . fit-window-to-buffer))
,(when temp-buffer-resize-mode
'(preserve-size . (nil . t))))))
A user can fix that via
(customize-set-variable
'display-buffer-alist
'(("*shell*" display-buffer-in-direction (window-height . nil) (direction . bottom))))
but that's undocumented and maybe not what we should ask users to do.
Note that 'display-buffer--maybe-at-bottom' has the same problem - but
that's an internal function.
There are numerous ways to fix that, all requiring some sort of surgery:
- We could simply document the current behavior. This means that for
using 'display-buffer-in-direction' as helper function for say
'display-buffer-at-bottom' we would have to append an extra
(window-height . nil) alist entry in order to suppress the resizing
('display-buffer-at-bottom' currently does not suffer from that
syndrome).
- We could inhibit the resizing. This would require a slight amendment
in the call in 're-builder' - all other calls in our code base provide
an extra 'window-height' alist entry. Nevertheless, it would be an
incompatible change of, admittedly undocumented, behavior. (Note that
for 'display-buffer--maybe-at-bottom' we would then have to fix
'hack-local-variables-confirm'.)
- We could try to refine the snippet above in some way. For example,
ask for 'resize-temp-buffer-window' only if the buffer to be displayed
is "temporary". That's a bit tricky because 'temp-buffer-resize-mode'
is a global mode and that variable does not allow to tell whether the
buffer to display is temporary at all. In either case, the
'fit-window-to-buffer' entry would have to be dropped and we still
have an incompatible change.
Any ideas?
Thanks, martin
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: display-buffer and temp-buffer-resize-mode
2022-02-16 17:52 display-buffer and temp-buffer-resize-mode martin rudalics
@ 2022-02-16 18:38 ` Juri Linkov
0 siblings, 0 replies; 2+ messages in thread
From: Juri Linkov @ 2022-02-16 18:38 UTC (permalink / raw)
To: martin rudalics; +Cc: emacs-devel
> There are numerous ways to fix that, all requiring some sort of surgery:
>
> - We could simply document the current behavior. This means that for
> using 'display-buffer-in-direction' as helper function for say
> 'display-buffer-at-bottom' we would have to append an extra
> (window-height . nil) alist entry in order to suppress the resizing
> ('display-buffer-at-bottom' currently does not suffer from that
> syndrome).
Shouldn't both 'display-buffer-in-direction (direction . bottom)'
and 'display-buffer-at-bottom' be consistent with each other
in regard to resizing, and either both resize or not?
Even this comment says they should have the same implementation:
;; This should be rewritten as
;; (display-buffer-in-direction buffer (cons '(direction . bottom) alist))
(defun display-buffer-at-bottom (buffer alist)
> - We could inhibit the resizing. This would require a slight amendment
> in the call in 're-builder' - all other calls in our code base provide
> an extra 'window-height' alist entry. Nevertheless, it would be an
> incompatible change of, admittedly undocumented, behavior. (Note that
> for 'display-buffer--maybe-at-bottom' we would then have to fix
> 'hack-local-variables-confirm'.)
Also I found 'ediff-setup-windows-plain-compare' where
'display-buffer-in-direction' is without explicit 'window-height'.
But the decision whether to resize or not could depend on statistics:
if the majority of uses prefer resizing, then resize by default.
> - We could try to refine the snippet above in some way. For example,
> ask for 'resize-temp-buffer-window' only if the buffer to be displayed
> is "temporary". That's a bit tricky because 'temp-buffer-resize-mode'
> is a global mode and that variable does not allow to tell whether the
> buffer to display is temporary at all. In either case, the
> 'fit-window-to-buffer' entry would have to be dropped and we still
> have an incompatible change.
Another variant is to treat synonyms differently where e.g.
'(direction . bottom)' will resize, but '(direction . below) won't.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-02-16 18:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16 17:52 display-buffer and temp-buffer-resize-mode martin rudalics
2022-02-16 18:38 ` Juri Linkov
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.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).