我一直在开发自己的自定义颜色主题,如果我可以获得影响光标下文本的字体列表,那将非常有用。
类似于 Textmate 的 show current scope 命令。
这样可以省去我做 Mx customize-face 和查看可用选项的麻烦,猜测哪个会影响我正在使用的当前单词。
有任何想法吗?
我一直在开发自己的自定义颜色主题,如果我可以获得影响光标下文本的字体列表,那将非常有用。
类似于 Textmate 的 show current scope 命令。
这样可以省去我做 Mx customize-face 和查看可用选项的麻烦,猜测哪个会影响我正在使用的当前单词。
有任何想法吗?
what-cursor-position
带有前缀参数的显示点下的面,以及其他信息。
键盘快捷键是Cu Cx =
示例输出(最后一段中显示了 face 属性):
position: 5356 of 25376 (21%), column: 4
character: r (displayed as r) (codepoint 114, #o162, #x72)
preferred charset: ascii (ASCII (ISO646 IRV))
code point in charset: 0x72
syntax: w which means: word
category: .:Base, L:Left-to-right (strong), a:ASCII, l:Latin, r:Roman
buffer code: #x72
file code: #x72 (encoded by coding system undecided-unix)
display: by this font (glyph code)
nil:-apple-Monaco-medium-normal-normal-*-12-*-*-*-m-0-iso10646-1 (#x55)
Character code properties: customize what to show
name: LATIN SMALL LETTER R
general-category: Ll (Letter, Lowercase)
decomposition: (114) ('r')
There are text properties here:
face org-level-2
fontified t
[back]
M-x describe-face
您可以what-face
使用以下代码定义:
(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
将打印在当前点找到的人脸。
(感谢thedz指出它what-face
不是内置的。)
Trey 的面子在正确的轨道上。它把我带到了一个邮件列表上的一封电子邮件,里面有这样的内容:
(defun what-face (pos)
(interactive "d")
(let ((face (or (get-char-property (point) 'read-face-name)
(get-char-property (point) 'face))))
(if face (message "Face: %s" face) (message "No face at %d" pos))))
`what-face' 代码中有一个错误:该函数将“pos”作为参数,但在获取人脸时不使用它——而是使用“(point)”,即使消息后来声称pos在“%d 没有脸”的情况下。
我尝试了@tray功能,但它不起作用,@thedz定义确实有效:
(defun what-face (pos)
(interactive "d")
(let ((face (or (get-char-property (point) 'read-face-name)
(get-char-property (point) 'face))))
(if face (message "Face: %s" face) (message "No face at %d" pos))))
经过一番研究,我发现了原因:
(point)
是一个将点的值作为整数返回的函数。pos
(interactive "d")
以整数形式获取将作为点位置的返回值。get-char-property
期望一个位置,在这种情况下由函数给出(point)
。