Get font face under cursor in Emacs

后端 未结 5 651
Happy的楠姐
Happy的楠姐 2020-12-12 12:48

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.

Something like T

5条回答
  •  忘掉有多难
    2020-12-12 12:59

    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))))
    

    After that,

    M-x what-face
    

    will print the face found at the current point.

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

提交回复
热议问题