The methods for toggling full screen on Emacs/Mac vary by version. I've reorganized this post to document what I've used for various versions of Emacs. As of 2012-11-01 I was using the Yamamoto Mitsuharu version of Emacs, which has a very nice full screen mode; as of 2014-01-01 I switched to the Emacs 24.4 nightlies from EmacsForMacOSX.com, but I also suggest looking at the railwaycat emacs build, which is also available on Homebrew.

Carbon Emacs 22.2

You can run M-x mac-toggle-max-window to toggle full screen mode, with no menubar. This is handy enough that I've bound it to ⌘ Cmd+Return, which is similar to what some Linux and Windows apps use to toggle full screen mode.

(define-key global-map [(alt return)] 
  'mac-toggle-max-window)
Carbon Emacs 22.5

They seem to have removed the function from 22.2, but you can get it back with this code from Vebjorn Lsoja:

(defun mac-toggle-max-window ()
  (interactive)
  (set-frame-parameter nil 'fullscreen 
    (if (frame-parameter nil 'fullscreen)
      nil
      'fullboth))) 
Yamamoto Mitsuharu's Emacs Port

Use the mac-toggle-max-window function definition above.

GNU (Cocoa/Nextstep) Emacs 23

Neither approach above works with this version. Instead I'm using a patched version of maxframe.el, and this function from the EmacsWiki page:

(defvar maxframe-maximized-p nil "maxframe is in fullscreen mode")
(defun toggle-maxframe ()
  "Toggle maximized frame"
  (interactive)
  (setq maxframe-maximized-p (not maxframe-maximized-p))
  (cond (maxframe-maximized-p (maximize-frame))
        (t (restore-frame))))
(define-key global-map [(alt return)] 'toggle-maxframe)

Unfortunately this doesn't hide the menubar or titlebar.

For other versions, check the EmacsWiki page to see if there's a method that works on the version you run, or check this page for Aquamacs.

Labels: , ,

8 comments:

Anonymous wrote at Thursday, July 31, 2008 at 9:35:00 PM PDT

Another handy app is iterm, where command - return toggles to completely full screen mode too. I often run regular emacs like that.

Anonymous wrote at Wednesday, August 13, 2008 at 1:16:00 PM PDT

Amit, thanks for the code snippet in the update. It seems to work in carbon emacs as well, but it resizes 1 line too big so that the minibuffer is hidden from view.

Anonymous wrote at Monday, March 9, 2009 at 9:42:00 PM PDT

Thanks for the tip! The key binding didn't work for me for some reason, but this did:

(define-key global-map (kbd "M-RET") 'mac-toggle-max-window)

(just in case it might help someone else)

topfunky wrote at Wednesday, October 7, 2009 at 12:52:00 PM PDT

I use this mode constantly, but would love to tell it to use my second monitor (instead of the main one). Is this possible?

Brendan wrote at Thursday, March 25, 2010 at 11:31:00 AM PDT

Oh hell yes! This is the best. Thanks for this post.

aidan wrote at Thursday, June 17, 2010 at 3:16:00 PM PDT

Thanks, this is great. Similar to Anonymous above, the key binding didn't work for me, so I used this instead:

(global-set-key (kbd "M-RET") 'mac-toggle-max-window)

Anonymous wrote at Monday, January 10, 2011 at 11:55:00 AM PST

Thanks for the post,
unfortunately Vebjørns solution

(set-frame-parameter nil 'fullscreen 'fullboth)

does not work for me.

I am new to Mac OS X and find it quite awkward... I got a very fancy MacBook Air as a job machine and am feeling a bit lost right now.

Although a newbee with Linux/Emacs I do miss my emacs/Xubuntu combo, so I am working on a dual boot.

It has to be possible to use emacs fullscreen in Mac OS X!? Any ideas?

Macbook Air 3.2
Mac OS X 10.6.6
Emacs 23.2 (I downloaded it from gnu.org)

Amit wrote at Monday, January 10, 2011 at 6:47:00 PM PST

rforge: Check the EmacsWiki page (http://www.emacswiki.org/emacs/FullScreen). You can either use the maxframe package to resize the frame to use up the screen (not ideal, as it doesn't hide the titlebar or menubar), or you can patch the Emacs code and build a new binary.