0

I usually set .emacs to open frames (windows) that nearly fill the laptop desktop. When I boot the laptop with an external monitor hooked, I end up needing to enlarge the first and every subsequent emacs frame by hand.

What do I write in my .emacs so that when I launch either the first or subsequent emacs frames, the emacs window is smaller than the desktop by just 2 columns and 2 rows?

Calaf
  • 10,113
  • 15
  • 57
  • 120
  • Have you had a look at http://stackoverflow.com/questions/92971/how-do-i-set-the-size-of-emacs-window? [One answer](http://stackoverflow.com/a/94277/789593) is about setting the size according to resolution. – N.N. Mar 17 '12 at 11:42
  • Thanks. I'm tinkering with it. So far it works for the initial frame, but the new frames have a smaller font and frame size. – Calaf Mar 17 '12 at 12:39
  • Please include what you have got so far and what is not working in your question. Then it will be easier to help you and you show that you made an effort. – N.N. Mar 17 '12 at 12:42
  • My effort looks like it is even working :) – Calaf Mar 17 '12 at 12:49
  • Then please post it as an answer to your question. – N.N. Mar 17 '12 at 12:50
  • The code you pointed to works out of the box and solves exactly the question I asked (though I prefer to use a height that depends on the height of the desktop alone, not on the size of the font). The additions are to maintain my current .emacs, which also caters for the case when I am on MS Windows. I'm not sure how others handle this, but I've found that it's too much of a hassle to maintain more than one .emacs file. It's better to spend a little extra time maintaining a single .emacs file than to constantly find out that some nice addition is in .emacs on one system but not the other. – Calaf Mar 17 '12 at 13:04
  • So this can be marked as a duplicate of that question? – N.N. Mar 17 '12 at 13:06
  • Yes, though not one revealed by a few searches or by stackoverflow's suggested "similar titles". The link from here should do it. – Calaf Mar 17 '12 at 13:11
  • No worries, sometimes it is really hard to find the correct post. I have flagged it as a duplicate. – N.N. Mar 17 '12 at 13:21

2 Answers2

0

Since at least Emacs 24 and the upcoming Emacs 25, it is possible to get maximized Emacs initial and default frames with:

(add-to-list 'initial-frame-alist '(fullscreen . maximized))
(add-to-list 'default-frame-alist '(fullscreen . maximized))

On OS X this is not perfect. You will run into this problem, but the two lines above will get you most of the way there.

Community
  • 1
  • 1
Calaf
  • 10,113
  • 15
  • 57
  • 120
0

I use initial-frame-alist to maximize the first Emacs frame in my init file:

  (setq initial-frame-alist `((top . 1) (left . 1)
                              (width . 1000) (height . 1000)))

In this elisp, 1000 stands for merely an enough large number. Although this elisp is not aesthetically beautiful, it works well for me.

initial-frame-alist is specific to the first Emacs frame, so you might want to use default-frame-alist instead, if you'd like to enlarge subsequent Emacs frames.

tnoda
  • 1,534
  • 9
  • 18
  • You misread my question. I was looking for variables identifying the size of the desktop (x-display-pixel-width/height in the link above). – Calaf Mar 19 '12 at 17:29