如何设置Emacs窗口的大小? [英] How do I set the size of Emacs' window?

查看:110
本文介绍了如何设置Emacs窗口的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试检测我正在启动emacs的屏幕大小,并调整其开始的窗口的大小和位置(我猜这是emacs中的框架)。我正在设置我的.emacs,以便我总是在屏幕左上方的左上角看到一个合理大的窗口。

I'm trying to detect the size of the screen I'm starting emacs on, and adjust the size and position the window it is starting in (I guess that's the frame in emacs-speak) accordingly. I'm trying to set up my .emacs so that I always get a "reasonably-big" window with it's top-left corner near the top-left of my screen.

我想这是一个大的请求一般情况,所以要缩小一点我最感兴趣的是在Windows和(Debian)Linux上的GNU Emacs 22。

I guess this is a big ask for the general case, so to narrow things down a bit I'm most interested in GNU Emacs 22 on Windows and (Debian) Linux.

推荐答案

如果要根据分辨率更改大小,可以这样做(根据具体需要调整首选宽度和分辨率):

If you want to change the size according to resolution you can do something like this (adjusting the preferred width and resolutions according to your specific needs):

(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中,窗口系统已被弃用。一个合适的替代品是(display-graphic-p)。有关此答案 -detect-that-emacs-in-in-terminal-mode>如何检测emacs是否处于终端模式?多一点背景。

Note that window-system is deprecated in newer versions of emacs. A suitable replacement is (display-graphic-p). See this answer to the question How to detect that emacs is in terminal-mode? for a little more background.

这篇关于如何设置Emacs窗口的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆