Centre Emacs buffer within window

前端 未结 4 630
执笔经年
执笔经年 2021-02-09 00:52

I wrap all my code at 80 columns, and there are times where the Emacs window is wider than 80 columns and there is a lot of unused whitespace on the right side.

I would

4条回答
  •  别跟我提以往
    2021-02-09 01:10

    As demonstrated here this is indeed possible:

    (set-fringe-mode
     (/ (- (frame-pixel-width)
           (* 80 (frame-char-width)))
        2))
    

    However, as I am testing this I seem to have more luck with using margins, at least when also resizing my frame:

    (defun my-resize-margins ()
      (let ((margin-size (/ (- (frame-width) 80) 2)))
        (set-window-margins nil margin-size margin-size)))
    
    (add-hook 'window-configuration-change-hook #'my-resize-margins)
    (my-resize-margins)
    

提交回复
热议问题