From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] completions-max-height Date: Mon, 07 Mar 2022 22:10:52 +0000 Message-ID: <87v8wpxvkj.fsf@posteo.net> References: <20220307210740.veiocemir46mmerk.ref@Ergus> <20220307210740.veiocemir46mmerk@Ergus> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2027"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Ergus Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Mar 07 23:11:58 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nRLaA-0000GQ-9W for ged-emacs-devel@m.gmane-mx.org; Mon, 07 Mar 2022 23:11:58 +0100 Original-Received: from localhost ([::1]:38654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRLa8-0004nU-TU for ged-emacs-devel@m.gmane-mx.org; Mon, 07 Mar 2022 17:11:56 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:46594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRLZD-0003gn-BT for emacs-devel@gnu.org; Mon, 07 Mar 2022 17:10:59 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]:60133) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRLZA-0000UB-Ln for emacs-devel@gnu.org; Mon, 07 Mar 2022 17:10:58 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 46064240101 for ; Mon, 7 Mar 2022 23:10:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1646691054; bh=JWH1p+w1zojZ/iwgrKTxduOaRJBQcz/UBhDHg3VjsiY=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=r+EkchwkRqRL26J75vcBZKq9O7A9ODRVOazMgvxkBTANAJEoukEUxbKrZUHWVdVNe TBgvlwJrorjr7T3aZUjw68ZkYP3xNiB1/JV+QEyLgtoeGHMdhxMz5yUtkFpkjDM9Co 7+r9jQtGTkGdNgm2TYmgeFrrv4RPtErux53p0p/btOEsSSwFISUO4+C34g8PJLrdtA HJ9kr6nIF0QE+ftgdGG7eTuw/5T8VmasILf6LNVe9BI8OHZETvr/DU/j63B7zhV731 0j2gBxogPNkug51YPYPao/qpwQuvBlSQwOhZqHTxo1Aibx/nMidEuaA5ux7b/0daT/ axUQUs5Vs97Eg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4KCCMd3hMNz9rxN; Mon, 7 Mar 2022 23:10:53 +0100 (CET) Autocrypt: addr=philipk@posteo.net; prefer-encrypt=nopreference; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB In-Reply-To: <20220307210740.veiocemir46mmerk@Ergus> (Ergus's message of "Mon, 7 Mar 2022 22:07:40 +0100") Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:286905 Archived-At: Ergus writes: > Hi: > > Do you think that this may be added to vanilla? IMO it would be better if this could be generalised to something like completion-display-buffer-action, so that you can decide where and how the completion buffer is displayed. Though I am uncertain if this might have unintended side effects, as the behaviour seems to have been hard-coded for a while. > Best, > Ergus > > diff --git a/etc/NEWS b/etc/NEWS > index 587e7f6ade..78f41de2ea 100644 > --- a/etc/NEWS > +++ b/etc/NEWS > @@ -554,6 +554,10 @@ This option controls the sorting of the completion candidates in > the "*Completions*" buffer. Available styles are no sorting, > alphabetical (the default), or a custom sort function. > > +*** New user option 'completions-max-height'. > +This option limits the height of the "*Completions*" buffer. > + > + > ** Isearch and Replace > > +++ > diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el > index 798cba0ac2..a06986fdb7 100644 > --- a/lisp/minibuffer.el > +++ b/lisp/minibuffer.el > @@ -2212,6 +2212,19 @@ completion--done > (equal pre-msg (and exit-fun (current-message)))) > (completion--message message)))) > > +(defcustom completions-max-height nil > + "Maximum height for *Completions* buffer." > + :type 'natnum > + :version "29.1") > + > +(defun completions--fit-window-to-buffer (&optional win &rest _) > + "Resize completions." > + (if temp-buffer-resize-mode > + (let ((temp-buffer-max-height (or completions-max-height > + temp-buffer-max-height))) > + (resize-temp-buffer-window win)) > + (fit-window-to-buffer win completions-max-height))) > + > (defun minibuffer-completion-help (&optional start end) > "Display a list of possible completions of the current minibuffer contents." > (interactive) > @@ -2275,9 +2288,7 @@ minibuffer-completion-help > ,(if (eq (selected-window) (minibuffer-window)) > 'display-buffer-at-bottom > 'display-buffer-below-selected)) > - ,(if temp-buffer-resize-mode > - '(window-height . resize-temp-buffer-window) > - '(window-height . fit-window-to-buffer)) > + (window-height . completions--fit-window-to-buffer) > ,(when temp-buffer-resize-mode > '(preserve-size . (nil . t))) > (body-function > -- Philip Kaludercic