在GNU / Linux中,启动Emacs后我经常按alt-f10来最大化窗口(在Emacs术语中,它实际上是一个frame)。 大多数情况下,我会按三次,因为我太早按第一个alt-f10键,这会导致一些垃圾出现在minibuffer周围(Emacs显示错误?)
我该如何自动化这个过程? (也许可以通过Gnome设置或elisp实现?)
我正在使用emacs24(来自bzr repo)。
请注意,我想要的不是常规全屏模式,您可以通过按f11来获得。
(defun fullscreen (&optional f)
(interactive)
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0))
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0)))
可能有效。(来自这里。)
;; 以下代码适用于 Emacs 21.4、22.3、23.1、24.3 版本。 (when window-system (let ( (px (display-pixel-width)) ; 显示器宽度 (py (display-pixel-height)) ; 显示器高度 (fx (frame-char-width)) ; 字符宽度 (fy (frame-char-height)) ; 字符高度 tx ty ) ;; 下面的公式是在 Windows 平台上使用默认字体经验发现的。 (setq tx (- (/ px fx) 7)) (setq ty (- (/ py fy) 4)) (setq initial-frame-alist '((top . 2) (left . 2))) (add-to-list 'initial-frame-alist (cons 'width tx)) (add-to-list 'initial-frame-alist (cons 'height ty)) ) )此代码为 Windows/Gnome/KDE 系统下保留任务栏位置。
但是,您可以尝试阅读以下链接了解如何全屏显示:http://www.emacswiki.org/emacs/FullScreen
(setq default-frame-alist '((width . 190) (height . 50) ))
这样的东西吗?我是LISP的新手,所以... - Lenar Hoyt(add-to-list 'default-frame-alist '(height . 24))
和 (add-to-list 'default-frame-alist '(width . 80))
。请参考http://www.emacswiki.org/emacs/FrameSize。 - gavenkoaOSX:
Emacs Trunk的开发版中有一个名为toggle-frame-maximized
的函数,该函数包含在.../lisp/frame.el
中。该函数可以添加到after-init-hook
或emacs-startup-hook
中,或者可以简单地包含在在启动时加载的.emacs
文件中。在OSX上,它一次性增加了宽度和高度。
Windows XP:
在make-frame
命令之后或Emacs生成初始帧之后,可以使用以下命令。
(w32-send-sys-command 61488)
OSX和Windows
这是一个设置初始框架大小和位置的示例--我将它放在我的.emacs
文件的开头:
(let ((frame (selected-frame)))
(cond
((eq system-type 'darwin)
(setq ns-auto-hide-menu-bar t)
(set-frame-position frame 0 0) ;; must come after `ns-auto-hide-menu-bar`
(cond
((and
(= 1920 (display-pixel-width))
(= 1080 (display-pixel-height)))
(set-frame-size frame 1895 1054 t))
((and
(= 1920 (display-pixel-width))
(= 1200 (display-pixel-height)))
(set-frame-size frame 1895 1174 t))
((and
(= 1280 (display-pixel-width))
(= 800 (display-pixel-height)))
(set-frame-size frame 1265 774 t))) )
((and
(eq system-type 'windows-nt)
(equal (w32-version) '(5 1 2600)))
;; (w32-send-sys-command #xf030)
(set-frame-position frame 0 0)
(cond
((and
(= 1920 (display-pixel-width))
(= 1003 (display-pixel-height)))
(set-frame-size frame 1898 924 t))
((and
(= 1920 (display-pixel-width))
(= 1123 (display-pixel-height)))
(set-frame-size frame 1876 1052 t))
((and
(= 1280 (display-pixel-width))
(= 723 (display-pixel-height)))
(set-frame-size frame 1250 670 t))))
((and
(eq system-type 'windows-nt)
(equal (w32-version) '(6 1 7601)))
(set-frame-position frame 0 0)
(cond
((and
(= 1920 (display-pixel-width))
(= 1080 (display-pixel-height)))
(set-frame-size frame 1890 1003 t))
(t
(message "Not yet contemplated.")))) ))
(defun lawlist-make-frame (&optional alist)
(let ((frame (make-frame alist)))
(set-frame-position frame 0 0)
(cond
((eq system-type 'darwin)
(cond
((and
(= 1920 (display-pixel-width))
(= 1080 (display-pixel-height)))
(set-frame-size frame 1895 1054 t))
((and
(= 1920 (display-pixel-width))
(= 1200 (display-pixel-height)))
(set-frame-size frame 1895 1174 t))
((and
(= 1280 (display-pixel-width))
(= 800 (display-pixel-height)))
(set-frame-size frame 1265 774 t))))
((and
(eq system-type 'windows-nt)
(equal (w32-version) '(5 1 2600)))
(select-frame frame)
(cond
((and
(= 1920 (display-pixel-width))
(= 1003 (display-pixel-height)))
(set-frame-size frame 1898 924 t))
((and
(= 1920 (display-pixel-width))
(= 1123 (display-pixel-height)))
(set-frame-size frame 1876 1052 t))
((and
(= 1280 (display-pixel-width))
(= 723 (display-pixel-height)))
(set-frame-size frame 1250 670 t))))
((and
(eq system-type 'windows-nt)
(equal (w32-version) '(6 1 7601)))
(select-frame frame)
(cond
((and
(= 1920 (display-pixel-width))
(= 1080 (display-pixel-height)))
(set-frame-size frame 1890 1003 t))
(t
(message "Not yet contemplated.")))) )))
将以下内容放入我的~/.emacs中对我有效(Debian GNU/Linux上的Emacs 24.5.1):
(toggle-frame-maximized)
为了找到它,我使用C-h M-F10检查了M-F10快捷键调用的命令名称:它返回“toggle-frame-maximized”,我只需在我的~/.emacs中调用它。
另一个解决方案,可能更好,可以在这里找到:
(add-to-list 'initial-frame-alist '(fullscreen . maximized))
由于某些原因,x-send-client-message在某个时刻无法正常工作(或者说不可靠)。因此我使用以下方法:
(defun set-maximized ()
(interactive)
(shell-command "wmctrl -r :ACTIVE: -badd,maximized_vert,maximized_horz"))
在启动时执行以下操作:
(add-hook 'window-setup-hook 'set-maximized t)
initial-frame-alist
或相应的xrdb
资源设置为所需的几何尺寸呢?请参阅 https://dev59.com/lnVD5IYBdhLWcg3wGHeu 获取代码和指针。 - tripleee