如何在启动时最大化 Windows 上的 Emacs? [英] How to maximize Emacs on Windows at startup?

查看:15
本文介绍了如何在启动时最大化 Windows 上的 Emacs?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这让我发疯:我只是想让 Emacs 最大化到我在启动时的任何屏幕分辨率.理想情况下,我喜欢适用于任何屏幕分辨率的跨平台(Windows 和 Linux)解决方案,但我什至无法让它仅在具有硬编码大小的 Window XP 上工作.

这是我尝试过的:

  1. 使用适当的高度/宽度设置初始帧列表
  2. 设置默认帧列表
  3. (Windows 特定的东西)通过 (w32-send-sys-command 61488)
  4. 向 emacs 窗口发送消息,告诉它最大化
  5. 尝试了我在某处找到的这个功能:

    (defun toggle-fullscreen ()" 切换当前选择的帧是否占用整个显示器或装饰有窗口边框"(交互的)(让((f(选定帧)))(修改帧参数F`((全屏. ,(if (eq nil (frame-parameter f 'fullscreen))'全都零))))))

  6. 在我的 init 文件的开头和结尾都尝试了上述方法,以尝试消除其他 init 事物的干扰.

不幸的是,以上都不起作用!!对于上述某些情况,我可以看到我的 emacs 窗口在恢复到较小的默认大小之前一瞬间正确调整了大小.如果我在初始化后运行上述方法,emacs 窗口会正确调整大小.这到底是怎么回事?

[ps.关于此还有其他 SO 问题,但没有一个答案有效]

<小时>

更新:

这些答案让我认为是我的 init 文件中的其他内容导致了问题.确实如此!经过一些尝试和错误,我找到了罪魁祸首.如果我注释掉以下行,则一切正常:

(工具栏模式 -1)

工具栏与最大化窗口有什么关系?

所以现在的问题是:我怎样才能禁用工具栏(毕竟,emacs 的工具栏很丑并且占用宝贵的屏幕空间)并最大化我的 init 文件中的窗口?工具栏干扰窗口大小可能是一个错误?

说明:(tool-bar-mode -1) 关闭工具栏,但此行会干扰 Emacs 窗口的最大化.因此,如果我尝试将函数最大化窗口并关闭工具栏,则最大化部分将失败;如果工具栏部分被注释掉,那么最大化部分将正常工作.我使用什么解决方案(在我列出的 4 个中)甚至都没有关系.

<小时>

解决方案:(或者至少现在对我有用)

这可能是 Emacs 中的一个错误.解决方法是通过注册表禁用工具栏,而不是在 .emacs 中.将以下内容另存为 .reg 文件,然后在 Windows 资源管理器中执行该文件:

Windows 注册表编辑器 5.00 版[HKEY_CURRENT_USERSoftwareGNUEmacs]"Emacs.Toolbar"="-1"

(此解决方案是 OtherMichael 建议的工作版本).

解决方案

我找到了 一年的答案-大约返回,这说明您必须操纵注册表才能正确行事:

<块引用>

要启动 Emacs 最大化把这一行在 ~/.emacs 文件的末尾:

(w32-send-sys-command 61488)

<块引用>

如果你不想要 Emacs 工具栏您可以添加行 (tool-bar-mode -1) [注意:原始页面上的值为 0]到您的 ~/.emacs 文件,但 Emacs 不会在这种情况下完全最大化 - 真正的工具栏占用的空间是丢失.您必须禁用工具栏在注册表中取回它:

[HKEY_LOCAL_MACHINESOFTWAREGNUEmacsEmacs.Toolbar]@="0"

如果您在 W32SendSys command-codes 下查看 EmacsWiki,您会发现61488最大化当前帧

This is driving me crazy: I simply want Emacs to maximize to whatever screen resolution I have at startup. Ideally I like a cross-platform (Windows & Linux) solution that works on any screen resolution, but I can't even get it to work on just Window XP with even hard-coded sizes.

Here are what I tried:

  1. Setting the initial-frame-alist with appropriate height/width
  2. Setting the default-frame-alist
  3. (Windows specific stuff) Sending message to the emacs windows telling it to maximize via (w32-send-sys-command 61488)
  4. Tried this function which I found somewhere:

    (defun toggle-fullscreen ()
      "toggles whether the currently selected frame consumes the entire display
    or is decorated with a window border"
      (interactive)
      (let ((f (selected-frame)))
        (modify-frame-parameters 
         f
         `((fullscreen . ,(if (eq nil (frame-parameter f 'fullscreen)) 
                              'fullboth
                            nil))))))
    

  5. Tried the above methods in both beginning and end of my init file to try to eliminate interference from other init things.

Unfortunately, none of the above works!! For some of the above, I can see my emacs windows resizes correctly for a split second before reverting back to the smallish default size. And if I run the methods above after the initialization, the emacs windows DOES resize correctly. What in the world is going on here?

[p.s. there are other SO questions on this but none of the answers work]


Update:

The answers make me think that something else in my init file is causing the problem. And indeed it is! After some try-and-error, I found the culprit. If I commented out the following line, everything works perfectly:

(tool-bar-mode -1)

What in the world does the toolbar have to do with maximizing windows?

So the question now is: how can I disable toolbar (after all, emacs's toolbar is ugly and takes up precious screen real-estate) AND maximize the windows both in my init file? It is possibly a bug that toolbar interferes with the windows size?

Clarification: (tool-bar-mode -1) turns the toolbar off, but this line interferes with maximizing the Emacs windows. So if I try put functions to maximize windows and turn off the toolbar, the maximize part will fail; if the toolbar part is commented out, then the maximize part will work ok. It does not even matter what solutions I use (among the 4 that I listed).


Solution: (or at least what work for me now)

This is probably a bug in Emacs. The workaround is to disable the toolbar through the Registry, not in .emacs. Save the following as a .reg file, and execute that file in Windows Explorer:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USERSoftwareGNUEmacs]
"Emacs.Toolbar"="-1"

(This solution is a working version of what OtherMichael suggested).

解决方案

I found an answer a year-or-so back that explains you have to manipulate the registry to do things right:

To start Emacs maximized put this line at the end of your ~/.emacs file:

(w32-send-sys-command 61488)

If you don't want the Emacs tool bar you can add the line (tool-bar-mode -1) [NOTE: value is 0 on original page] to your ~/.emacs file but Emacs won't fully maximize in this case - the real estate occupied by the tool bar is lost. You have to disable the tool bar in the registry to get it back:

[HKEY_LOCAL_MACHINESOFTWAREGNUEmacsEmacs.Toolbar]
@="0"

If you look in the EmacsWiki under W32SendSys command-codes you'll find that 61488 is maximize current frame

这篇关于如何在启动时最大化 Windows 上的 Emacs?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆