From the Emacs Linux man page (command line “man emacs”), for maximized frame, and for complete full screen:
|Maximize the first frame, like “-fw -fh” (since Emacs 23.2)|
|Make the first frame fullscreen|
emacs -mm [files]
On MS Windows, when parameters don’t work, use the following line instead in your .emacs init file to start with maximized frame:
Probably the simplest way to configure fullscreen or maximized mode is to customize
(custom-set-variables '(initial-frame-alist (quote ((fullscreen . maximized)))))
Library frame-cmds.el provides various commands to maximize and restore frames horizontally, vertically, or both. It applies to any platform and any Emacs version (20+), and it can take into account a standalone minibuffer frame, the MS Windows task bar, and Mac areas that should not be covered.
As is true for other methods mentioned on this page, “maximized” here is not quite the same thing as “full-screen”. Maximizing here means making a frame as big as possible (possibly leaving room for the things mentioned above), but the frame still appears as a frame, with title bar, border, etc.
frame-cmds.el also includes other, related commands, to tile frames across or down your display, for instance. These are the commands relevant to this topic:
At least on my Ubuntu installation, directly calling (toggle-fullscreen) from the .emacs gives weird layout behaviour. It seems that window resizes have to take place after something which is evaluated after the .emacs, so this did the job for me:
(run-with-idle-timer 0.1 nil 'toggle-fullscreen)
Note that an after-init-hook didn’t work for me.
These methods may be useful with older versions of Emacs, or ports where the ‘fullscreen’ frame parameter is not supported.
The simplest way to get near fullscreen editing is to hide the Windows taskbar and maximize the current Emacs frame. You can use the control panel to make the taskbar always hidden (autohide), or call TSTBARSET from the command line with the appropriate flag to toggle the taskbar’s visibility. (TSTBARSET is a utility to manipulate the taskbar from the command line; scroll near the bottom of linked page to download it).
If the menubar on the emacs frame still bothers you, a call to emacs-fullscreen-win32 listed below will get rid of it.
If you’re using MS Windows, and want to use “real fullscreen”, i.e, getting rid of the top titlebar and all, see w32-fullscreen at the site for darkroom-mode
Alternatively, a patch is available here that makes the fullscreen frame parameter really fullscreen on Windows.
Another option is to use emacs-fullscreen-win32 project. It allows you to switch to/from full-screen mode.
(defun toggle-full-screen () (interactive) (shell-command "emacs_fullscreen.exe")) (global-set-key [f11] 'toggle-full-screen)
If you want to hide menu-bar, tool-bar, and scroll-bar forever, then use this code:
(menu-bar-mode -1) (tool-bar-mode -1) (scroll-bar-mode -1)
If you want to start Emacs in full-screen mode then put call to toggle-full-screen function into your .emacs file:
If you want to hide menu-bar, tool-bar, and scroll-bar in full-screen mode and restore them in windowed mode then use this code:
(defun toggle-full-screen () "Toggles full-screen mode for Emacs window on Win32." (interactive) (shell-command "emacs_fullscreen.exe")) (defun toggle-bars () "Toggles bars visibility." (interactive) (menu-bar-mode) (tool-bar-mode) (scroll-bar-mode)) (defun toggle-full-screen-and-bars () "Toggles full-screen mode and bars." (interactive) (toggle-bars) (toggle-full-screen)) (global-set-key [f11] 'toggle-full-screen-and-bars)
Here is a part of my .emacs file. Emacs will start in full-screen mode. Menu-bar, tool-bar, and scroll-bar are visible in windowed mode (and are invisible in full-screen mode):
;; Hide splash-screen and startup-message (setq inhibit-splash-screen t) (setq inhibit-startup-message t) (defun toggle-full-screen () "Toggles full-screen mode for Emacs window on Win32." (interactive) (shell-command "emacs_fullscreen.exe")) (defun toggle-bars () "Toggles bars visibility." (interactive) (menu-bar-mode) (tool-bar-mode) (scroll-bar-mode)) (defun toggle-full-screen-and-bars () "Toggles full-screen mode and bars." (interactive) (toggle-bars) (toggle-full-screen)) ;; Use F11 to switch between windowed and full-screen modes (global-set-key [f11] 'toggle-full-screen-and-bars) ;; Switch to full-screen mode during startup (toggle-full-screen-and-bars)
emacs_fullscreen.exe supports --topmost command line switch. If this switch is present, then Emacs window will be topmost. It will hide task bar and all other windows. The downside is that if you want to switch to other window, you cannot use Alt+Tab directly, you have to turn off the full screen mode first (see 866d015f9a7b changeset).
To get a maximized window you can use: (w32-send-sys-command #xf030)
Attention! If you want that emacs starts maximized, you have to put this code into your .emacs file:
(defun jbr-init () "Called from term-setup-hook after the default terminal setup is done or directly from startup if term-setup-hook not used. The value 0xF030 is the command for maximizing a window." (interactive) (w32-send-sys-command #xf030) (ecb-redraw-layout) (calendar) ) (setq term-setup-hook 'jbr-init) (setq window-setup-hook 'jbr-init)
I admire the unobtrusive UI of Emacs. But the one thing I painfully missed was the ability to truly fullscreen Emacs on Windows. So I took the Emacs 24.1 codebase and crudely patched the window handling code to let it create a window without the title bar for the first frame. I use this patch on Windows XP SP3 and Windows 7.
The combination of the font and screen size could leave gaps on the lower and right side of the screen. To correct this, play around with the font size and the internal border width:
%EMACS_DIR%\bin\runemacs.exe --xrm="emacs.verticalScrollBars:off" --xrm="emacs.menuBar:off" --xrm="emacs.toolBar:0" --font "Courier New-13" --fullscreen --internal-border=4
If you need to minimize the frame, you can use something like this:
(defun minimize-frame () (interactive) (w32-send-sys-command #xf020))
The following maps the function 11 key to toggle fullscreen on X11 (Linux, BSD, etc…).
I (Ivan Kanis) have tested it works on Emacs 24.1.
(defun toggle-fullscreen () "Toggle full screen on X11" (interactive) (when (eq window-system 'x) (set-frame-parameter nil 'fullscreen (when (not (frame-parameter nil 'fullscreen)) 'fullboth)))) (global-set-key [f11] 'toggle-fullscreen)
(defun fullscreen () (interactive) (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 '(2 "_NET_WM_STATE_FULLSCREEN" 0)))
Or to only maximize window:
(defun fullscreen (&optional f) (interactive) (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 '(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0)) (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 '(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0)))
If you want to bind F11 to toggle full-screen, here is what you need:
(defun switch-full-screen () (interactive) (shell-command "wmctrl -r :ACTIVE: -btoggle,fullscreen"))
(global-set-key [f11] 'switch-full-screen)
That does the trick, and now you are GNOME HIG compliant ☺
(defun switch-full-screen () (interactive) (shell-command "wmctrl -r :ACTIVE: -btoggle,maximized_vert,maximized_horz"))
(defun switch-full-screen () (interactive) (shell-command (concat "wmctrl -i -r " (frame-parameter nil 'outer-window-id) " -btoggle,maximized_vert,maximized_horz"))
;; ;; ~/.devilspie/emacs.ds ;; (if (or (contains (window_class) "emacs") (contains (window_class) "Emacs")) (undecorate fullscreen))
If you use GNOME you can assign a Keyboard Shortcut to toggle Full Screen or not. Just go to
System ⇒ Preferences ⇒ Keyboard Shortcuts
And bind the option “Toggle fullscreen mode” to a key which can be used when using Emacs to toggle full screen or not.
The disadvantage of this is that if you bind F11 so that emacs matches other programs, then the window manager handles the resize/de-chroming and the application does not get a chance to modify it’s appearance. For example, Mozilla Firefox will not set its toolbars to auto-hide.
‘ns-use-native-fullscreen’ to get “native” fullscreen on OS X 10.7.
M-x toggle-frame-fullscreen or
M-x toggle-frame-maximized are available without having to define a function from below.
This is the simplest approach, and works with CarbonEmacs and Aquamacs and the Yamamoto Mitsuharu version of Emacs 24. Use the toggle function:
(defun toggle-fullscreen () "Toggle full screen" (interactive) (set-frame-parameter nil 'fullscreen (when (not (frame-parameter nil 'fullscreen)) 'fullboth)))
or use this to always use fullscreen:
(set-frame-parameter nil 'fullscreen 'fullboth)
Apparently the fullscreen functionality had not made it into Emacs 24 as of late 2012 but it is confirmed to be in Emacs 24.3.1 running on OS X 10.8.3 as of April 2013.
Maximizer is a free utility that brings Full Screen app mode to all Cocoa apps running in Mac OS X Lion 10.7, even if they don’t technically support the feature yet. It also works with Emacs from emacsformacosx.com. For more info go to article at osxdaily.com.
To add the fullscreen functionality into Emacs, you can compile your own binary.
Patch for Emacs 23.1.95 pretest was posted Jan 2010, and contains instructions for using typester’s patch with newer versions of Emacs. (Recommended)
This blog post uses typester’s patch with newer versions of Emacs, and includes a download link to for a patched version of Emacs 24.0.50.
Emacs 23 Mac Port contains another patch; it’s unclear whether it’s related to the above.
homebrew builds emacs23 with the fullscreen patch:
brew install emacs --cocoa
Then use the function
The patch is currently disabled for emacs24 (see the issue on GitHub).
There is a working homebrew formula that enables fullscreen mode under OS X Lion for the current git head versions (as of march 2012). Install using
brew install https://gist.github.com/raw/1946398/e7bbb52a4fe3ae0060e65df3d4a7462730ddc822/emacs.rb --force --HEAD --cocoa --use-git-head
If your Emacs does not support fullscreen, it can be faked with the maxframe library, which resizes the window to approximately cover the entire screen. Use patched maxframe.el for Cocoa/Nextstep Emacs. You can see the original version from maxframe.el, which works for Windows, X11, and Carbon.
(require 'maxframe) (defvar my-fullscreen-p t "Check if fullscreen is on or off") (defun my-toggle-fullscreen () (interactive) (setq my-fullscreen-p (not my-fullscreen-p)) (if my-fullscreen-p (restore-frame) (maximize-frame))) (global-set-key (kbd "M-RET") 'my-toggle-fullscreen)
(defvar my-fullscreen-p t "Check if fullscreen is on or off") (defun my-non-fullscreen () (interactive) (if (fboundp 'w32-send-sys-command) ;; WM_SYSCOMMAND restore #xf120 (w32-send-sys-command 61728) (progn (set-frame-parameter nil 'width 82) (set-frame-parameter nil 'fullscreen 'fullheight)))) (defun my-fullscreen () (interactive) (if (fboundp 'w32-send-sys-command) ;; WM_SYSCOMMAND maximaze #xf030 (w32-send-sys-command 61488) (set-frame-parameter nil 'fullscreen 'fullboth))) (defun my-toggle-fullscreen () (interactive) (setq my-fullscreen-p (not my-fullscreen-p)) (if my-fullscreen-p (my-non-fullscreen) (my-fullscreen)))
See also Fullscreen.
(defadvice handle-switch-frame (after maximize-frame activate) "Maximize frame every time it receives focus, i.e. a switch-frame event." (w32-send-sys-command #xf030))