]> git.eshelyaron.com Git - emacs.git/commitdiff
Validate keywords. Error if any keyword is unrecognized
authorPhil Hudson <phil.hudson@iname.com>
Fri, 14 Jun 2013 09:53:49 +0000 (10:53 +0100)
committerJohn Wiegley <johnw@newartisans.com>
Wed, 3 Jul 2013 17:56:48 +0000 (12:56 -0500)
Conflicts:
use-package.el

lisp/use-package/use-package.el

index 5b5d0995913e6c050e6ec331d7534b330c5f8bfa..20344799b8a4cce9af28d3eb64715deee94d7fb6 100644 (file)
   (when (not (package-installed-p package))
     (package-install package)))
 
+(defvar use-package-keywords
+  '(
+     :bind
+     :commands
+     :config
+     :defer
+     :defines
+     :diminish
+     :disabled
+     :ensure
+     :idle
+     :if
+     :init
+     :interpreter
+     :load-path
+     :mode
+     :pre-init
+     :requires
+  )
+  "Keywords recognized by `use-package'.")
+
+(defun plist-keys (plist)
+  "Return a list containing all the keys in PLIST."
+  (when plist
+    (cons
+      (car plist)
+      (plist-keys
+        (cddr plist)))))
+
+(defun use-package-validate-keywords (args)
+  "Error if any keyword given in ARGS is not recognized.
+Return the list of recognized keywords."
+  (mapc
+    (function
+      (lambda (keyword)
+        (unless (memq keyword use-package-keywords)
+          (error "Unrecognized keyword: %s" keyword))))
+    (plist-keys args)))
 
 (defmacro use-package (name &rest args)
 "Use a package with configuration options.
@@ -424,6 +462,7 @@ For full documentation. please see commentary.
 :diminish Support for diminish package (if it's installed).
 :idle adds a form to run on an idle timer
 :ensure loads package using package.el if necessary."
+  (use-package-validate-keywords args) ; error if any bad keyword, ignore result
   (let* ((commands (plist-get args :commands))
          (pre-init-body (plist-get args :pre-init))
          (init-body (plist-get args :init))