From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Clemens Newsgroups: gmane.emacs.bugs Subject: bug#44080: 27.1; Display behavior of overlays `after-string` in resizable minibuffer frames Date: Sat, 24 Oct 2020 15:08:19 +0200 Message-ID: <1c3e6434-fc1b-ad72-f775-266e14facdcf@posteo.de> References: <83v9f6ngr6.fsf@gnu.org> <9a624e83-8d12-7597-2421-8c8ac9415ef9@gmx.at> <62b3f36b-c352-6004-7a59-e95ffe1ce408@gmx.at> <10267321-400d-5d36-1558-070a24476a03@posteo.de> <82e8f1b4-c3cb-6aec-45d3-e413da4a1b58@gmx.at> <052c2d28-c565-4038-92b1-38057bfe654b@posteo.de> <0a222f7d-6d3f-4c7c-548f-09f4af82ae6e@posteo.de> <632cd636-2821-10c7-da7c-66fa74b2558e@gmx.at> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------C0E7B90D880376334E552209" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8368"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 Cc: 44080@debbugs.gnu.org To: martin rudalics , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 24 15:09:23 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1kWJIR-00023R-38 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 24 Oct 2020 15:09:23 +0200 Original-Received: from localhost ([::1]:56622 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kWJIQ-0002XQ-4H for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 24 Oct 2020 09:09:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kWJI7-0002X1-Ft for bug-gnu-emacs@gnu.org; Sat, 24 Oct 2020 09:09:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49630) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kWJI7-00049e-5A for bug-gnu-emacs@gnu.org; Sat, 24 Oct 2020 09:09:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kWJI6-0006kM-Up for bug-gnu-emacs@gnu.org; Sat, 24 Oct 2020 09:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Clemens Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 24 Oct 2020 13:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44080 X-GNU-PR-Package: emacs Original-Received: via spool by 44080-submit@debbugs.gnu.org id=B44080.160354490925877 (code B ref 44080); Sat, 24 Oct 2020 13:09:02 +0000 Original-Received: (at 44080) by debbugs.gnu.org; 24 Oct 2020 13:08:29 +0000 Original-Received: from localhost ([127.0.0.1]:32941 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kWJHY-0006jI-PH for submit@debbugs.gnu.org; Sat, 24 Oct 2020 09:08:29 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:49299) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kWJHX-0006j5-2Z for 44080@debbugs.gnu.org; Sat, 24 Oct 2020 09:08:28 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id E32EF160063 for <44080@debbugs.gnu.org>; Sat, 24 Oct 2020 15:08:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1603544900; bh=DJFn/JIXfM+36PXQKIxGFPzxHBucJBeZwlULdGwenrE=; h=Subject:To:Cc:From:Date:From; b=fqWWrBGTjhjTwdaPL+yLhs3LME9zqoxVi6SRQVpe6iDcxH9s8Llws/NdqfmxaQuO9 hhylpTr0kO9AcLdafJIxO8gnNaIWIhmhLhAgW1QPdxz8K2n895n+atu/RSdhcQm6Qf BwxZHokFfHNDjYt5fUCMoDygqkaXkogiXTtfFCXs7J9dRSuNuiL4I7hGTxNScX0Go/ QjW6iqRhzxoFFRFyMz4gMOq/eD7DWyAZtR9XRHRZaPX3dGPk8MuQG0vVoF77/gUQmH DzRsLjQYmmYMvNqooRSfVljc59rp9pDJjJ5rKLg7Z/TfHxTiCNLzhSaDp9SULqUa2C I3Lreky11XO3g== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4CJLxw1cmpz9ry3; Sat, 24 Oct 2020 15:08:20 +0200 (CEST) In-Reply-To: <632cd636-2821-10c7-da7c-66fa74b2558e@gmx.at> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:191421 Archived-At: This is a multi-part message in MIME format. --------------C0E7B90D880376334E552209 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit > The customization is done here in cus-start.el > > (resize-mini-frames > frames (choice > (const :tag "Never" nil) > (const :tag "Fit frame to buffer" t) > (function :tag "User-defined function")) > "27.1") Thanks, now I know how that is done, I should have grepped for it. I have attached an updated patch where I implemented your suggestions. For now I updated the tag to 27.2. Let me know if anything else could be improved and thanks for giving me the opportunity to contribute a little to my favorite software :) --------------C0E7B90D880376334E552209 Content-Type: text/x-patch; charset=UTF-8; name="0001-Don-t-skip-empty-lines-when-fitting-mini-frame-to-bu.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Don-t-skip-empty-lines-when-fitting-mini-frame-to-bu.pa"; filename*1="tch" >From fa40d19d2eb6339a30d396e51201781fc8a639ca Mon Sep 17 00:00:00 2001 From: Clemens Radermacher Date: Sat, 24 Oct 2020 14:49:45 +0200 Subject: [PATCH] Don't skip empty lines when fitting mini frame to buffer (bug#44080) * lisp/window.el: (fit-mini-frame-to-buffer, window--resize-mini-frame, fit-frame-to-buffer, fit-frame-to-buffer-1): Fit to mini frames without skipping leading or trailing empty lines. * src/frame.c: (resize-mini-frames): Update docstring. * lisp/cus-start.el: Update for customize. * doc/lispref/minibuf.texi: (resize-mini-frames) Update description. --- doc/lispref/minibuf.texi | 6 ++++-- etc/NEWS | 6 ++++++ lisp/cus-start.el | 4 ++-- lisp/window.el | 24 +++++++++++++++++++++--- src/frame.c | 2 +- 5 files changed, 34 insertions(+), 8 deletions(-) diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index d00acd0ded..e5a0233b3c 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi @@ -2501,8 +2501,10 @@ frame is the buffer whose contents will be shown the next time that window is redisplayed. The function is expected to fit the frame to the buffer in some appropriate way. -Any other non-@code{nil} value means to resize minibuffer-only frames -by calling @code{fit-frame-to-buffer} (@pxref{Resizing Windows}). +Any other non-@code{nil} value means to resize minibuffer-only frames by +calling @code{fit-mini-frame-to-buffer}, a function that behaves like +@code{fit-frame-to-buffer} (@pxref{Resizing Windows}) but does not strip +leading or trailing empty lines from the buffer text. @end defopt diff --git a/etc/NEWS b/etc/NEWS index 2aed575159..861ce6ff6f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -274,6 +274,12 @@ of the next command to be displayed in a new window. It's bound to the command 'other-frame-prefix' that requests the buffer of the next command to be displayed in a new frame. ++++ +*** Change behavior of user option 'resize-mini-frames'. +If set to non-nil resize the mini frame using the new function +'fit-mini-frame-to-buffer' which won't skip leading or trailing empty +lines of the buffer. + ** Tab Bars *** The key prefix 'C-x t t' displays next command buffer in a new tab. diff --git a/lisp/cus-start.el b/lisp/cus-start.el index 3fd6ac031c..6927b6df6b 100644 --- a/lisp/cus-start.el +++ b/lisp/cus-start.el @@ -324,9 +324,9 @@ (default-frame-alist frames (resize-mini-frames frames (choice (const :tag "Never" nil) - (const :tag "Fit frame to buffer" t) + (const :tag "Fit mini frame to buffer" t) (function :tag "User-defined function")) - "27.1") + "27.2") (menu-bar-mode frames boolean nil ;; FIXME? ;; :initialize custom-initialize-default diff --git a/lisp/window.el b/lisp/window.el index 1fcfffcb53..865f6fdd5c 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -3432,7 +3432,7 @@ (defun window--resize-mini-frame (frame) "Resize minibuffer-only frame FRAME." (if (functionp resize-mini-frames) (funcall resize-mini-frames frame) - (fit-frame-to-buffer frame))) + (fit-mini-frame-to-buffer frame))) (defun window--sanitize-window-sizes (horizontal) "Assert that all windows on selected frame are large enough. @@ -8925,6 +8925,14 @@ (defun window--sanitize-margin (margin left right) (declare-function tool-bar-height "xdisp.c" (&optional frame pixelwise)) +(defun fit-mini-frame-to-buffer (&optional frame) + "Adjust size of minibuffer FRAME to display its contents. +FRAME should be a minibuffer-only frame and defaults to the +selected one. Unlike `fit-frame-to-buffer' FRAME will fit to the +contents of its buffer with any leading or trailing empty lines +included." + (fit-frame-to-buffer-1 frame)) + (defun fit-frame-to-buffer (&optional frame max-height min-height max-width min-width only) "Adjust size of FRAME to display the contents of its buffer exactly. FRAME can be any live frame and defaults to the selected one. @@ -8943,8 +8951,18 @@ (defun fit-frame-to-buffer (&optional frame max-height min-height max-width min- The new position and size of FRAME can be additionally determined by customizing the options `fit-frame-to-buffer-sizes' and `fit-frame-to-buffer-margins' or setting the corresponding -parameters of FRAME." +parameters of FRAME. + +Any leading or trailing empty lines of the buffer content are not +considered." (interactive) + (fit-frame-to-buffer-1 frame max-height min-height max-width min-width only t t)) + +(defun fit-frame-to-buffer-1 (&optional frame max-height min-height max-width min-width only from to) + "Helper function for `fit-frame-to-buffer'. +FROM and TO are the buffer positions to determine the size to fit +to, see `window-text-pixel-size'. The remaining arguments are as +for `fit-frame-to-buffer'." (unless (fboundp 'display-monitor-attributes-list) (user-error "Cannot resize frame in non-graphic Emacs")) (setq frame (window-normalize-frame frame)) @@ -9079,7 +9097,7 @@ (defun fit-frame-to-buffer (&optional frame max-height min-height max-width min- ;; Note: Currently, for a new frame the sizes of the header ;; and mode line may be estimated incorrectly (size - (window-text-pixel-size window t t max-width max-height)) + (window-text-pixel-size window from to max-width max-height)) (width (max (car size) min-width)) (height (max (cdr size) min-height))) ;; Don't change height or width when the window's size is fixed diff --git a/src/frame.c b/src/frame.c index 0b707c2af8..797d885d43 100644 --- a/src/frame.c +++ b/src/frame.c @@ -6182,7 +6182,7 @@ window of that frame is the buffer whose text will be eventually shown in the minibuffer window. Any other non-nil value means to resize minibuffer-only frames by -calling `fit-frame-to-buffer'. */); +calling `fit-mini-frame-to-buffer'. */); resize_mini_frames = Qnil; DEFVAR_LISP ("focus-follows-mouse", focus_follows_mouse, -- 2.17.1 --------------C0E7B90D880376334E552209--