如何在启动时最大化Windows上的Emacs?
这让我抓狂:我只是想让Emacs最大化到启动时的屏幕分辨率。理想情况下,我喜欢在任何屏幕分辨率下都能工作的跨平台(Windows和Linux)解决方案,但我甚至不能让它在Windows XP上工作,甚至连硬编码的大小都不行 以下是我尝试过的:如何在启动时最大化Windows上的Emacs?,emacs,elisp,Emacs,Elisp,这让我抓狂:我只是想让Emacs最大化到启动时的屏幕分辨率。理想情况下,我喜欢在任何屏幕分辨率下都能工作的跨平台(Windows和Linux)解决方案,但我甚至不能让它在Windows XP上工作,甚至连硬编码的大小都不行 以下是我尝试过的: 使用适当的高度/宽度设置初始帧列表 设置默认帧列表 (特定于Windows的东西)向emacs Windows发送消息,告诉它通过(w32 send sys command 61488) 尝试了我在某处找到的此功能: (取消全屏切换() “切换当前选定的帧
(w32 send sys command 61488)
(取消全屏切换()
“切换当前选定的帧是否占用整个显示
或者用窗框装饰”
(互动)
(let((f(选定帧)))
(修改结构件参数)
F
`((全屏),(如果(等式nil(帧参数f'全屏))
“两个都好
无(()())()))
更新: 这些答案让我觉得是init文件中的其他东西导致了这个问题。的确如此!经过反复尝试,我找到了罪犯。如果我把下面这行注释掉,一切都会很完美:
(工具栏模式-1)
工具栏究竟与最大化窗口有什么关系
所以现在的问题是:如何禁用工具栏(毕竟,emacs的工具栏很难看,占用了宝贵的屏幕空间),并最大化init文件中的窗口?这可能是一个错误,工具栏干扰了窗口的大小
澄清:(工具栏模式-1)关闭工具栏,但这一行干扰了Emacs窗口的最大化。因此,如果我尝试将函数最大化窗口并关闭工具栏,最大化部分将失败;如果工具栏部分被注释掉,那么最大化部分将正常工作。我使用什么解决方案(在我列出的4种解决方案中)都无关紧要
解决方案:(或者至少是现在适合我的方案) 这可能是Emacs中的一个bug。解决方法是通过注册表而不是在.emacs中禁用工具栏。将以下内容另存为.reg文件,并在Windows资源管理器中执行该文件:
Windows注册表编辑器5.00版
[HKEY\U当前用户\软件\ GNU\Emacs]
“Emacs.Toolbar”=“-1”
(此解决方案是OtherMichael建议的工作版本)。嘿,功能不错!谢谢你的发帖 我认为它可能不适合您,因为您的代码看起来像 在init文件中的其他地方跟踪。正在应用默认的帧列表 创建框架后。我删除了大小和位置元素,您可以使用 对emacs的启动非常有用
(setq default-frame-alist
(list
(cons 'left 350)
(cons 'top 0)
(cons 'width 80)
(cons 'height 45)
......
下面是my.emacs文件中调用的最后一个函数,它设置屏幕的高度和宽度。它在debian和mac os x上的emacs 22和emacs 23上都可以使用。根据屏幕设置高度和宽度数字。要禁用工具栏,请添加行
(tool-bar-mode nil)
到您的自定义文件(通常是根目录中的.emacs)。我发现这解释了您必须操作注册表才能正确操作:
要启动Emacs maximized,请将此行
在~/.emacs文件的末尾:
(defun jbr-init ()
"Called from term-setup-hook after the default
terminal setup is
done or directly from startup if term-setup-hook not
used. The value
0xF030 is the command for maximizing a window."
(interactive)
(w32-send-sys-command #xf030)
(ecb-redraw-layout)
(calendar)
)
(setq term-setup-hook 'jbr-init)
(setq window-setup-hook 'jbr-init)
如果您不想要Emacs工具栏
您可以添加行(工具栏模式-1)[注意:原始页面上的值为0]
添加到~/.emacs文件,但emacs不会
在这种情况下,完全最大化-真实
工具栏占用的空间为
迷路的您必须禁用工具栏
在注册表中,要将其取回,请执行以下操作:
如果您在EmacsWiki下查看,您会发现
61488
是X.org上的最大化当前帧,系统调用是(因为您最初要求跨平台解决方案):
(取消x11最大化帧()
“最大化当前帧(全屏显示)”
(互动)
(x-send-client-message nil 0 nil”\u NET\u WM\u STATE“32”(2”\u NET\u WM\u STATE\u MAXIMIZED\u HORZ“0))
(x-send-client-message nil 0 nil”\u NET\u WM\u STATE“32”(2”\u NET\u WM\u STATE\u MAXIMIZED\u VERT“0)))
解决此问题的另一种方法是在
(menu-bar-mode -1)
(tool-bar-mode -1)
(tooltip-mode -1)
(scroll-bar-mode 1)
并设置frame-*函数。例如:
(tool-bar-mode -1)
(when window-system
(run-at-time (format "%d sec" 1) nil '(lambda () (set-frame-position (selected-frame) 1 1)))
(run-at-time (format "%d sec" 2) nil '(lambda () (set-frame-width (selected-frame) 150 t)))
(run-at-time (format "%d sec" 3) nil '(lambda () (set-frame-height (selected-frame) 60 t)))
)
设置帧-*功能之间的延迟也很重要 首先,感谢您提供了有关错误的提示(工具栏模式-1);省去了我很多麻烦!我宁愿将所有内容都保存在.emacs文件中(我没有注册表mods),因此,如果在最大化之前打开工具栏,然后再次关闭它,则可以很好地最大化:
(defun maximize-current-frame () "Resizes the current frame to fill the screen"
(interactive)
;; There is a bug in tool-bar-mode that prevents it from being
;; maximized, so turn it on before maximizing.
;; See http://stackoverflow.com/questions/815239/how-to-maximize-emacs-on-windows-at-startup)
(tool-bar-mode 1)
(w32-send-sys-command 61488)
(tool-bar-mode -1)
)
这是对我有效的最简单的修复方法:
(w32-send-sys-command #xf030)
(add-hook 'window-setup-hook (lambda () (tool-bar-mode -1)))
如果您真的想在没有窗口浏览器(标题栏和最大/最小/关闭按钮)的情况下运行Emacs全屏,请尝试以下模式。这对我在XP SP3上使用Emacs 23.3.1很有效 每一个人。 emacs 23.3.1,blow代码无效。因为(菜单栏模式-1)会导致windows无法 全屏也一样
(w32-send-sys-command #xf030)
(add-hook 'window-setup-hook (lambda () (tool-bar-mode -1)))
我搜索Eamcs wiki,找到一个可用的方法
微软视窗
如果您使用的是MS Windows,并且希望使用“真正的全屏”,即去掉顶部标题栏和所有内容,请参阅网站上的w32全屏以了解暗室模式
或者,这里提供了一个补丁,使全屏帧参数在Windows上真正全屏显示
要获得最大化的窗口,可以使用:(w32 send sys命令#xf030)
<
(defun maximize-current-frame () "Resizes the current frame to fill the screen"
(interactive)
;; There is a bug in tool-bar-mode that prevents it from being
;; maximized, so turn it on before maximizing.
;; See http://stackoverflow.com/questions/815239/how-to-maximize-emacs-on-windows-at-startup)
(tool-bar-mode 1)
(w32-send-sys-command 61488)
(tool-bar-mode -1)
)
(w32-send-sys-command #xf030)
(add-hook 'window-setup-hook (lambda () (tool-bar-mode -1)))
(w32-send-sys-command #xf030)
(add-hook 'window-setup-hook (lambda () (tool-bar-mode -1)))
(defun jbr-init ()
"Called from term-setup-hook after the default
terminal setup is
done or directly from startup if term-setup-hook not
used. The value
0xF030 is the command for maximizing a window."
(interactive)
(w32-send-sys-command #xf030)
(ecb-redraw-layout)
(calendar)
)
(setq term-setup-hook 'jbr-init)
(setq window-setup-hook 'jbr-init)
if [ "$(pidof emacs)" ] ; then
emacsclient "$@"
else
emacs -mm "$@"
fi
(defun jbr-init ()
"Called from term-setup-hook after the default
terminal setup is
done or directly from startup if term-setup-hook not
used. The value
0xF030 is the command for maximizing a window."
(interactive)
(w32-send-sys-command #xf030)
(ecb-redraw-layout)
(calendar)
)
(setq term-setup-hook 'jbr-init)
(setq window-setup-hook 'jbr-init)
(add-to-list 'initial-frame-alist '(fullscreen . maximized))