1

When I want to find out a character's face, I usually move point to it, and run M-x describe-face.

This approach requires being able to move point to the character of interest, which is not always possible.

(For example, I don't know how to move point so that it sits on a character right on the mode-line; therefore, the anything on the mode-line is off-limits to the technique described above.)

Is there a more general way to determine conclusively a character's face, irrespective of where it is?

kjo
  • 3,145
  • 14
  • 42

1 Answers1

2

There’s no universal method (though perhaps there ought to be, perhaps based on the mouse cursor rather than moving point), but you can definitely find out for the mode line. Just run (format-mode-line mode-line-format t) in the scratch buffer. The result will be a big string with text properties that tell Emacs which font(s) to use, which parts are buttons, any images that need to be displayed in it, etc.

This will get you the mode line for the scratch buffer, of course, so if you want the mode line for a specific buffer you need to specify it as the fourth argument. For example:

(format-mode-line mode-line-format
                  t
                  nil
                  (get-buffer "main.rs"))

Since header lines use the same format as the mode line, you can also call it with header-line-format, although for most buffers that will just be an empty string.

(format-mode-line header-line-format t)
db48x
  • 15,741
  • 1
  • 19
  • 23
  • There was [another question](https://emacs.stackexchange.com/questions/68053/how-can-i-identify-this-popup-face) in the same spirit but with different details. Might you be able to answer it? – NickD Aug 15 '21 at 13:18