Noob here. In my .emacs.d/custom.el I have stuff like:

(defface delim-mismatch `((t (:foreground "red"))))

  '(show-paren-mismatch delim-mismatch)

But it throws "Wrong type argument: listp, delim-mismatch". I can't seem to find an example of using defface-defined faces in custom-set-faces by name.

  • 1
    Why define delim-mismatch? Why not do it directly like this: (custom-set-faces '(show-paren-mismatch ((t (:foreground "red")))))? Or even better, customize it interactively: M-x customize-face<RET>show-paren-mismatch<RET>. In particular, the default seems to be white foreground on purple background. If you just change the foreground to red, the paren becomes almost invisible: red on purple is not a good combination. If you do it interactively, you can experiment with the colors before saving the customization.
    – NickD
    Jul 22, 2022 at 22:12
  • This is an example. I apply the style to several targets. Also I'm using a different theme so the visibility is not an issue. Jul 22, 2022 at 22:15
  • I don't understand. (1) Your custom-file should be only for Customize to write to. Put your deffaces in your init file or some other file that you load from it. (2) Your defface definition is no good. See C-h f defface. (3) It's not clear (to me) what you're really trying to do.
    – Drew
    Jul 22, 2022 at 23:10
  • (3) How can I actually use a face defined by defface -- apply it to some other face (overwrite it?) Sorry, I can't find what type of object show-paren-mismatch is... (2) Hmm, it didn't give me an error. (3) Gotcha, thanks. Jul 22, 2022 at 23:19

1 Answer 1


As Drew pointed out, your defface definition is no good, but let’s ignore that for now.

One has to assign a face spec to a face, which delim-mismatch is not. There is, however, a way to construct a face spec that inherits from another face by using the :inherit face attribute. Alternatively, faces can be aliased.

This gives us three options:

;; use the `:inherit' face attribute
(defface delim-mismatch '((t :foreground "red"))
  "My custom delim mismatch face.")
 '(show-paren-mismatch ((t :inherit delim-mismatch))))
;; define the face spec instead of the face itself
(defvar delim-mismatch-face-spec '((t :foreground "red"))
  "My custom delim mismatch face spec.")
 `(show-paren-mismatch ,delim-mismatch-face-spec))
;; alias the faces
(defface delim-mismatch '((t :foreground "red"))
  "My custom delim mismatch face.")
(put 'show-paren-mismatch 'face-alias 'delim-mismatch)

The first option is the one that’s most commonly used as it’s the most flexible of the three.

  • Thank you! This perfectly answers my question. I had tried :inherit similar to how you have here, but one possible limitation is that: attributes already attached to the face must be explicitly overwritten/negated in the inherited face spec, whereas the other two approaches completely overwrite, which (in my case) is simpler. Jul 23, 2022 at 14:31

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.