emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

display-buffer and temp-buffer-resize-mode


From: martin rudalics
Subject: display-buffer and temp-buffer-resize-mode
Date: Wed, 16 Feb 2022 18:52:44 +0100

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]