tags:

views:

1080

answers:

4

I know you can change the frame size in the .emacs file with set-frame-width or (add-to-list 'default-frame-alist '(width . 80)) but how can I change the width after Emacs has started up (aside from dragging the edge of the frame)?

+5  A: 

Well, go to the *scratch* buffer and use set-frame-width.

(set-frame-width (selected-frame) 100)  ;; ^J to execute.

set-frame-width isn't interactive, so you can't run it with M-x but you could trivially write a set-frame-width-interactive, something like

(defun set-frame-width-interactive (arg)
   (interactive "p")
   (set-frame-width (selected-frame) arg))

Now C-u 8 0 M-x set-frame-width-interactive will set the width to 80.

Is this what you're trying to do?

Charlie Martin
A: 

In addition to Charlie Martin's suggestions, you can do

M-: (set-frame-width (selected-frame) N)
Chris Conway
+2  A: 

This library has a bunch of interactive commands for your use: http://www.emacswiki.org/emacs/frame-cmds.el

Here are a few relevant ones:

enlarge-frame
enlarge-frame-horizontally
hide-frame
mouse-show-hide-mark-unmark
move-frame-down
move-frame-left
move-frame-right
move-frame-up
show-a-frame-on
show-frame
shrink-frame
shrink-frame-horizontally
tile-frames
Trey Jackson
+1  A: 

To toggle between 2 frame sizes easily you could define something like that (e.g., add it to your ".emacs" file) (adapt the sizes to your screen and fonts)

  (defvar myfullscreen '()
    "non-nil if current frame is in fullscreen mode. See myfullscreen-on, myfullscreen-off, myfullscreen-toggle")

  (defun myfullscreen-on ()
    "Sets fullscreen on (based on ???display??? with font ???)"
    (interactive)
    (set-frame-width (selected-frame) 177); adapt size
    (set-frame-height (selected-frame) 58); adapt size
    (setq myfullscreen t)
    )

  (defun myfullscreen-off ()
    "Sets fullscreen off (based on ???display??? with font ???)"  
    (interactive)
    (set-frame-width (selected-frame) 110); adapt size
    (set-frame-height (selected-frame) 58); adapt size
    (setq myfullscreen nil)
    )

  (defun myfullscreen-toggle ()
    "Toggles fullscreen on/off (based on ???Display??? with font ???)"    
    (interactive)
    (if (eq myfullscreen 'nil)
     (myfullscreen-on)
         ;else
   (myfullscreen-off)
   )
    )

Then, you can use

M-x myfullscreen-on

M-x myfullscreen-off

M-x myfullscreen-toggle

and/or bind them to your favorite key bindings