mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
Clean up defcustom type quote check
* lisp/emacs-lisp/bytecomp.el (byte-compile--suspicious-defcustom-choice): Rename to... (byte-compile--defcustom-type-quoted): ...this and rewrite to make more sense. All callers updated. (byte-compile-nogroup-warn): Better warning message. * test/lisp/emacs-lisp/bytecomp-tests.el (test-bytecomp-defgroup-choice): This never failed because it wasn't actually a test. Turn it into... (bytecomp-test-defcustom-type-quoted): ...this, which is.
This commit is contained in:
parent
f8a79c0055
commit
08291e6f17
2 changed files with 18 additions and 19 deletions
|
|
@ -1619,21 +1619,20 @@ extra args."
|
|||
(dolist (elt '(format message format-message error))
|
||||
(put elt 'byte-compile-format-like t))
|
||||
|
||||
(defun byte-compile--suspicious-defcustom-choice (type)
|
||||
"Say whether defcustom TYPE looks odd."
|
||||
;; Check whether there's anything like (choice (const :tag "foo" ;; 'bar)).
|
||||
(defun byte-compile--defcustom-type-quoted (type)
|
||||
"Whether defcustom TYPE contains an accidentally quoted value."
|
||||
;; Detect mistakes such as (const 'abc).
|
||||
;; We don't actually follow the syntax for defcustom types, but this
|
||||
;; should be good enough.
|
||||
(catch 'found
|
||||
(if (and (consp type)
|
||||
(proper-list-p type))
|
||||
(if (memq (car type) '(const other))
|
||||
(when (assq 'quote type)
|
||||
(throw 'found t))
|
||||
(when (memq t (mapcar #'byte-compile--suspicious-defcustom-choice
|
||||
type))
|
||||
(throw 'found t)))
|
||||
nil)))
|
||||
(and (consp type)
|
||||
(proper-list-p type)
|
||||
(if (memq (car type) '(const other))
|
||||
(assq 'quote type)
|
||||
(let ((elts (cdr type)))
|
||||
(while (and elts (not (byte-compile--defcustom-type-quoted
|
||||
(car elts))))
|
||||
(setq elts (cdr elts)))
|
||||
elts))))
|
||||
|
||||
;; Warn if a custom definition fails to specify :group, or :type.
|
||||
(defun byte-compile-nogroup-warn (form)
|
||||
|
|
@ -1647,10 +1646,10 @@ extra args."
|
|||
(byte-compile-warn-x (cadr name)
|
||||
"defcustom for `%s' fails to specify type"
|
||||
(cadr name)))
|
||||
((byte-compile--suspicious-defcustom-choice type)
|
||||
((byte-compile--defcustom-type-quoted type)
|
||||
(byte-compile-warn-x
|
||||
(cadr name)
|
||||
"defcustom for `%s' has syntactically odd type `%s'"
|
||||
"defcustom for `%s' may have accidentally quoted value in type `%s'"
|
||||
(cadr name) type)))))
|
||||
(if (and (memq (car form) '(custom-declare-face custom-declare-variable))
|
||||
byte-compile-current-group)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue