【问题标题】:Maximize Emacs on start up? (not the fullscreen)在启动时最大化 Emacs? (不是全屏)
【发布时间】:2011-12-07 12:13:48
【问题描述】:

在 Emacs 启动后按 alt-f10(在 GNU/Linux 中)以最大化窗口(在 Emacs 术语中,它实际上是一个框架)对我来说很常见。大多数时候我按三次是因为我太早了,无法按第一个 alt-f10,这会使 minibuffer 周围出现一些垃圾(Emacs 显示错误?)

我怎样才能自动化这个? (也许使用 Gnome 设置或使用 elisp?)

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

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

【问题讨论】:

  • 您为什么不将initial-frame-alist 或相应的xrdb 资源设置为您想要的几何图形呢?有关代码和指针,请参见 stackoverflow.com/questions/92971/…
  • 我想要全屏,接受的答案满足我的需要。谢谢你的链接顺便说一句。

标签: emacs elisp


【解决方案1】:
(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)))

可能会奏效。 (取自here。)

【讨论】:

  • @phimuemue 奇怪的是 kindhaero不是全屏 所以我提出了另一个可以修改为这样使用的解决方案...跨度>
  • &optional 参数 f 有什么用?
【解决方案2】:
;;下一个代码适用于 Emacs 21.4、22.3、23.1、24.3。 (当窗口系统 (让 ( (px (显示像素宽度)) (py(显示像素高度)) (fx (帧字符宽度)) (fy (frame-char-height)) 发送 ) ;;下一个公式在 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

【讨论】:

  • 谢谢.. 这个没用。是的,我应该先去emacswiki。只是我最近读了很多关于 SO 的文章。
  • 我忘了补充一下,这段代码只适用于 Emacs 加载,所以你需要把它放到 .emacs 文件中......希望这有帮助......
  • 是的。我明白这一点..但它似乎不是我想要的。因为我使用不同分辨率的显示器,所以我想要的是最大化窗口而不是特定大小。
  • @kindahero。我的解决方案是自适应的而不是特定的大小))
  • 效果很好。我也可以以某种方式设置默认帧大小吗?像(setq default-frame-alist '((width . 190) (height . 50) )) 这样的东西?我是 LISP 新手,所以……
【解决方案3】:

OSX:

Emacs Trunk 的开发者版本有一个名为toggle-frame-maximized 的函数,它包含在.../lisp/frame.el 中。该函数可以添加到after-init-hookemacs-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.")))) )))

【讨论】:

    【解决方案4】:

    把它放到我的 ~/.emacs 中对我有用(Debian GNU/Linux 上的 Emacs 24.5.1):

    (toggle-frame-maximized)

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

    找到了另一个可能更好的解决方案here

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

    【讨论】:

    • (toggle-frame-maximized) 在 Emacs 27.1 / OSX Catalina 上为我工作
    【解决方案5】:

    由于某种原因,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)
    

    【讨论】:

      猜你喜欢
      • 2010-10-23
      • 1970-01-01
      • 1970-01-01
      • 2011-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多