Fix cloning 'face-remapping-alist' for indirect buffers

* lisp/face-remap.el (face-remap--copy-face): Remove.
(face-attrs--make-indirect-safe): Use 'copy-tree'.  Suggested by
Stefan Monnier <monnier@iro.umontreal.ca>.
This commit is contained in:
Eli Zaretskii 2023-08-17 10:51:36 +03:00
parent 636fb267c4
commit d9af79ae39

View file

@ -70,21 +70,10 @@
:foreground :background :stipple :overline :strike-through :box :foreground :background :stipple :overline :strike-through :box
:font :inherit :fontset :distant-foreground :extend :vector]) :font :inherit :fontset :distant-foreground :extend :vector])
(defun face-remap--copy-face (val)
"Return a copy of the `face' property value VAL."
;; A `face' property can be either a face name (a symbol), or a face
;; property list like (:foreground "red" :inherit default),
;; or a list of such things.
;; FIXME: This should probably be shared to some extent with
;; `add-face-text-property'.
(if (or (not (listp val)) (keywordp (car val)))
val
(copy-sequence val)))
(defun face-attrs--make-indirect-safe () (defun face-attrs--make-indirect-safe ()
"Deep-copy the buffer's `face-remapping-alist' upon cloning the buffer." "Deep-copy the buffer's `face-remapping-alist' upon cloning the buffer."
(setq-local face-remapping-alist (setq-local face-remapping-alist
(mapcar #'face-remap--copy-face face-remapping-alist))) (mapcar #'copy-tree face-remapping-alist)))
(add-hook 'clone-indirect-buffer-hook #'face-attrs--make-indirect-safe) (add-hook 'clone-indirect-buffer-hook #'face-attrs--make-indirect-safe)