启动时最大化Emacs?(不是全屏)

kin*_*ero 21 emacs elisp

在Emacs启动以最大化窗口之后,按下alt-f10(在GNU/Linux中)是很常见的(在Emacs术语中,它实际上是一个帧).我大部分时间都按三次因为我太早了按第一个alt-f10,这会使迷你缓冲区周围出现一些垃圾(Emacs显示bug?)

我该如何自动化这个呢?(也许使用Gnome设置或使用elisp?)

我正在使用emacs24(来自bzr repo).

请注意,这不是我想要的常规全屏,按f11即可获得.

phi*_*mue 14

(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)))
Run Code Online (Sandbox Code Playgroud)

可能有用.(取自这里.)

  • 此代码在Windows/Mac OS X下无效.查看我的解决方案... (3认同)

gav*_*koa 10

;; Next code works with 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
        )
    ;; Next formulas discovered empiric on Windows host with default font.
    (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


law*_*ist 9

OSX:

Emacs Trunk的开发人员构建有一个名为的函数toggle-frame-maximized,它包含在其中.../lisp/frame.el.该函数可以添加到after-init-hookor emacs-startup-hook,或者只是包含在.emacs启动时加载的文件中.在OSX上,它一举增加宽度和高度.


Windows XP:

可以在make-frame命令之后或Emacs生成初始帧之后使用以下命令.

(w32-send-sys-command 61488)
Run Code Online (Sandbox Code Playgroud)

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.")))) ))
Run Code Online (Sandbox Code Playgroud)

这是我用来创建新框架的示例 - 控制确切的大小和位置:

(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.")))) )))
Run Code Online (Sandbox Code Playgroud)


use*_*594 5

将其放入我的 ~/.emacs 中对我来说很有效(Debian GNU/Linux 上的 Emacs 24.5.1):

(toggle-frame-maximized)

为了找到这一点,我用以下命令检查了 M-F10 快捷方式调用的命令的名称:Ch M-F10:它返回“toggle-frame-maximized”,我只是在 ~/.emacs 中调用它。

另一个解决方案,可能甚至更好,在这里找到:

(add-to-list 'initial-frame-alist '(fullscreen . maximized))