首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何设置Emacs的窗口大小?

如何设置Emacs的窗口大小?
EN

Stack Overflow用户
提问于 2008-09-18 14:20:29
回答 9查看 62.5K关注 0票数 107

我正在尝试检测正在启动emacs的屏幕的大小,并相应地调整窗口的大小和位置(我猜这就是emacs中的帧)。我正在尝试设置我的.emacs,以便我总是得到一个“相当大”的窗口,它的左上角靠近屏幕的左上角。

我想这是一个很大的要求,所以为了缩小范围,我最感兴趣的是Windows和(Debian) Linux上的GNU Emacs 22。

EN

回答 9

Stack Overflow用户

回答已采纳

发布于 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?

票数 89
EN

Stack Overflow用户

发布于 2008-09-18 16:29:30

我的.emacs中有以下内容

(if (window-system)
  (set-frame-height (selected-frame) 60))

您还可以查看函数set-frame-sizeset-frame-positionset-frame-width。使用C-h f (又称M-x describe-function)调出详细的文档。

我不确定在当前的窗口环境中是否有办法计算框架的最大高度/宽度。

票数 53
EN

Stack Overflow用户

发布于 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的原始框架是很好的。

票数 21
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/92971

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档