简短的回答是将以下内容添加到您的custom-set-variables:-
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
...
'(initial-frame-alist (quote ((fullscreen . maximized))))
...
)
下面给出的是 我想要的作为解决同一问题的方法。 TL;博士。
我在所有应用程序中都面临同样的问题,而不仅仅是在 Emacs 中。为此,我已将 Mac 上的快捷键 cmd-m 全局绑定到缩放菜单选项,该选项通常是绿色最大化按钮的菜单选项。然而,Emacs 不提供通常在 Window 菜单项下的 Zoom 菜单选项。所以我最终得到了以下结果。
我昨晚刚刚编写了以下代码。
;; This defines cmd-m to do the same as clicking the green titlebar button
;; usually meant for the "Window -> Zoom" menu option in Mac apps
(defun zoom () "zoom, same as clicking the green titlebar button in Mac app windows"
(interactive)
(set-frame-parameter
nil 'fullscreen
(pcase (frame-parameter nil 'fullscreen)
(`nil 'fullheight)
(`fullheight 'maximized)
(`fullboth (ding) 'fullboth)
(`fullscreen (ding) 'fullscreen)
(_ nil))))
(global-set-key (kbd "s-m") 'zoom)
代码最后一行中的这个键盘快捷键与我最初描述的全局到 Mac cmd+m 键绑定很相配。您可以将其自定义为适合您的任何内容。我习惯于在启动大多数应用程序时按 cmd-m 直到它适合屏幕,而 Emacs 对我来说就是其中之一。所以我不打扰initial-frame-alist 设置。
我今晚继续通过添加以下代码来完成我想要的功能集。
;; This defines ctrl-cmd-f to do the same as clicking the toggle-fullscreen titlebar
;; icon usually meant for the "View -> Enter/Exit Full Screen" menu option in
;; Mac apps
(defun toggle-fullscreen() "toggle-fullscreen, same as clicking the
corresponding titlebar icon in the right hand corner of Mac app windows"
(interactive)
(set-frame-parameter
nil 'fullscreen
(pcase (frame-parameter nil 'fullscreen)
(`fullboth nil)
(`fullscreen nil)
(_ 'fullscreen))))
(global-set-key (kbd "C-s-f") 'toggle-fullscreen)
; For some weird reason C-s-f only means right cmd key!
(global-set-key (kbd "<C-s-268632070>") 'toggle-fullscreen)
几个注意事项:-
- 如果您只是在此代码中学习使用
pcase,请注意不要犯与我一样的错误,将反引号误读为文档中的引号。
-
fullscreen 是 fullboth 的别名,并不是像后者那样用词不当,因此我不仅将这种情况作为(frame-parameter nil 'fullscreen) 的值处理,而且在我想@时使用它987654330@ 至 fullboth
HTH