Subject: bug#44933: 27.1; Ephemeral frame selection shrinks minibuffer

From: Sean Devlin <[email-masked]>
Date: Sat, 28 Nov 2020 16:21:40 -0500

Hi folks,

Selecting a different frame ephmerally (e.g. via `with-selected-frame`
in a timer callback) shrinks the minibuffer. This is true whether or not
the minibuffer is active.

Reproduction steps:

1. Evaluate this form in the scratch buffer:

   (run-with-timer nil 13 (lambda () (with-selected-frame
   (next-frame))))

2. Evaluate this form in the scratch buffer:

   (run-with-timer nil 11 (lambda () (window-resize (minibuffer-window)
   10)))

3. Observe that the minibuffer grows and shrinks as the timers fire.

You can run some completing read command (e.g. `M-x`) to see that the
resizing happens whether or not the minibuffer is active.

This is relevant for completing read implementations that resize the
minibuffer to display a vertical list of candidates. I noticed the
behavior while using selectrum (https://github.com/raxod502/selectrum)
while I had a subprocess running under term in another frame. Since the 
`term-emulate-terminal` function selects windows in the background  
whenever the subprocess sends output, it was causing the selectrum
minibuffer to shrink.

I'm not sure what the correct behavior is here, but this was unexpected
to me. I think that if the minibuffer is active, ephemeral frame or
window selections should not affect its size. (I'm less certain about
the inactive minibuffer case, but I think the size should stay the same
there as well.)

Thanks!

In GNU Emacs 27.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95))
of 2020-08-12 built on builder10-14.porkrind.org
Windowing system distributor 'Apple', version 10.3.2022
System Description:  macOS 11.0

Recent messages:
Beginning of buffer [5 times]
uncompressing window.el.gz...done
Making completion list...
Type C-x 1 to delete the help window, C-M-v to scroll help.
t [2 times]
Quit [3 times]
[nil 24514 47830 650446 10 (closure (t) nil (window-resize (minibuffer-window) 10)) nil nil 0]
[nil 24514 47883 629069 11 (closure (t) nil (let (... ...) (unwind-protect ... ... ...))) nil nil 0]
End of buffer [6 times]
Beginning of buffer [8 times]

Configured using:
'configure --with-ns '--enable-locallisppath=/Library/Application
Support/Emacs/${version}/site-lisp:/Library/Application
Support/Emacs/site-lisp' --with-modules'

Configured features:
NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES
THREADS JSON PDUMPER

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr cl-print debug backtrace cl-extra minibuf-eldef
help-fns radix-tree help-mode emacsbug message rmc puny dired
dired-loaddefs format-spec rfc822 mml easymenu mml-sec password-cache
epa derived epg epg-config gnus-util rmail rmail-loaddefs
text-property-search time-date subr-x seq byte-opt gv bytecomp
byte-compile cconv mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader cl-loaddefs cl-lib sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils linum misearch
multi-isearch jka-compr thingatpt find-func tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel term/ns-win ns-win
ucs-normalize mule-util term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
timer select scroll-bar mouse jit-lock font-lock syntax facemenu
font-core term/tty-colors frame minibuffer cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads kqueue cocoa ns
multi-tty make-network-process emacs)

Memory information:
((conses 16 59777 30679)
(symbols 48 6538 1)
(strings 32 19388 2002)
(string-bytes 1 586736)
(vectors 16 11741)
(vector-slots 8 146822 21486)
(floats 8 40 48)
(intervals 56 896 92)
(buffers 1000 16))