
當我啟動 emacs 時,它總是全螢幕。我找不到 emacs 啟動的配置不是全螢幕(最大化)。我不是唯一遇到這個問題的人:
http://ubuntuforums.org/showthread.php?t=2282182
系統:
- 戴爾 XPS 15
- Ubuntu 14.04(出廠安裝)
- Emacs 24.3.1(出廠安裝,已更新)
我已經嘗試過該--geometry
選項,它可以從命令列運行,但不會改變停靠圖示的行為。即使我刪除圖標,使用 custom 從命令列啟動--geometry
,並鎖定新圖標 - 它也會再次以全螢幕模式啟動。我的設定也沒有任何運氣*-frame-alist
。還有什麼其他配置可以做到這一點?
答案1
我還有一台配備 HiDPI 螢幕的戴爾 XPS,也遇到了同樣的問題。結果Emacs 想要佔用比可用的更多的螢幕空間,因為在我的Emacs 啟動檔案中,我將幀寬度設為88 個字符,由於我將UI 比例因子設為2 以使內容在HiDPI 顯示器上可讀,因此該寬度加倍了。因此視窗管理器(正確地)以全螢幕模式開啟 Emacs。當我嘗試 ennob 的解決方案時我發現了這一點http://ubuntuforums.org/showthread.php?t=2282182。在 ennob 的程式碼中,幀大小為 40 x 25 個字符,這導致我的系統上的幀大小為 80x50。一些實驗證實,Emacs 在設定框架的實際寬度和高度時,會將請求的文字寬度和高度乘以比例因子。
您可以從 dconf 取得比例因子:
dconf read /com/ubuntu/user-interface/scale-factor
在我的系統上返回{'eDP1': 16}
.比例因子 1 給出{'eDP1': 8}
.所以我概括了 ennob 的程式碼並將其添加到我的 Emacs 啟動檔案中(對我來說,~/.emacs.d/init.el)
:
(defun my:window-setup-hook ()
(when (and (string= system-type "gnu/linux") window-system)
(toggle-frame-maximized)
(let* ((dconf-entry
(shell-command-to-string
"dconf read /com/ubuntu/user-interface/scale-factor"))
(scale-factor (progn (string-match "'[eD][FD]P1': \\([0-9]+\\)[,\}]"
dconf-entry)
(string-to-int (match-string 1 dconf-entry))))
(text-width (truncate (/ desired-width (/ scale-factor 8.0))))
(text-height (truncate (/ desired-height (/ scale-factor 8.0)))))
(message "set-frame-size is %dx%d, scale-factor is %s"
text-width text-height scale-factor)
(set-frame-size (selected-frame) text-width text-height))))
(setq window-setup-hook 'my:window-setup-hook)
這適用於比例因子 >= 2 且預設字體為 14 pt ( (set-face-attribute 'default nil :height 140)
) 的情況。所以我仍然不明白起作用的眾多因素,但我眼前的問題已經解決,我希望這也對您有幫助。
答案2
@chris-simpkins 的答案幾乎對我有用,但切換全螢幕的功能由於某種原因不起作用:/根據我的評論,這裡是對我有用的程式碼(我更喜歡更窄的螢幕):
(defun toggle-fullscreen-x11 ()
"Toggle full screen on X11"
(interactive)
(when (eq window-system 'x)
(set-frame-parameter
nil 'fullscreen
(when (not (frame-parameter nil 'fullscreen)) 'fullboth))))
(defun my:window-setup-hook ()
(toggle-fullscreen-x11)
(when window-system
(let* ((dconf-entry
(shell-command-to-string
"dconf read /com/ubuntu/user-interface/scale-factor"))
(scale-factor (progn (string-match "{'eDP1': \\([0-9]+\\)}"
dconf-entry)
(string-to-int (match-string 1 dconf-entry))))
;; text-width make room for gutter and fringes
(text-width (truncate (/ 48 (/ scale-factor 8.0))))
(text-height (truncate (/ 50 (/ scale-factor 8.0)))))
(set-frame-size (selected-frame) text-width text-height))))
(setq window-setup-hook 'my:window-setup-hook)