为每个缓冲区/模式设置 Emacs 默认字体 [英] Set Emacs defaut font face per-buffer/mode

查看:38
本文介绍了为每个缓冲区/模式设置 Emacs 默认字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改 Emacs 用于基于每种模式设置文本样式的默认字体?

例如,假设我已经对我拥有的面部自定义感到满意,其中包括默认的固定宽度字体.但是,在一种特定模式下(例如,markdown-mode.el),我希望默认字体为可变宽度.

很容易为markdown-mode设置独特的标题、链接等样式:只需将光标放在样式文本和Mx describe-face上,然后单击链接进行自定义.

但是,默认的人脸是在没有指定其他人脸的情况下使用的人脸,所以它不是特定于markdown-mode的,如果修改会影响所有其他模式.

我可以在 markdown-mode-hook 中使用什么魔法来设置使用此模式的缓冲区的默认面?

解决方案

这样的事情怎么样:

(add-hook 'markdown-mode-hook (lambda() (variable-pitch-mode t))

然后您可以自定义variable-pitch面,缓冲区中的其他面将继承自此而不是默认面.

阅读 buffer-face-mode 的文档以了解更多自定义细节.(BufFace 也用于text-scale-increasetext-scale-decrease...非常有用.)

How do you change the default face which Emacs uses to style text on a per-mode basis?

For example, say that I am already happy with the face customizations that I have, which include a default fixed-width font. However, in one particular mode (markdown-mode.el, say), I want the default font to be variable-width.

It is easy to style headers, links etc. uniquely for markdown-mode: simply place the cursor over the styled text and M-x describe-face, then click the link to customize it.

However, the default face is the face used if no other face is specified, so it is not specific to markdown-mode and if modified will affect all other modes.

What magic can I put in the markdown-mode-hook to set the default face for buffers using this mode?

解决方案

How about something like this:

(add-hook 'markdown-mode-hook (lambda () (variable-pitch-mode t))

You can then customize the variable-pitch face, and the other faces in the buffer will inherit from this instead of the default face.

Read the docs for buffer-face-mode for more customization details. (BufFace is also used for text-scale-increase and text-scale-decrease... very useful.)

这篇关于为每个缓冲区/模式设置 Emacs 默认字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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