以编程方式设置 Emacs 框架大小

发布于 2024-07-09 20:43:39 字数 409 浏览 10 评论 0原文

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

我一直在玩以下内容:

(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

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

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

沫离伤花 2024-07-16 20:43:39

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

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))
著墨染雨君画夕 2024-07-16 20:43:39
(setq initial-frame-alist '(
            (top . 40) (left . 10)
            (width . 128) (height . 68)
            )
  )
(setq initial-frame-alist '(
            (top . 40) (left . 10)
            (width . 128) (height . 68)
            )
  )
一紙繁鸢 2024-07-16 20:43:39

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

发现于:

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

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

Found at :

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

沦落红尘 2024-07-16 20:43:39

之前发布的解决方案都无法解决我的调整大小问题,因此我想分享一个额外的解决方案:启动时,Emacs 23 使用某种字体,然后切换到用户定义的字体; 因此,如果该字体较大,Emacs 还会减小窗口大小,使其适合屏幕。 然后,应用用户字体,并且窗口可能看起来比用户期望的小。 因此,在我的 ~/.Xresource 中添加以下内容解决了这个问题:

Emacs.font: -*-fixed-*-*-*-*-8-*-*-*-*-*-*-*
Emacs.pane.menubar.*.fontList: 8x16
Emacs.menu*.fontList:         -*-fixed-*-*-*-*-8-*-*-*-*-*-*-*
Emacs.dialog*.fontList:        -*-fixed-*-*-*-*-8-*-*-*-*-*-*-*

这使得 Emacs 在启动时使用小字体,这样它的窗口就不会太大并且不会被截断。 当然,您可能想在此处或 Emacs 初始化文件中自定义所需的字体。

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.

拥抱影子 2024-07-16 20:43:39

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

  (setq initial-frame-alist
                (cons '(width . 96)
                      (cons '(height . 72)
                        (cons '(menu-bar-lines . 1)
                          initial-frame-alist))))

,当我“升级”到 Emacs 23.2 时,上面的内容并没有出现。不再完全了。 Emacs 不是我的职业。 我将其用作工具,因此我无法投入太多时间来深入了解原因。 因此,我只是通过向 Emacs Windows XP 快捷方式添加“-geometry 96x72”来解决该问题。 所以快捷方式目标现在看起来:

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

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
拒绝两难 2024-07-16 20:43:39

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

HKCU\Software\GNU\Emacs\
    Emacs.Geometry REG_SZ "245x74"

(这使得机器本地设置远离我的 .emacs 文件,我与许多其他机器共享该文件......)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文