From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#9970: 24.0.90; Commandify set-frame-{height,width} Date: Mon, 15 Mar 2021 19:16:48 +0200 Organization: LINKOV.NET Message-ID: <8735wwibgf.fsf@mail.linkov.net> References: <20111106.115426.1296159156205375292.hanche@math.ntnu.no> <87ef1i3ues.fsf@mouse.gnus.org> <875zmrwn0c.fsf@mail.linkov.net> <87zhk2xp0f.fsf@mouse.gnus.org> <87k0qhmok6.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36359"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: Lars Ingebrigtsen , Harald Hanche-Olsen , 9970@debbugs.gnu.org To: Daniel =?UTF-8?Q?Mart=C3=ADn?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 15 18:19:50 2021 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 1lLqsf-0009LD-EI for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 15 Mar 2021 18:19:49 +0100 Original-Received: from localhost ([::1]:57548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLqse-0003my-Dl for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 15 Mar 2021 13:19:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLqqw-0002kY-Cj for bug-gnu-emacs@gnu.org; Mon, 15 Mar 2021 13:18:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53494) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lLqqw-0006fL-3a for bug-gnu-emacs@gnu.org; Mon, 15 Mar 2021 13:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lLqqv-0001FN-VT for bug-gnu-emacs@gnu.org; Mon, 15 Mar 2021 13:18:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 15 Mar 2021 17:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9970 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 9970-submit@debbugs.gnu.org id=B9970.16158286744774 (code B ref 9970); Mon, 15 Mar 2021 17:18:01 +0000 Original-Received: (at 9970) by debbugs.gnu.org; 15 Mar 2021 17:17:54 +0000 Original-Received: from localhost ([127.0.0.1]:36805 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lLqqo-0001Eu-0V for submit@debbugs.gnu.org; Mon, 15 Mar 2021 13:17:54 -0400 Original-Received: from relay1-d.mail.gandi.net ([217.70.183.193]:39689) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lLqqm-0001Ec-6R; Mon, 15 Mar 2021 13:17:53 -0400 X-Originating-IP: 91.129.108.46 Original-Received: from mail.gandi.net (m91-129-108-46.cust.tele2.ee [91.129.108.46]) (Authenticated sender: juri@linkov.net) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id CFE4B240002; Mon, 15 Mar 2021 17:17:43 +0000 (UTC) In-Reply-To: ("Daniel =?UTF-8?Q?Mart=C3=ADn?="'s message of "Sun, 14 Mar 2021 13:07:29 +0100") 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:202414 Archived-At: reopen 9970 thanks >>> Would it make sense to ask for the frame width and height using the >>> minibuffer if no prefix argument is provided? Right now, if you try the >>> command, the frame resizes to a somewhat arbitrary size, which may >>> confuse some users. >> >> I guess that'd be a natural addition -- we have many commands that >> either take a numerical prefix, or query the user if there isn't any >> prefix. > > I've attached a patch that implements the idea. It offers the current > width or height by default, so you can estimate better the new size > you'd want. Thanks. frame.el is preloaded as well, so frame.el would be a more suitable place for this function. > From 1d48a90b584207290d8785ac4b294b43cc5851b3 Mon Sep 17 00:00:00 2001 > From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= > Date: Sun, 14 Mar 2021 12:33:00 +0100 > Subject: [PATCH] Add minibuffer input support to commands that set the frame > size > > * lisp/subr.el (set-frame-property--interactive): Internal function to > produce the interactive form of `set-frame-width' and > `set-frame-height'. Offer the current size as default. (Bug#9970) > * src/frame.c (Fset_frame_height): Modify to call > `set-frame-property--interactive'. > (Fset_frame_width): Modify to call `set-frame-property--interactive'. > * doc/lispref/frames.texi (Frame Size): Update the manuals. > * etc/NEWS: Advertise the change. > --- > doc/lispref/frames.texi | 12 ++++++------ > etc/NEWS | 4 ++++ > lisp/subr.el | 8 ++++++++ > src/frame.c | 4 ++-- > 4 files changed, 20 insertions(+), 8 deletions(-) > > diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi > index f4316b753d..cd2ff8f3b3 100644 > --- a/doc/lispref/frames.texi > +++ b/doc/lispref/frames.texi > @@ -1120,9 +1120,9 @@ Frame Size > refuse to truly honor the request if it does not increase/decrease the > frame height to a multiple of its character height. > > -When used interactively, this command will set the height of the > -currently selected frame to the number of lines specified by the > -numeric prefix. > +When used interactively, this command will ask the user for the number > +of lines to set the height of the currently selected frame. You can > +also provide this value with a numeric prefix. > @end defun > > @defun set-frame-width frame width &optional pretend pixelwise > @@ -1136,9 +1136,9 @@ Frame Size > refuse to fully honor the request if it does not increase/decrease the > frame width to a multiple of its character width. > > -When used interactively, this command will set the width of the > -currently selected frame to the number of columns specified by the > -numeric prefix. > +When used interactively, this command will ask the user for the number > +of columns to set the width of the currently selected frame. You can > +also provide this value with a numeric prefix. > @end defun > > None of these three functions will make a frame smaller than needed to > diff --git a/etc/NEWS b/etc/NEWS > index fa8784db59..08935dcce4 100644 > --- a/etc/NEWS > +++ b/etc/NEWS > @@ -253,6 +253,10 @@ commands. The new keystrokes are 'C-x x g' ('revert-buffer'), > ('clone-buffer'), 'C-x x i' ('insert-buffer') and 'C-x x t' > ('toggle-truncate-lines'). > > +--- > +** Commands 'set-frame-width' and 'set-frame-height' can now get their > +input using the minibuffer. > + > > * Editing Changes in Emacs 28.1 > > diff --git a/lisp/subr.el b/lisp/subr.el > index ef0e5e6f78..692346c8ba 100644 > --- a/lisp/subr.el > +++ b/lisp/subr.el > @@ -2965,6 +2965,14 @@ goto-char--read-natnum-interactive > (default (and (natnump number) number))) > (list (read-number prompt (list default (point))))))) > > +(defun set-frame-property--interactive (prompt number) > + "Get a value for `set-frame-width' or `set-frame-height', prompting with PROMPT. > +Offer NUMBER as default value, if it is a natural number." > + (if (and current-prefix-arg (not (consp current-prefix-arg))) > + (list (selected-frame) (prefix-numeric-value current-prefix-arg)) > + (let ((default (and (natnump number) number))) > + (list (selected-frame) (read-number prompt (list default (point))))))) > + > > (defvar read-char-history nil > "The default history for the `read-char-from-minibuffer' function.") > diff --git a/src/frame.c b/src/frame.c > index a62347c1fb..cfdf3b6193 100644 > --- a/src/frame.c > +++ b/src/frame.c > @@ -3595,7 +3595,7 @@ check_frame_pixels (Lisp_Object size, Lisp_Object pixelwise, int item_size) > } > > DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 4, > - "(list (selected-frame) (prefix-numeric-value current-prefix-arg))", > + "(set-frame-property--interactive \"Frame height: \" (frame-height))", > doc: /* Set text height of frame FRAME to HEIGHT lines. > Optional third arg PRETEND non-nil means that redisplay should use > HEIGHT lines but that the idea of the actual height of the frame should > @@ -3620,7 +3620,7 @@ DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 4, > } > > DEFUN ("set-frame-width", Fset_frame_width, Sset_frame_width, 2, 4, > - "(list (selected-frame) (prefix-numeric-value current-prefix-arg))", > + "(set-frame-property--interactive \"Frame width: \" (frame-width))", > doc: /* Set text width of frame FRAME to WIDTH columns. > Optional third arg PRETEND non-nil means that redisplay should use WIDTH > columns but that the idea of the actual width of the frame should not > -- > 2.28.0