问题
My emacs (on Windows) always launches with a set size, which is rather small, and if I resize it, it's not "remembered" at next start-up.
I've been playing with the following:
(set-frame-position (selected-frame) 200 2) ; pixels x y from upper left
(set-frame-size (selected-frame) 110 58) ; rows and columns w h
which totally works when I execute it in the scratch buffer. I put it in my .emacs, and although now when I start the program, I can see the frame temporarily set to that size, by the time *scratch*
loads, it resets back to the small default again.
Can anyone help me fix up the above code so that it "sticks" on start-up?
回答1:
Here's what I use in my ~/.emacs
:
(add-to-list 'default-frame-alist '(left . 0))
(add-to-list 'default-frame-alist '(top . 0))
(add-to-list 'default-frame-alist '(height . 50))
(add-to-list 'default-frame-alist '(width . 155))
回答2:
(setq initial-frame-alist '(
(top . 40) (left . 10)
(width . 128) (height . 68)
)
)
回答3:
Did you try this : emacs -geometry 110x58+200+2 &
Found at :
http://web.mit.edu/answers/emacs/emacs_window_size.64R.html
回答4:
None of the solutions posted before could solve my resizing problem, so I thought I'd share an additional solution: upon start-up, Emacs 23 uses a certain font, before switching to the user-defined one; as a consequence, if this font is large, Emacs also reduces the window size so that it fits in the screen. Then, the user font is applied, and the window might appear smaller than what desired by the user. Thus, adding the following in my ~/.Xresource solved the problem:
Emacs.font: -*-fixed-*-*-*-*-8-*-*-*-*-*-*-*
Emacs.pane.menubar.*.fontList: 8x16
Emacs.menu*.fontList: -*-fixed-*-*-*-*-8-*-*-*-*-*-*-*
Emacs.dialog*.fontList: -*-fixed-*-*-*-*-8-*-*-*-*-*-*-*
This makes Emacs use a small font during start-up, so that its window is not too large and is not truncated. Of course, you might want to customize the font you want here, or in the Emacs init file.
回答5:
Between Emacs 19 and 21, I used to have a perfectly working .emacs that did exactly what you are looking for, by distinguishing between default-frame and initial-frame:
(setq default-frame-alist '((foreground-color . "LightGray")
(background-color . "Black")
(cursor-color . "Medium Sea Green")
(width . 80)
(height . 36)
(menu-bar-lines . 1)
(vertical-scroll-bars . right)))
and
(setq initial-frame-alist
(cons '(width . 96)
(cons '(height . 72)
(cons '(menu-bar-lines . 1)
initial-frame-alist))))
Alas, when I "upgraded" to Emacs 23.2 the above doesn't fully anymore. Emacs is not my career. I am using it as a tool, so I can't devote too much time delving into understanding why. So I simply worked around the problem by adding to the Emacs Windows XP shortcut "-geometry 96x72". So the shortcut target now looks:
C:\emacs-23.2\bin\runemacs.exe -geometry 96x72
回答6:
For emacs on windows, I generally put it in the registry.
HKCU\Software\GNU\Emacs\
Emacs.Geometry REG_SZ "245x74"
(This keeps machine-local settings out of my .emacs file, which I share with many other machines...)
来源:https://stackoverflow.com/questions/335487/programmatically-setting-emacs-frame-size