How to determine what face is associated with a bit of text?

jeff-xemacs at delphioutpost.com jeff-xemacs at delphioutpost.com
Mon Apr 7 09:49:57 EDT 2008


   From: skip at pobox.com
   Date: Mon, 7 Apr 2008 08:40:54 -0500
   
   I'm having trouble figuring out what face is used to render a particular bit
   of text.  See the attached PNG.  I'm particularly interested in the
   hard-to-read green text.  (This was clipped from an ipython comint buffer.)
   Given a random bit of text is there some way to determine the face used to
   render it?
   
   Thanks,

You can do M-x list-faces-display (or edit-faces), which lists all of
the defined faces.

Or you can use this:

  (global-set-key [(control button3)] 'describe-face-at-mouse-point)

  (defun describe-face-at-mouse-point (event)
    (interactive "*e")
    (let ((point (save-excursion
                   (save-window-excursion
                     (mouse-set-point event)
                     (point)))))
      (describe-face-at-point point)))

  (defun describe-face-at-point (&optional point)
    "Return face used at point."
    (interactive)
    (let ((face (get-char-property (or point (point)) 'face)))
      (if (listp face)
          (progn
            (message (format "Full value: %s" (prin1-to-string face)))
            (setq face (car face))))
      (hyper-describe-face face)))

-jeff



More information about the XEmacs-Beta mailing list