簡體   English   中英

如何在啟動時最大化Windows上的Emacs?

[英]How to maximize Emacs on Windows at startup?

這讓我抓狂:我只是想讓Emacs最大化到我在啟動時的屏幕分辨率。 理想情況下,我喜歡可以在任何屏幕分辨率下工作的跨平台(Windows和Linux)解決方案,但我甚至無法使用甚至硬編碼大小的Window XP。

這是我嘗試過的:

  1. 設置具有適當高度/寬度的初始幀alist
  2. 設置default-frame-alist
  3. (Windows特定的東西)向emacs窗口發送消息告訴它最大化通過(w32-send-sys-command 61488)
  4. 嘗試了我在某處發現的這個功能:

     (defun toggle-fullscreen () "toggles whether the currently selected frame consumes the entire display or is decorated with a window border" (interactive) (let ((f (selected-frame))) (modify-frame-parameters f `((fullscreen . ,(if (eq nil (frame-parameter f 'fullscreen)) 'fullboth nil)))))) 
  5. 在我的init文件的開頭和結尾嘗試了上述方法,試圖消除其他init事件的干擾。

不幸的是,以上都沒有! 對於上面的一些,我可以看到我的emacs窗口在一瞬間正確調整大小,然后恢復到較小的默認大小。 如果我在初始化后運行上面的方法,emacs窗口會正確調整大小。 世界上到底發生了什么?

[ps還有其他SO問題,但沒有一個答案有效]


更新:

答案讓我覺得我的init文件中的其他東西導致了問題。 確實是這樣! 經過一些嘗試和錯誤,我找到了罪魁禍首。 如果我注釋掉以下行,一切都很完美:

(tool-bar-mode -1)

工具欄與最大化窗口有什么關系?

所以現在的問題是:如何禁用工具欄(畢竟,emacs的工具欄很丑陋,占用了寶貴的屏幕空間)並且在我的init文件中最大化了窗口? 可能是工具欄干擾窗口大小的錯誤?

澄清:(工具欄模式-1)關閉工具欄,但此行干擾最大化Emacs窗口。 因此,如果我嘗試將函數放到最大化窗口並關閉工具欄,則最大化部分將失敗; 如果工具欄部分已注釋掉,則最大化部分將正常工作。 它甚至不重要我使用什么解決方案(在我列出的4個中)。


解決方案:(或者至少現在對我有用)

這可能是Emacs中的一個錯誤。 解決方法是通過注冊表禁用工具欄,而不是.emacs。 將以下內容另存為.reg文件,並在Windows資源管理器中執行該文件:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\GNU\Emacs]
"Emacs.Toolbar"="-1"

(此解決方案是OtherMichael建議的工作版本)。

我找到了一年左右的答案 ,這解釋了你必須操縱注冊表來做正確的事情:

要啟動Emacs最大化,請將此行放在〜/ .emacs文件的末尾:

(w32-send-sys-command 61488)

如果您不想使用Emacs工具欄,可以在〜/ .emacs文件中添加行(工具欄模式-1) [注意:原始頁面上的值為0],但Emacs不會完全最大化case - 工具欄占用的房地產丟失。 您必須禁用注冊表中的工具欄才能將其恢復:

[HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs\Emacs.Toolbar]
@="0"

如果您在W32SendSys命令代碼查看EmacsWiki,您會發現61488最大化當前幀

這是對我有用的最簡單的修復:

(w32-send-sys-command #xf030)
(add-hook 'window-setup-hook (lambda () (tool-bar-mode -1)))

伙計,有什么不對

emacs -mm

這使Emacs完全最大化。 把它放在你的快捷方式中,它實際上取決於你使用的窗口管理器; 我自己只是在我的。* shrc中將其別名。

在一個不同但不相關的說明中,我實際上以一種方式啟動Emacs,如果它已經啟動,則所選文件只是在我現有的Emacs會話中作為新緩沖區打開:

if [ "$(pidof emacs)" ] ; then
    emacsclient "$@"
else
    emacs -mm "$@"
fi

我輸入了〜/ bin / e,我只用“e”啟動Emacs。 我右鍵單擊文件管理器中的文本文件,選擇“用另一個程序打開”並輸入“e”,現在我只需雙擊文件,它們都在同一個會話中整齊地打開。

一切都是桃子和lispy :)

在X.org上,系統調用是(因為您最初詢問的是跨平台解決方案):

\n (defun x11-maximize-frame()\n   “最大化當前幀(到全屏)”\n   (互動)\n   (x-send-client-message nil 0 nil“_NET_WM_STATE”32'(2“_NET_WM_STATE_MAXIMIZED_HORZ”0))\n   (x-send-client-message nil 0 nil“_NET_WM_STATE”32'(2“_NET_WM_STATE_MAXIMIZED_VERT”0)))\n

首先,感謝bug的提示(工具欄模式-1); 救了我很多麻煩! 我寧願將所有內容保存在.emacs文件中(對我來說沒有注冊表模式),所以如果在最大化之前打開工具欄,然后再將其關閉,那么你可以很好地最大化:

(defun maximize-current-frame () "Resizes the current frame to fill the screen"
    (interactive)
    ;; There is a bug in tool-bar-mode that prevents it from being
    ;; maximized, so turn it on before maximizing.
    ;; See http://stackoverflow.com/questions/815239/how-to-maximize-emacs-on-windows-at-startup)
    (tool-bar-mode 1)
    (w32-send-sys-command 61488)
    (tool-bar-mode -1)
)

這在Emacs 24.5.1 (i686-pc-mingw32)上可靠地工作:

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

解決此類問題的另一種方法是延遲

(menu-bar-mode -1)
(tool-bar-mode -1)
(tooltip-mode -1)
(scroll-bar-mode 1)

和set-frame- *函數。 例如:

 (tool-bar-mode -1)
 (when window-system
  (run-at-time (format "%d sec" 1) nil '(lambda () (set-frame-position (selected-frame) 1 1)))
  (run-at-time (format "%d sec" 2) nil '(lambda () (set-frame-width (selected-frame) 150 t)))
  (run-at-time (format "%d sec" 3) nil '(lambda () (set-frame-height (selected-frame) 60 t)))
  )

在set-frame- *函數之間放置延遲也很重要!

我遇到了一個似乎有效的命令(toggle-frame-maximized) ,它可以在Linux和Windows上運行。

在設置完所有內容后,我只是把它放在我的init文件的末尾附近,假設在設置結束時一切都不會最大化,瞧,它有效。

如果你真的想在沒有窗口鑲邊(標題欄和最大/最小/關閉按鈕)的情況下全屏運行Emacs,請嘗試下面的模式。 這適用於XP SP3上的Emacs 23.3.1。

http://www.martyn.se/code/emacs/darkroom-mode/

每一個人。 emacs 23.3.1,打擊代碼無效。 因為(菜單欄模式-1)可能導致窗口不全屏。

(w32-send-sys-command #xf030)
(add-hook 'window-setup-hook (lambda () (tool-bar-mode -1)))

我搜索Eamcs wiki,找到一個有用的方法。

http://www.emacswiki.org/emacs/FullScreen#toc3

MS Windows

如果您正在使用MS Windows,並希望使用“真正的全屏”,即擺脫頂部標題欄和所有,請在網站上查看暗室模式的w32全屏

或者,此處提供了一個補丁,使全屏幀參數在Windows上真正全屏。

要獲得最大化窗口,您可以使用:(w32-send-sys-command#xf030)

注意! 如果您希望emacs啟動最大化,則必須將此代碼放入.emacs文件中:

(defun jbr-init ()
  "Called from term-setup-hook after the default
terminal setup is
done or directly from startup if term-setup-hook not
used.  The value
0xF030 is the command for maximizing a window."
  (interactive)
  (w32-send-sys-command #xf030)
  (ecb-redraw-layout)
  (calendar)
)
(setq term-setup-hook 'jbr-init)
(setq window-setup-hook 'jbr-init)

嘿 - 好功能! 謝謝發帖

我認為它可能不適合您,因為您的代碼在您的init文件中的其他地方看起來像以下內容。 在創建幀之后應用default-frame-alist。 我刪除了大小和位置元素,你的功能在emacs的啟動時運行良好。

   (setq default-frame-alist
     (list
      (cons 'left                 350)
      (cons 'top                  0)
      (cons 'width                80)
      (cons 'height               45)
     ......

來自emacswiki的以下片段對我很好:(添加到你的啟動配置文件)

(defun jbr-init ()
"Called from term-setup-hook after the default
terminal setup is
done or directly from startup if term-setup-hook not
used.  The value
0xF030 is the command for maximizing a window."
  (interactive)
  (w32-send-sys-command #xf030)
  (ecb-redraw-layout)
  (calendar)
  )
(setq term-setup-hook 'jbr-init)
(setq window-setup-hook 'jbr-init)

emacs-full-screen-win32項目將幫助你:)

(defun resize-frame ()
"Set size"
(interactive)
(set-frame-width (selected-frame) 110)
(set-frame-height (selected-frame) 33)
(set-frame-position (selected-frame) 0 1))

以下是我的.emacs文件中調用的最后一個函數,它設置了它在debian和mac os x上的emacs 22和emacs 23上都可以工作的屏幕的高度和寬度。 根據您的屏幕設置高度和寬度數字。

要禁用工具欄,請添加該行

(tool-bar-mode nil)

到您的自定義文件(通常是根目錄中的.emacs)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM