Skip to main content
3 of 3
added 221 characters in body
Tobias
  • 33.7k
  • 1
  • 38
  • 78

I think you cannot really delete the faces from the internal face table of the current frame. Maybe I am mistaken in that point because I did not carefully inspect the c-source code. So I would very much appreciate acknowledgement of somebody who knows the Emacs internals better.

Gilles is right in his answer that you can change the default faces for newly created frames.

I did a little experiment in the scratch buffer. The results are given as comments.

(defface myface '((t :inverse-video t))
  "Doc" :group 'test)
;; => myface

(insert (propertize "test" 'font-lock-face 'myface))
;; => inverted "test" inserted into the buffer

(get 'myface 'face)
;; => 773

(setq face-new-frame-defaults (cl-delete-if (lambda (face) (string-equal (car face) "myface")) face-new-frame-defaults))
;; => new list of faces

(get 'myface 'face)
;; => 773

(unintern 'myface)
;; t

(defface myface '((t :inverse-video t))
  "Doc" :group 'test)
;; => myface

(insert (propertize "test" 'font-lock-face 'myface))
;; => inverted "test" inserted into the buffer

(get 'myface 'face)
;; => 774

As one sees. After the first (get 'myface 'face) one gets 773 and after the second -- inspit of the attempts to delete the face -- one gets 774.

Another experiment: The following sequence of instruction gives you a new frame with only shades of gray. The old frame remains colorful. Also new input in the old frame lets font-lock colorize the text as before in the old frame. On the other hand the new frame spies error messages about missing fonts into the message buffer.

(setq old-faces face-new-frame-defaults)
(setq face-new-frame-defaults nil)
(new-frame)

Note, also the list returned by (frame-face-alist) is a list newly created from the internal face table. So destructively deleting an entry from that list does also not delete the entry from the internal face table.

Tobias
  • 33.7k
  • 1
  • 38
  • 78