3

A string may hold a nil or default face text property, or its face text property is simply unspecified. E.g.,

#("void nil default"
  0 4   ; unspecified
  ()            
  5 8   ; nil face (this is an anonymous face, see the manual)
  (face ())
  9 16  ; default face
  (face default))

Although they are usually rendered to look the same, I wonder whether there is an exception?

13
  • They are not eq but they are string=? The first does not specify any properties, but the other two do? Not sure what you are looking for.
    – NickD
    Apr 29, 2023 at 14:18
  • What are you asking? Are you asking what face attributes a face should have so that it appears to have no effect, i.e., text with that face appears like text with face default? And only as shown by function message? What are you really trying to do? At best, this sounds like an X-Y problem. You should be able to pare it down to something you really want/need to know.
    – Drew
    Apr 29, 2023 at 21:42
  • You don't define what you mean by "act like". Clearly, the 3 (1-char) strings you show at the outset are different ("s", #("s" 0 1 (face nil)), #("s" 0 1 (face default))), so clearly they don't "act" the same in all contexts. So far, the question seems completely undefined, to me.
    – Drew
    Apr 30, 2023 at 0:52
  • To me it's unclear, as I said. To others it might be clear. You want to make two (or three) strings "act" the same, but you don't say what acting the same means for you. To me, this looks like an X-Y question: you don't say what you're trying to do or to understand; you instead try to ask about what you think might solve your real question/problem. But the something you try to ask is itself unclear: "Act like" isn't defined. Say what you want to do with the string: in what way you want the different strings to be/act the same.
    – Drew
    Apr 30, 2023 at 16:19
  • You struggle with whether nil or face default is better. Better for what? Better in what way? You don't say what you want, so it's hard/impossible to help you choose which choice is "better" (for you, in some way).
    – Drew
    Apr 30, 2023 at 19:08

1 Answer 1

1
nil and default always look the same.

(info "(emacs) Face Customization"):

A face does not have to specify every single attribute; ... . Any unspecified attribute is taken from the special face named default, whose attributes are all specified.

Since nil face (i.e., an anonymous face which is ()) doesn't specify any attribute, all its attributes will fall back to default.

Void face sometimes looks different.

(info "(elisp) Displaying Faces"):

Here is the order in which Emacs merges the faces, from highest to lowest priority:

  • ...
  • If the text contains a face or mouse-face property, Emacs applies the specified faces and face attributes.
  • If the text lies within the mode line of the selected window, Emacs applies the mode-line face. ...
  • If the text comes from an overlay string via before-string or after-string properties, ...
  • If any given attribute has not been specified during the preceding steps, Emacs applies the attribute of the default face.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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