unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: emacs-devel <emacs-devel@gnu.org>
Cc: Juri Linkov <juri@linkov.net>
Subject: display-buffer and temp-buffer-resize-mode
Date: Wed, 16 Feb 2022 18:52:44 +0100	[thread overview]
Message-ID: <c2b7e835-7ebd-1762-eb4a-006095f4ef25@gmx.at> (raw)

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	other threads:[~2022-02-16 17:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-16 17:52 martin rudalics [this message]
2022-02-16 18:38 ` display-buffer and temp-buffer-resize-mode Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c2b7e835-7ebd-1762-eb4a-006095f4ef25@gmx.at \
    --to=rudalics@gmx.at \
    --cc=emacs-devel@gnu.org \
    --cc=juri@linkov.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).