1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 22:41:06 -08:00

Warn about bad face specs in defface at compile time

* lisp/emacs-lisp/bytecomp.el (byte-compile--custom-declare-face):
Byte-compile `defface` forms, or the byte-compile handler won't
be called.
(bytecomp--check-cus-face-spec): New.
(bytecomp--custom-declare): Call it.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-test-defface-spec):
New tests.
This commit is contained in:
Mattias Engdegård 2024-09-27 11:48:14 +02:00
parent 09d63ba32b
commit bba14a2767
2 changed files with 84 additions and 1 deletions

View file

@ -1985,6 +1985,32 @@ EXPECTED-POINT BINDINGS (MODES \\='\\='(ruby-mode js-mode python-mode)) \
(dc 'integerp))
))
(ert-deftest bytecomp-test-defface-spec ()
(cl-flet ((df (spec) `(defface mytest ',spec "doc" :group 'test)))
(bytecomp--with-warning-test
(rx "Bad face display condition `max-colors'")
(df '((((class color grayscale) (max-colors 75) (background light))
:foreground "cyan"))))
(bytecomp--with-warning-test
(rx "Bad face display `defualt'")
(df '((defualt :foreground "cyan"))))
(bytecomp--with-warning-test
(rx "`:inverse' is not a valid face attribute keyword")
(df '((t :background "blue" :inverse t))))
(bytecomp--with-warning-test
(rx "`:inverse' is not a valid face attribute keyword")
(df '((t (:background "blue" :inverse t))))) ; old attr list syntax
(bytecomp--with-warning-test
(rx "Value for face attribute `:inherit' should not be quoted")
(df '((t :inherit 'other))))
(bytecomp--with-warning-test
(rx "Missing face attribute `:extend' value")
(df '((t :foundry "abc" :extend))))
(bytecomp--with-warning-test
(rx "Non-keyword in face attribute list: `\"green\"'")
(df '((t :foreground "white" "green"))))
))
(ert-deftest bytecomp-function-attributes ()
;; Check that `byte-compile' keeps the declarations, interactive spec and
;; doc string of the function (bug#55830).