我正在使用来自http://emacsformacosx.com/的Mac Emacs,并且需要在启动Emacs时点击最大化图标。
我该如何将最大化的Emacs窗口设置为默认窗口?
我该如何将最大化的Emacs窗口设置为默认窗口?
按照以下方式启动emacs
emacs -mm
maxframe.el
在Aquamacs和Emacs.app上都能正常运行。我是通过EmacsWiki找到的:http://www.emacswiki.org/emacs/FullScreen。那个页面讲了一个补丁版本,但现在已经成为404页面,不过在https://github.com/rmm5t/maxframe.el上的原始版本似乎很好用。请注意保留html标记。这是我编写并使用的一个函数。当你连续按下 F11 键时,emacs 会切换到 4 种模式:
(defun switch-fullscreen nil
(interactive)
(let* ((modes '(nil fullboth fullwidth fullheight))
(cm (cdr (assoc 'fullscreen (frame-parameters) ) ) )
(next (cadr (member cm modes) ) ) )
(modify-frame-parameters
(selected-frame)
(list (cons 'fullscreen next)))))
(define-key global-map [f11] 'switch-fullscreen)
fullboth
模式时,框架会占据屏幕上的所有内容;也就是说,WM 窗口标题栏消失了,我的 XFCE 面板也消失在窗口后面(我正在使用 Xubuntu)。fullheight
模式正常工作:框架仅使用 XFCE 面板留给它的垂直空间。我希望 fullboth
模式能够像按下标题栏中的 +
按钮一样正常工作。有什么想法可以实现吗? - Teemu Leistifullboth
是一个误称。在普通的 Mac 术语中,它使 Emacs 进入全屏模式。而 maximized
才是真正的全屏! - trsscustom-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))))
...
)
;; 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)
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)
的值进行处理,而且每当我想要将set-frame-parameter
设置为fullboth
时都会使用它。希望对您有所帮助。
这个https://dev59.com/qnRA5IYBdhLWcg3wzhbZ#1029065 给出的答案对我有用(使用GNU Emacs v24.2.1)。简而言之,在您的.emacs
文件中定义以下函数:
(defun x11-maximize-frame ()
"Maximize the current frame (to full screen)"
(interactive)
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32 '(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32 '(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
为了方便起见,您可以将该命令绑定到一个键上。我使用C-z
键,否则它会最小化框架,而我不需要它,但总是在我意外按下它时感到烦恼:
(global-set-key (kbd "C-z") 'x11-maximize-frame)