emacs zoom in/out globally

2019-03-14 15:36发布

I know that I can zoom in/out using C-x C-+, but this applies only to the current file. Once I open another one, the text goes back to the default value and it's really tiresome to do it over and over. How can I keep the zoom level global for the current emacs session?

I know it's possible to set this in the init file if you know the exact font size, which I don't. Plus, I don't want to keep it that permanent - I usually need this when I'm without an external screen for a couple of hours or connected to a beamer while giving a presentation.

5条回答
Root(大扎)
2楼-- · 2019-03-14 16:17

This piece of code modify the zoom in/out functionality to apply the commands to every buffer. That should achieve what you are trying to do.

(defadvice text-scale-increase (around all-buffers (arg) activate)
  (dolist (buffer (buffer-list))
    (with-current-buffer buffer
      ad-do-it)))
查看更多
仙女界的扛把子
3楼-- · 2019-03-14 16:24

All of the answers given here, and more, are available on the EmacsWiki page dedicated to the question of setting and changing font size, including changing it incrementally.

The answer from @abo-abo is on the right track, regardless of whether you think the size he used in the example code was too big, and regardless of whether the solution does not address incremental adjustment.

The answer from @juanleon essentially makes text scaling simulate changing the default character size (@abo-abo's answer).

The point of text scaling is to scale the buffer text (one buffer, no matter where it is shown), not the frame text (all buffers shown in the frame). But if you want all buffers to have their text size changed in a given frame then there is no reason to bother with text scaling in that case: just change the font size.

You can do either or both (scale the buffer text everywhere or zoom a frame), and do so incrementally, using the same command, if you use command zoom-in/out from library zoom-frm.el.

On the other hand, if you really do want to incrementally change the text size of all buffers in all frames, then the best approaches are either (1) @juanleon's suggestion or (2) incrementally zoom the standard face default.

To do the latter, you can use commands zoom-all-frames-in and zoom-all-frames-out in library zoom-frm.el

查看更多
老娘就宠你
4楼-- · 2019-03-14 16:24

connected to a beamer while giving a presentation.

There is another package for that!

emacs-presentation-mode

Quoting from the site

  1. Execute ~M-x presentation-mode~ to start the presentation.
  2. Adjust scale size by ~C-x C-+~ or ~C-x C--~ See https://www.gnu.org/software/emacs/manual/html_node/emacs/Text-Scale.html
  3. After the presentation, execute ~M-x presentation-mode~ again.
  4. And then execute ~M-x presentation-mode~ again, the last scale will be reproduced.
  5. If you want to persistize its size as the default size of presentation-mode after restarting Emacs, set ~presentation-default-text-scale~.

It's also have description of differences from other similar modes/package.

查看更多
在下西门庆
5楼-- · 2019-03-14 16:27

Just paste this in *scratch* and evaluate (with C-j or C-x C-e):

(set-face-attribute 'default nil :height 150)

There's nothing wrong in putting this in the init file and commenting it out later, when you don't need it.

查看更多
Root(大扎)
6楼-- · 2019-03-14 16:38

Its possible to scale all text (including status-line & line-numbers) using a little mode that handles this exact problem: purcell/default-text-scale. It's available in Melpa.

This scales all text to avoid text scale mismatch such as line-numbers of fill-column indicator being offset incorrectly.

The other answers here either don't work for new buffers or require too much manual intervention.

查看更多
登录 后发表回答