From: Dmitry Gutov Date: Tue, 19 Jan 2021 01:05:44 +0000 (+0200) Subject: Make sure the new window is not too tall X-Git-Tag: emacs-28.0.90~4228 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=4ca808ee7adda7b17a7dedffbce9e9e49ee4cd93;p=emacs.git Make sure the new window is not too tall * lisp/progmodes/xref.el (xref-show-definitions-buffer-at-bottom): Make sure the new window is not too tall (bug#45945). --- diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index b6778de807d..aecb30a0ad4 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -1001,8 +1001,12 @@ When only one definition found, jump to it right away instead." When there is more than one definition, split the selected window and show the list in a small window at the bottom. And use a local keymap that binds `RET' to `xref-quit-and-goto-xref'." - (let ((xrefs (funcall fetcher)) - (dd default-directory)) + (let* ((xrefs (funcall fetcher)) + (dd default-directory) + ;; XXX: Make percentage customizable maybe? + (max-height (/ (window-height) 2)) + (size-fun (lambda (window) + (fit-window-to-buffer window max-height)))) (cond ((not (cdr xrefs)) (xref-pop-to-location (car xrefs) @@ -1013,7 +1017,8 @@ local keymap that binds `RET' to `xref-quit-and-goto-xref'." (xref--transient-buffer-mode) (xref--show-common-initialize (xref--analyze xrefs) fetcher alist) (pop-to-buffer (current-buffer) - '(display-buffer-in-direction . ((direction . below)))) + `(display-buffer-in-direction . ((direction . below) + (window-height . ,size-fun)))) (current-buffer)))))) (define-obsolete-function-alias 'xref--show-defs-buffer-at-bottom