How do I set the size of Emacs' window?

前端 未结 10 1454
陌清茗
陌清茗 2020-12-04 06:19

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)

10条回答
  •  一生所求
    2020-12-04 06:40

    (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)
    

    I prefer Bryan Oakley's settings. However the 'height not work properly in my GNU Emacs 24.1.1.

提交回复
热议问题