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?

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)
1
  • There was another question in the same spirit but with different details. Might you be able to answer it?
    – NickD
    Aug 15 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.