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).
This commit is contained in:
Daniel Martín 2021-03-16 01:29:28 +01:00 committed by Lars Ingebrigtsen
parent c4549d3b37
commit ef122bf45d
4 changed files with 20 additions and 8 deletions

View file

@ -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

View file

@ -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

View file

@ -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,

View file

@ -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