From ef122bf45d8ab7f8ec31612ac39fc521039ae19a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Mart=C3=ADn?= Date: Tue, 16 Mar 2021 01:29:28 +0100 Subject: [PATCH] Add minibuffer input support to commands that set the frame size * lisp/frame.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 (bug#9970). --- doc/lispref/frames.texi | 12 ++++++------ etc/NEWS | 4 ++++ lisp/frame.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 f4316b753d8..cd2ff8f3b31 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi @@ -1120,9 +1120,9 @@ The optional fourth argument @var{pixelwise} non-@code{nil} means that 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 @@ The optional fourth argument @var{pixelwise} non-@code{nil} means that 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 18b1252bcae..6fe98dbc123 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/frame.el b/lisp/frame.el index ce4de83b8c5..409ce0563b5 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -2733,6 +2733,14 @@ See also `toggle-frame-maximized'." (make-obsolete-variable 'window-system-version "it does not give useful information." "24.3") +(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))))))) + ;; Variables whose change of value should trigger redisplay of the ;; current buffer. ;; To test whether a given variable needs to be added to this list, diff --git a/src/frame.c b/src/frame.c index a62347c1fb2..cfdf3b61938 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 @@ If FRAME is nil, it defaults to the selected frame. */) } 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.39.5