4

Are there emacs commands which will let me resize/move the frames/windows?

By frame/window I mean the GUI object that X/Windows/whateverAppleCallsIt to contain the interface to emacs. Sorry, emacs language conflicts with OS-GUI language.

1
  • Emacs 25 (net yet officially released, but available to the public if so desired) contains some important bug fixes if you eventually decide to create frames and have them set at precise sizes/locations from the outset -- including, but not limited to pixelwise.
    – lawlist
    Jul 31, 2016 at 16:37

4 Answers 4

5

There are the built in functions set-frame-size, set-frame-height, set-frame-width and set-frame-position which let's you programmatically set the frame size and position.

For example (set-frame-size (selected-frame) 300 300 t) would set the currently selected frame size to 300x300 pixels.

If you want to set the size interactively there is the frame-cmds package available on melpa that you can install via M-x package-install RET frame-cmds RET if you have melpa in you package-archives list or download from it from the emacs wiki.

2
  • In addition to frame-cmds.el, which is mentioned by @Tephra, you have library frame-fns.el, on which it depends, and which provides some general frame-manipulation utility functions.

  • Libraries fit-frame.el and autofit-frame.el, which shrink-wrap a frame to fit the text that is in its selected window (used typically in a one-window frame). See Shrink-Wrapping Frames.

  • Library zoom-frm.el lets you easily zoom the text in a frame (or a buffer) in and out. It extends and is more flexible than the standard Emacs text "scaling" provided by vanilla Emacs.

  • Library doremi-frm.el provides another way to incrementally resize frames.

1

Yes, one can find the official detailed list here:

Those could be combined to do all sort of things, like for example:

(defun my/frame-move-resize (position)
  "Resize selected frame to cover exactly 1/3 of screen area, and
  move frame to given third of current screen. Symbol POSITION can
  be either left, center, right."

  (pcase position
    ('left   (setf x 0))
    ('center (setf x 1))
    ('right  (setf x 2)))

  (let* ((HEIGHT (display-pixel-height))
     (WIDTH  (display-pixel-width)))
    (set-frame-size (selected-frame) (/ WIDTH 3) HEIGHT t)
    (set-frame-position (selected-frame) (* x (/ WIDTH 3)) 0)))

;; Example:
(my/frame-move-resize 'center)
-1

moom-move-frame and other related functions in moom package move/resize Emacs frame (not window) https://github.com/takaxp/moom

3
  • Please clarify in which way this package answers the question. Link-only answers are not very valuable since the link may go stale.
    – Stefan
    May 3, 2020 at 4:39
  • In addition to explaining your answer in more detail, please do not post duplicate answers to multiple questions.
    – Dan
    May 3, 2020 at 9:32
  • Modified the answer to reply the question.
    – AhLeung
    May 4, 2020 at 5:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.