Last Updated: February 25, 2016
·
770
· gtg922r

Emacs 24 OS X Fullscreen Keyboard Shortcut

Most applications on OS X Lion allow the user to toggle fullscreen mode via ⌘-ESC. While Emacs 24.3 supports native fullscreen, this keyboard shortcut is not defined by default.

To toggle fullscreen via ⌘-ESC, add the following to your .emacs or .init.el:

;; Shortcut for full screen
(defun toggle-fullscreen (&optional f)
  (interactive)
  (let ((current-value (frame-parameter nil 'fullscreen)))
    (set-frame-parameter nil 'fullscreen
      (if (equal 'fullboth current-value)
        (if (boundp 'old-fullscreen) old-fullscreen nil)
        (progn (setq old-fullscreen current-value)
          'fullboth)))))
(global-set-key [s-escape] 'toggle-fullscreen)

Original Source: Juan Céspedes