在 Emacs 中获取光标下的字体 [英] Get font face under cursor in Emacs

查看:25
本文介绍了在 Emacs 中获取光标下的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在开发自己的自定义颜色主题,如果我能获得影响光标下文本的字体列表,那将会非常有用.

I've been developing my own custom color theme, and it'd be really useful if I could get a list of font-faces affecting the text under the cursor.

类似于 Textmate 的 show current scope 命令.

Something like Textmate's show current scope command.

这将省去我进行 M-x 自定义面部和查看可用选项的麻烦,猜测哪个会影响我当前使用的单词.

That would save me the trouble of doing M-x customize-face and looking through available options, guessing at which one affects the current word I'm on.

有什么想法吗?

推荐答案

您可以使用以下代码定义what-face:

You can define what-face with this code:

(defun what-face (pos)
  (interactive "d")
  (let ((face (or (get-char-property (pos) 'read-face-name)
                  (get-char-property (pos) 'face))))
    (if face (message "Face: %s" face) (message "No face at %d" pos))))

在那之后,

M-x what-face

将打印在当前点找到的人脸.

will print the face found at the current point.

(感谢 thedz 指出 what-face 不是内置的.)

(Thanks to thedz for pointing out that what-face wasn’t built in.)

这篇关于在 Emacs 中获取光标下的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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