我一直在开发自己的定制化颜色主题,如果能够获得一个列表,列出影响光标下文本的字体集将非常有用。
类似于Textmate的“显示当前范围”命令。
这将节省我通过执行M-x customize-face和查看可用选项并猜测哪个选项会影响我正在编辑的单词的时间。
有什么想法吗?
我一直在开发自己的定制化颜色主题,如果能够获得一个列表,列出影响光标下文本的字体集将非常有用。
类似于Textmate的“显示当前范围”命令。
这将节省我通过执行M-x customize-face和查看可用选项并猜测哪个选项会影响我正在编辑的单词的时间。
有什么想法吗?
what-cursor-position
带有前缀参数时,会显示光标下的 face 属性等相关信息。
键盘快捷键为 C-u C-x =
示例输出(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]
what-cursor-position
。 - viam0Zahemacs -nw file.txt
)中执行C-u C-x =
时,此类信息是不可用的。 - Fernando BassoM-x describe-face
return
键。例如,我的结果读取“描述face(默认为'org-block-background'):”。 - Mallory-Erik您可以使用以下代码定义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
未内置。)
hl-line-mode
,您将只看到“hl-line”作为面的hl-line
,而不是其他面。这忽略了被设置为文本属性的面。请参考https://gist.github.com/Wilfred/f7d61b7cdf9fdbb1d11c。 - Wilfred Hughes(pos)
替换为pos
。 - cebolaTrey的想法是正确的。他引导我看到了邮件列表中的一封电子邮件,内容如下:
(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' 函数存在一个 bug:它将 "pos" 作为参数传入,但在获取 face 时并没有使用它,而是使用了 "(point)",尽管后面的消息在 "No face at %d" 情况下声称使用了 pos。
我尝试了@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)
是一个函数,它将 point 的值作为整数返回。pos
获取由 (interactive "d")
返回的值,这个值将是 point 的位置,作为一个整数。get-char-property
需要一个位置,在这种情况下由函数 (point)
给出。(face-at-point t)
这就是M-x describe-face
使用的内容。