Corrections to the normalization of :custom

This commit is contained in:
John Wiegley 2017-11-28 11:03:47 -08:00
parent 903ff82219
commit c72d8567d2

View file

@ -1411,23 +1411,20 @@ deferred until the prefix key sequence is pressed."
;;; :custom ;;; :custom
;; ;;
(defun use-package-normalize/:custom (name-symbol keyword arg) (defun use-package-normalize/:custom (name-symbol keyword args)
"Normalize use-package custom keyword." "Normalize use-package custom keyword."
(let ((error-msg (format "%s wants a (<symbol> <form> <optional string comment>) or list of these" name-symbol))) (cond
(unless (listp arg) ((and (= (length args) 1)
(use-package-error error-msg)) (listp (car args))
(dolist (def arg arg) (listp (car (car args))))
(unless (listp def) (car args))
(use-package-error error-msg)) ((and (= (length args) 1)
(let ((variable (nth 0 def)) (listp (car args)))
(value (nth 1 def)) args)
(comment (nth 2 def))) (t
(when (or (not variable) (use-package-error
(and (not value) (concat label " a (<symbol> <value> [comment])"
(not (eq value nil))) " or list of these")))))
(> (length def) 3)
(and comment (not (stringp comment))))
(use-package-error error-msg))))))
(defun use-package-handler/:custom (name keyword args rest state) (defun use-package-handler/:custom (name keyword args rest state)
"Generate use-package custom keyword code." "Generate use-package custom keyword code."
@ -1437,7 +1434,7 @@ deferred until the prefix key sequence is pressed."
(let ((variable (nth 0 def)) (let ((variable (nth 0 def))
(value (nth 1 def)) (value (nth 1 def))
(comment (nth 2 def))) (comment (nth 2 def)))
(unless comment (unless (and comment (stringp comment))
(setq comment (format "Customized with use-package %s" name))) (setq comment (format "Customized with use-package %s" name)))
`(customize-set-variable (quote ,variable) ,value ,comment))) `(customize-set-variable (quote ,variable) ,value ,comment)))
args) args)