Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want a keyboard shortcut to open emacs in a maximised window. I tried emacs --fullscreen, but that is full screen rather than maximised window... That is, the emacs window covers ubuntu menu bars. emacs -fw gets a full width window and emacs -fh gets a full height window, but if you put both options, it only reads the second one. At the moment, I just have another keyboard shortcut for maximising a window. Is there a way to get emacs to start maximised?

Ubuntu 9.10, emacs 22, if that makes a difference.

share|improve this question
add comment

4 Answers

up vote 3 down vote accepted

I have this in my .emacs, which I then bind to a key:

(defun my-frame-toggle ()
  "Maximize/Restore Emacs frame using 'wmctrl'."
  (interactive)
  (shell-command "wmctrl -r :ACTIVE: -btoggle,maximized_vert,maximized_horz"))

(global-set-key [(control f4)] 'my-frame-toggle)

You can then hit CtrlF4 and toggle between regular and full-screen (but not covering the Ubuntu menu bar and bar at the bottom of the screen whose name I'm blanking on at the moment). To start up that way simply invoke it:

$ emacs -e "my-frame-toggle"
share|improve this answer
add comment

I had the same problem. Found the answer in this thread: http://ubuntuforums.org/showthread.php?t=1619533

Basically from the command line start emacs with this parameters:

  • emacs -fs //if you want emacs to cover all your screen (cover the ubuntu bar)
  • emacs -mm //if you want emacs to start like you pressed the maximize button (shows ubuntu bar)

Of course you can bind those starting options to an icon and have emacs always start the way you want.

share|improve this answer
    
Superb! emacs -fs works perfectly in Ubuntu 12.10 –  Chris McCauley Dec 5 '12 at 14:52
add comment

I have the following functions in my .emacs, which first defines the codes to send the window manager to maximize the frame on X.org and Win32 respectively, and then add this as a setup hook, if applicable:

(defun x-maximize-frame ()
    "Maximize the current frame (to full screen)"
    (interactive)
    (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 '(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
    (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 '(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))

(defun w32-maximize-frame ()
  "Maximize the current frame (to full screen)"
  (interactive)
  (w32-send-sys-command 61488))

(defun maximize-frame ()
    (if (eq window-system 'w32)
            (w32-maximize-frame)
        (x-maximize-frame)))

(if window-system
    (add-hook 'window-setup-hook 'maximize-frame t))
share|improve this answer
add comment

This might be what you're looking for. You could also hard-code the pixel width/height for your screen, and set that in your .emacs file (the author covers that here).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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