diff options
| author | Michael Shields | 2025-04-19 12:58:26 -0700 |
|---|---|---|
| committer | Eli Zaretskii | 2025-04-27 10:48:55 +0300 |
| commit | ebcde0f90f67852d485a36941b0661cfd1b892eb (patch) | |
| tree | 15178cd179ded1f70cb42c2d429255939d7dbc51 /test | |
| parent | 0c55cd0e176cc73178e8f18d959d5a6f9bf632de (diff) | |
| download | emacs-ebcde0f90f67852d485a36941b0661cfd1b892eb.tar.gz emacs-ebcde0f90f67852d485a36941b0661cfd1b892eb.zip | |
Fix use-package :custom-face to set face-defface-spec (bug#77928)
By default, `face-set-spec' sets the override face spec, so face
attributes are combined with defaults rather than replacing them.
This was a behavior change that was an apparently unintended
consequence of commit 6b344a9.
Also set the `face-modified' property, which causes Customize to
flag the face as changed outside Customize.
* doc/misc/use-package.texi (Faces): Document the behavior.
* lisp/use-package/use-package-core.el (use-package-handler/:custom-face):
(use-package): Improve docstring to reflect implementation.
* test/lisp/use-package/use-package-tests.el
(use-package-test/:custom-face-1): (use-package-test/:custom-face-2):
(use-package-test/:custom-face-3): (use-package-test/:custom-face-4):
Add tests.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/use-package/use-package-tests.el | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/test/lisp/use-package/use-package-tests.el b/test/lisp/use-package/use-package-tests.el index 8554b37d5b8..b221c5de5c1 100644 --- a/test/lisp/use-package/use-package-tests.el +++ b/test/lisp/use-package/use-package-tests.el | |||
| @@ -1153,7 +1153,12 @@ | |||
| 1153 | (match-expansion | 1153 | (match-expansion |
| 1154 | (use-package foo :custom-face (foo ((t (:background "#e4edfc"))))) | 1154 | (use-package foo :custom-face (foo ((t (:background "#e4edfc"))))) |
| 1155 | `(progn | 1155 | `(progn |
| 1156 | (apply #'face-spec-set (backquote (foo ((t (:background "#e4edfc")))))) | 1156 | (progn |
| 1157 | (apply #'face-spec-set | ||
| 1158 | (append (backquote (foo ((t (:background "#e4edfc"))))) | ||
| 1159 | '(face-defface-spec)) | ||
| 1160 | ) | ||
| 1161 | (put 'foo 'face-modified t)) | ||
| 1157 | (require 'foo nil nil)))) | 1162 | (require 'foo nil nil)))) |
| 1158 | 1163 | ||
| 1159 | (ert-deftest use-package-test/:custom-face-2 () | 1164 | (ert-deftest use-package-test/:custom-face-2 () |
| @@ -1163,19 +1168,42 @@ | |||
| 1163 | (example-1-face ((t (:foreground "LightPink")))) | 1168 | (example-1-face ((t (:foreground "LightPink")))) |
| 1164 | (example-2-face ((t (:foreground "LightGreen"))))) | 1169 | (example-2-face ((t (:foreground "LightGreen"))))) |
| 1165 | `(progn | 1170 | `(progn |
| 1166 | (apply #'face-spec-set | 1171 | (progn |
| 1167 | (backquote (example-1-face ((t (:foreground "LightPink")))))) | 1172 | (apply #'face-spec-set |
| 1168 | (apply #'face-spec-set | 1173 | (append (backquote (example-1-face ((t (:foreground "LightPink"))))) |
| 1169 | (backquote (example-2-face ((t (:foreground "LightGreen")))))) | 1174 | '(face-defface-spec))) |
| 1175 | (put 'example-1-face 'face-modified t)) | ||
| 1176 | (progn | ||
| 1177 | (apply #'face-spec-set | ||
| 1178 | (append (backquote (example-2-face ((t (:foreground "LightGreen"))))) | ||
| 1179 | '(face-defface-spec))) | ||
| 1180 | (put 'example-2-face 'face-modified t)) | ||
| 1170 | (require 'example nil nil)))) | 1181 | (require 'example nil nil)))) |
| 1171 | 1182 | ||
| 1172 | (ert-deftest use-package-test/:custom-face-3 () | 1183 | (ert-deftest use-package-test/:custom-face-3 () |
| 1173 | (match-expansion | 1184 | (match-expansion |
| 1174 | (use-package foo :custom-face (foo ((t (:background "#e4edfc"))) face-defspec-spec)) | 1185 | (use-package foo :custom-face (foo ((t (:background "#e4edfc"))) face-defspec-spec)) |
| 1175 | `(progn | 1186 | `(progn |
| 1176 | (apply #'face-spec-set (backquote (foo ((t (:background "#e4edfc"))) face-defspec-spec))) | 1187 | (progn |
| 1188 | (apply #'face-spec-set | ||
| 1189 | (append (backquote (foo ((t (:background "#e4edfc"))) face-defspec-spec)) | ||
| 1190 | '(face-defface-spec))) | ||
| 1191 | (put 'foo 'face-modified t)) | ||
| 1177 | (require 'foo nil nil)))) | 1192 | (require 'foo nil nil)))) |
| 1178 | 1193 | ||
| 1194 | (ert-deftest use-package-test/:custom-face-4 () | ||
| 1195 | (defface use-package-test/base-face '((t (:background "green"))) "") | ||
| 1196 | (defface use-package-test/face '((t (:inherit use-package-test/base-face))) "") | ||
| 1197 | (use-package emacs | ||
| 1198 | :custom-face | ||
| 1199 | (use-package-test/face ((t (:foreground "blue"))))) | ||
| 1200 | (should (equal (face-foreground 'use-package-test/face nil t) | ||
| 1201 | "blue")) | ||
| 1202 | (should (equal (face-background 'use-package-test/face nil t) | ||
| 1203 | nil)) | ||
| 1204 | (should (equal (get 'use-package-test/face 'face-modified) | ||
| 1205 | t))) | ||
| 1206 | |||
| 1179 | (ert-deftest use-package-test/:init-1 () | 1207 | (ert-deftest use-package-test/:init-1 () |
| 1180 | (match-expansion | 1208 | (match-expansion |
| 1181 | (use-package foo :init (init)) | 1209 | (use-package foo :init (init)) |