Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

set window size on init

22 views
Skip to first unread message

Xah Lee

unread,
Nov 10, 2009, 2:57:14 PM11/10/09
to
i have, at the end of my .emacs this code:

; set window size to 100x58 chars.
(set-frame-size (selected-frame) 100 58)

however, it doesn't work.
But eval-region the code itself would work.

Anyone know why's that?

Thanks.

Xah
http://xahlee.org/


des...@verizon.net

unread,
Nov 10, 2009, 3:39:16 PM11/10/09
to
Xah Lee <xah...@gmail.com> writes:

> i have, at the end of my .emacs this code:
>
> ; set window size to 100x58 chars.
> (set-frame-size (selected-frame) 100 58)
>
> however, it doesn't work.
> But eval-region the code itself would work.
>
> Anyone know why's that?

I don't think you have a "selected-frame" while
.emacs is being read.

I don't see that in the documentation but under
.emacs processing, it says it reads terminal specific
stuff after it reads the .emacs:

"Emacs runs the hook term-setup-hook at the end of initialization, after
both your `.emacs' file and any terminal-specific library have been read
in."

Kiwon Um

unread,
Nov 11, 2009, 3:32:02 AM11/11/09
to
On Nov 11, 4:57 am, Xah Lee <xah...@gmail.com> wrote:
> i have, at the end of my .emacs this code:
>
> ; set window size to 100x58 chars.
> (set-frame-size (selected-frame) 100 58)
>
> however, it doesn't work.
> But eval-region the code itself would work.
>
Check default-frame-alist and init-frame-alist, e.g.:
(setq default-frame-alist '((width . 80) (height . 65)))
(setq init-frame-alist '((width . 80) (height . 65)))

Eli Zaretskii

unread,
Nov 11, 2009, 1:31:51 PM11/11/09
to help-gn...@gnu.org
> From: Xah Lee <xah...@gmail.com>
> Date: Tue, 10 Nov 2009 11:57:14 -0800 (PST)

>
> i have, at the end of my .emacs this code:
>
> ; set window size to 100x58 chars.
> (set-frame-size (selected-frame) 100 58)
>
> however, it doesn't work.
> But eval-region the code itself would work.

Does it help to run this from term-setup-hook or window-setup-hook?

The reason for the inconsistency is that Emacs initializes the GUI
display at some specific point during startup, and any customizations
of the display before that point will generally be overridden.


des...@verizon.net

unread,
Nov 11, 2009, 3:05:06 PM11/11/09
to
Eli Zaretskii <el...@gnu.org> writes:

It might but this page suggests some solutions:

http://emacsblog.org/2007/01/29/maximize-on-startup-part-1/

(The one with the initial-frame-alist seems most useful.)

Xah Lee

unread,
Nov 11, 2009, 4:01:47 PM11/11/09
to

Thanks all for help. The following works as it should.

(setq default-frame-alist
'((menu-bar-lines . 1)
(left-fringe)
(right-fringe)
(tool-bar-lines . 0)
(width . 75)
(height . 50)
))

(setq initial-frame-alist '((width . 100) (height . 50)))

for future reference of later readers, type Ctrl+h v then initial-
frame-alist will give you good doc.

Xah
http://xahlee.org/


Jonathan Groll

unread,
Nov 14, 2009, 1:51:54 AM11/14/09
to help-gn...@gnu.org

The same Ryan McGeary who wrote the above blog entry also wrote
maxframe.el:
http://files.emacsblog.org/ryan/elisp/maxframe.el

I find it works perfectly well for me with GNU emacs under Linux if it
is one of the last things invoked in .emacs.

Under OS X I manually set frame-size as maxframe makes the frame too
big. This is the function I use to set frame-size manually for my
specific display:

;;maximize frame function for darwin - by Nurullah Akkaya on help-gnu-emacs
(defun na-resize-frame-big ()
"Set size"
(interactive)
(set-frame-width (selected-frame) 178)
(set-frame-height (selected-frame) 50 )
(set-frame-position (selected-frame) 0 1))


Regards,
Jonathan


0 new messages