windows 以编程方式设置 Emacs 帧大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/335487/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:41:44  来源:igfitidea点击:

Programmatically setting Emacs frame size

windowsemacsdot-emacs

提问by J Cooper

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.

我的 emacs(在 Windows 上)总是以一个相当小的设定大小启动,如果我调整它的大小,它不会在下次启动时“记住”。

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.

当我在暂存缓冲区中执行它时,它完全有效。我把它放在我的 .emacs 中,虽然现在当我启动程序时,我可以看到框架暂时设置为该大小,但在*scratch*加载时,它再次重置回较小的默认值。

Can anyone help me fix up the above code so that it "sticks" on start-up?

谁能帮我修复上面的代码,使其在启动时“粘住”?

回答by Bill White

Here's what I use in my ~/.emacs:

这是我在我的~/.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))

回答by Cheeso

(setq initial-frame-alist '(
            (top . 40) (left . 10)
            (width . 128) (height . 68)
            )
  )

回答by Eric O Lebigot

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 sizeso 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 23 使用某种字体,然后切换到用户定义的字体;因此,如果该字体很大,Emacs 也会缩小窗口大小以使其适合屏幕。然后,应用用户字体,窗口看起来可能比用户想要的要小。因此,在我的 ~/.Xresource 中添加以下内容解决了问题:

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.

这使得 Emacs 在启动时使用小字体,这样它的窗口就不会太大,不会被截断。当然,您可能希望在此处或在 Emacs init 文件中自定义您想要的字体。

回答by siukurnin

Did you try this : emacs -geometry 110x58+200+2 &

你试过这个吗:emacs -geometry 110x58+200+2 &

Found at :

发现于:

http://web.mit.edu/answers/emacs/emacs_window_size.64R.html

http://web.mit.edu/answers/emacs/emacs_window_size.64R.html

回答by Android Eve

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:

在 Emacs 19 和 21 之间,我曾经有一个完美运行的 .emacs,通过区分默认帧和初始帧,它完全符合您的要求:

  (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:

唉,当我“升级”到 Emacs 23.2 时,上述内容不再完整。Emacs 不是我的职业。我将它用作工具,所以我不能花太多时间深入研究原因。所以我只是通过添加到 Emacs Windows XP 快捷方式“-geometry 96x72”来解决这个问题。所以快捷方式目标现在看起来:

C:\emacs-23.2\bin\runemacs.exe -geometry 96x72

回答by Alastair

For emacs on windows, I generally put it in the registry.

对于windows上的emacs,我一般都放在注册表中。

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...)

(这将机器本地设置排除在我与许多其他机器共享的 .emacs 文件之外......)