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.")
(custom-set-faces
'(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.")
(custom-set-faces
`(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.
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.custom-file
should be only for Customize to write to. Put yourdefface
s in your init file or some other file that you load from it. (2) Yourdefface
definition is no good. SeeC-h f defface
. (3) It's not clear (to me) what you're really trying to do.defface
-- apply it to some other face (overwrite it?) Sorry, I can't find what type of objectshow-paren-mismatch
is... (2) Hmm, it didn't give me an error. (3) Gotcha, thanks.