How to make emacs truly full screen on start up?

I want emacs to be truly maximized on start up.

There are solutions to the problem that just make the emacs window width of the screen. That's not enough for me. I want the emacs window to be docked to the right upper corner of the screen, so that when I press there with a mouse, I will close emacs, not Firefox or Krusader or whatever is maximized in the background.

I tried to do it with Kwin - but no luck.

P.S. I'm using Kubuntu, and emacs is quite fresh one 23.2 or something like that.


I've taken this from somewhere on emacswiki, some time ago. Note that I no longer use it, as I've switched to dwm to have everything fullscreen, but it used to work.

(defun fullscreen ()
       (interactive)
       (x-send-client-message nil 0 nil "_NET_WM_STATE" 32
                 '(2 "_NET_WM_STATE_FULLSCREEN" 0)))

If you want it to run on startup, you should be able to add

(fullscreen)

to your .emacs

EDIT: Rereading your question, I think this is not what you want. This will go really fullscreen, not maximized: you will not have any close button.

This one should do:

(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)))

Now it's directly from http://www.emacswiki.org/emacs/FullScreen


Here are two non-Lisp ways to achieve the same:

  1. Alias your emacs command to emacs -fs. Add this line of code to your .bashrc file in your home directory:

    alias emacs='emacs -fs'
    

    Personally, I don't like this approach because I wouldn't want Emacs to start up in full screen all the time and would like some control.

  2. My solution: In Ubuntu, you can assign a keyboard shortcut to 'full-screen' any window. This seems to be the most convenient and simple option. Besides, it has the advantage that the same shortcut also applies to all your applications.


Put (w32-send-sys-command ?\xf030) on your .emacs file. I think it solves your problem.

(works on Windows only)