我正在尝试检测正在启动emacs的屏幕的大小,并相应地调整窗口的大小和位置(我猜这就是emacs中的帧)。我正在尝试设置我的.emacs,以便我总是得到一个“相当大”的窗口,它的左上角靠近屏幕的左上角。
我想这是一个很大的要求,所以为了缩小范围,我最感兴趣的是Windows和(Debian) Linux上的GNU Emacs 22。
发布于 2008-09-18 16:40:11
如果你想根据分辨率改变大小,你可以这样做(根据你的特定需求调整首选的宽度和分辨率):
(defun set-frame-size-according-to-resolution ()
(interactive)
(if window-system
(progn
;; use 120 char wide window for largeish displays
;; and smaller 80 column windows for smaller displays
;; pick whatever numbers make sense for you
(if (> (x-display-pixel-width) 1280)
(add-to-list 'default-frame-alist (cons 'width 120))
(add-to-list 'default-frame-alist (cons 'width 80)))
;; for the height, subtract a couple hundred pixels
;; from the screen height (for panels, menubars and
;; whatnot), then divide by the height of a char to
;; get the height we want
(add-to-list 'default-frame-alist
(cons 'height (/ (- (x-display-pixel-height) 200)
(frame-char-height)))))))
(set-frame-size-according-to-resolution)
请注意,在较新版本的emacs中不推荐使用window-system。一个合适的替代方案是(display-graphic-p)
。有关更多背景信息,请参阅this answer to the question How to detect that emacs is in terminal-mode?。
发布于 2008-09-18 16:29:30
我的.emacs
中有以下内容
(if (window-system)
(set-frame-height (selected-frame) 60))
您还可以查看函数set-frame-size
、set-frame-position
和set-frame-width
。使用C-h f
(又称M-x describe-function
)调出详细的文档。
我不确定在当前的窗口环境中是否有办法计算框架的最大高度/宽度。
发布于 2008-09-18 14:26:48
摘自:http://www.gnu.org/software/emacs/windows/old/faq4.html
(setq default-frame-alist
'((top . 200) (left . 400)
(width . 80) (height . 40)
(cursor-color . "white")
(cursor-type . box)
(foreground-color . "yellow")
(background-color . "black")
(font . "-*-Courier-normal-r-*-*-13-*-*-*-c-*-iso8859-1")))
(setq initial-frame-alist '((top . 10) (left . 30)))
第一个设置适用于所有emacs帧,包括启动时弹出的第一个帧。第二个设置将附加属性添加到第一个帧。这是因为有时知道你开始emacs的原始框架是很好的。
https://stackoverflow.com/questions/92971
复制相似问题