I'm running Emacs 25.1 on macOS Sierra. After opening Emacs using the GUI and maximizing its frame, I execute (C-x C-e) the following code:

(setq ns-auto-hide-menu-bar t)
(set-frame-position nil 0 -24)
(set-frame-size nil (display-pixel-width) (display-pixel-height) t)

This code moves the Emacs frame up so that the title bar is hidden, and then resizes the frame so that it fills the entire screen.

Problem: If I add the code above to my init.el file and relaunch Emacs, the title bar is not hidden anymore. But if I open my init.el and C-x C-e the mentioned code, then the title bar goes away.

Question: How can I make the code above work properly inside my init.el file?

Thanks for helping!

  • I' having trouble getting past the first sentence and reconciling it with your code. Why are you maximizing the frame, and then adjusting the size after you maximize it? How are you maximizing the frame? Why not set the frame size and position exactly and forego playing around with maximizing it beforehand?
    – lawlist
    Jul 6, 2017 at 4:22
  • What's the difference between what you're trying to do and just making the frame fullscreen with (toggle-frame-fullscreen)?
    – stevoooo
    Jul 6, 2017 at 8:44
  • @lawlist by maximizing the frame I mean expanding the Emacs "window" to occupy the entire screen (toggle-frame-maximized). However, that leaves the title bar still visible, and I want to get rid of the title bar. Jul 6, 2017 at 11:57
  • @stevoooo that is a possible solution, but it is not what I am looking for. Making Emacs fullscreen on a Mac will move it to a "new Desktop", and add a bunch of animations when alt-tabbing around other applications. I am trying to achieve an effect similar to fullscreen borderless on Windows. Jul 6, 2017 at 11:58
  • Ah, OK I see what you mean! Hrm actually that would be quite useful for me too - the animations when switching between desktops drives me nuts...
    – stevoooo
    Jul 6, 2017 at 12:57

1 Answer 1


To force it, you could use a hook which is called after emacs sets its frame parameters.

Like this:

(add-hook 'window-setup-hook (lambda()
                                 (setq ns-auto-hide-menu-bar t)
                                 (set-frame-position nil 0 -24)
                                 (set-frame-size nil (display-pixel-width) (display-pixel-height) t)))

Note, that the sequence of your code is not working with every operating system (Window Manager) as you expect. But if your code worked with C-x C-e, then this should solve your problem.

Also (toggle-frame-fullscreen) is doing a similar thing like you want.

If you are interested you might have a look at the emacs startup summary.

  • Thanks for your reply! Adding that hook solved the issue! I didn't want to use toggle-frame-fullscreen because it moves the Emacs window to a "new desktop" window, and it adds some unwanted animations when using alt-tab. Jul 6, 2017 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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