Maximizing Emacs on startup
Until recently it was impossible to start Emacs in maximized mode in X, but that changed with the release of Emacs 23.2. Now you can force Emacs to start in maximized mode with the command line switch --maximized or -mm.
In Windows you have to use a bit of elisp and Win32 magic to get it to work.
Add this to your .emacs file to make Emacs start in maximized mode in Windows:
(defun maximize-frame () "Maximizes the active frame in Windows" (interactive) ;; Send a `WM_SYSCOMMAND' message to the active frame with the ;; `SC_MAXIMIZE' parameter. (when (eq system-type 'windows-nt) (w32-send-sys-command 61488))) (add-hook 'window-setup-hook 'maximize-frame t) |
The code will only execute on Windows, and it works by sending a WM_SYSCOMMAND window message to itself, telling it to maximize. The magic number 61488 is a constant declared as SC_MAXIMIZED.
Mastering Emacs
This works great for me on Windows XP using GNU Emacs 23.2.1 (i386-mingw-nt5.1.2600) of 2010-05-08 on G41R2F1. Thanks for the awesome tip!
I tested it on Windows XP, and works well, and does not conflict with my [setq initial-frame-alist...]
It also work in GNU Linux distribution?
Thanks
I’ve tested in gNewSense 3.0 but doesn’t work
Sin, because it is a feature that I like.
Hi Mickey!
I’m a recent convert to Emacs and am struggling with some of the basics. Let me explain … I see so much potential for moulding Emacs into an application I would like to see, but some of what seem to be the simplest things are maddeningly difficult. For example:
I like the format of applications that use a tri-term design – like Evolution. It has a small window (using Emacs terminology) on the left, a small window on the top-right, and a large window on the bottom. In Emacs, here is how I create it:
(setq w1 (selected-window)) ; w1 = top left window.
(setq w2 (split-window w1 9)) ; w2 = bottom window.
(setq w3 (split-window w1 35 t)) ; w3 = top right window.
BUT! No matter how hard I try with combinations of “display-buffer” … “select-window” … etc. I cannot make it so that *the buffer I want to see* is in the window I want to see it in.
For example, if I want to see the “calendar” code run in the top right window (w3) I would expect to put code like this in next:
(select-window w3)
(calendar)
…but it doesn’t work as the calendar always seems to force itself into the bottom window. Please help me to understand how to put what I want into the windows that I want to put it in. (Thanks!)
- Bill
Bill,
Welcome to Camp Emacs. It’s a fun editor, with a fairly byzantine tiling window manager.
Generally, in Emacs, we tend to let windows come and go as out needs change; it’s not really all that productive to lock it into a fixed set of tiles like you would in most IDEs. Exceptions here being tools that really are multi-windowed like GUD and so on.
Saying that, there are several options that can alleviate your pains like escreen or just plain “Window Configurations”.
Anyway, your conundrum is caused by errant calendar behavior, but that is easily rectified. Place the following code in your .emacs to force calendar to show itself in the top-right split window:
Have fun.
-Mickey.
Thanks Mickey! Two follow-up questions:
1. What was the purpose of the (interactive) function in this context? (I read the info on it with C-h-f, but didn’t understand it.)
2. Where should I execute (calendar) so there is a *Calendar* buffer to display? (Starting raw without it just causes an error;
“Symbol’s function definition is void: calendar-basic-setup”
when I run the function.)
I’m really enjoying reading your blog and “Mastering Emacs” – THANKS for a great service!
Bill–
You are getting symbol void error because the calendar isn’t loaded. You must add
(require 'calendar)before the defun.Interactive means it is considered a command, which is something you can invoke using M-x.
Glad you’re enjoying the blog!
Thanks AGAIN!!!!!
Learning such complexity is *SO* much easier when you have the right teacher.
Also, I tried to look up both “escreen” and “Window Configurations” in the info docs and couldn’t find them. (?)
escreen is a third-party module — check out the Emacs Wiki. Window Configurations are found under “registers”
Ah! I think I found them! To wit,
http://www.splode.com/~friedman/software/emacs-lisp/src/escreen.el
http://www.google.com/search?hl=en&q=Emacs+%22Window+Configuration%22&aq=f&aqi=&aql=&oq=&gs_rfai=
- Bill
Ooops, it looks like I posted before seeing your reply.
It might be nice to show how to make start with the window vertically maximized, or note that this isn’t possible if it’s not (I think I remember reading some very ugly incantations for it in the past, but I’m not sure).
Thanks. This works
No love for us mac users?! I’m having to manually expand emacs every time I open it!
Sorry, I don’t know if GNU Emacs for MacOSX supports maximizing.