It drives me crazy: I just want Emacs to maximize to whatever screen resolution I had at startup. Ideally, I like the cross-platform (Windows and Linux) solution that works at any screen resolution, but I can't even get it to work only with Windows XP with even hard-coded sizes.
Here is what I tried:
- Setting the start-alist frame with the appropriate height / width
- Setting the default-frame-alist
- (Windows-specific stuff) Sending a message to emacs windows that tell it to maximize using
(w32-send-sys-command 61488) Tried this function, which I found somewhere:
(defun toggle-fullscreen () "toggles whether the currently selected frame consumes the entire display or is decorated with a window border" (interactive) (let ((f (selected-frame))) (modify-frame-parameters f `((fullscreen . ,(if (eq nil (frame-parameter f 'fullscreen)) 'fullboth nil))))))
- I tried the above methods both at the beginning and at the end of my initialization file, in order to try to eliminate interference from other init things.
Unfortunately, none of this works !! For some of the above, I see that my emacs windows change correctly for a second before returning to the small default size. And if I run the above methods after initialization, then emacs windows correctly resize. What is going on here in the world?
[ps there are other SO questions, but none of the answers work]
Update:
The answers make me think that something else in my initialization file is causing the problem. And really! After some attempts and mistakes, I found the culprit. If I commented on the following line, everything works fine:
(tool-bar-mode -1)
What does the toolbar do to maximize windows?
So now the question is: how do I turn off the toolbar (after all, the emacs toolbar is ugly and takes precious screen real estate) And maximize windows like in my initialization file? Perhaps the error is that the toolbar is blocking the size of the window?
Clarification: (tool-bar-mode -1) disables the toolbar, but this line interferes with maximizing Emacs windows. Therefore, if I try to put functions to maximize windows and disable the toolbar, the maximum part will not work; if part of the toolbar is commented out, then the maximization part will work fine. It doesnβt matter which solutions I use (among the 4 that I listed).
Solution: (or at least what works for me now)
This is probably a bug in Emacs. The workaround is to disable the toolbar through the registry, not in .emac. Save the following as a .reg file and execute this file in Windows Explorer:
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\GNU\Emacs] "Emacs.Toolbar"="-1"
(This solution is a working version of what another Michael suggested).
emacs elisp
polyglot May 2 '09 at 17:20 2009-05-02 17:20
source share