]> git.eshelyaron.com Git - emacs.git/commitdiff
allow :mode and :interpreter to accept a string
authorAdam Spiers <emacs@adamspiers.org>
Mon, 16 Dec 2013 12:16:56 +0000 (12:16 +0000)
committerAdam Spiers <emacs@adamspiers.org>
Mon, 16 Dec 2013 13:57:32 +0000 (13:57 +0000)
Fixes https://github.com/jwiegley/use-package/issues/72.

lisp/use-package/use-package.el

index 2d75c549b21026e436d03c64f30b36dbe25d7842..a9ba4e5353fb9a032200ee7ea0b47925cc31b20f 100644 (file)
 ;;
 ;; Similar to `:bind', you can use `:mode' and `:interpreter' to establish a
 ;; deferred binding within `auto-mode-alist' and `interpreter-mode-alist'.
-;; The specifier to either keyword can be a single cons or a list:
+;; The specifier to either keyword can be a single cons, or a list, or just
+;; a string:
 ;;
-;;   (use-package python-mode
-;;     :mode ("\\.py$" . python-mode)
+;;   (use-package ruby-mode
+;;     :mode "\\.rb\\'"
+;;     :interpreter "ruby")
+;;
+;;   ;; The package is "python" but the mode is "python-mode":
+;;   (use-package python
+;;     :mode ("\\.py\\'" . python-mode)
 ;;     :interpreter ("python" . python-mode))
 ;;
 ;; If you aren't using `:commands', `:bind', `:mode', or `:interpreter' (all
@@ -421,8 +427,12 @@ For full documentation. please see commentary.
          (defines (plist-get-value args :defines))
          (idle-body (plist-get args :idle))
          (keybindings-alist (plist-get-value args :bind))
-         (mode-alist (plist-get-value args :mode))
-         (interpreter-alist (plist-get-value args :interpreter))
+         (mode (plist-get-value args :mode))
+         (mode-alist
+          (if (stringp mode) (cons mode name) mode))
+         (interpreter (plist-get-value args :interpreter))
+         (interpreter-alist
+          (if (stringp interpreter) (cons interpreter name) interpreter))
          (predicate (plist-get args :if))
          (pkg-load-path (plist-get-value args :load-path))
          (defines-eval (if (null defines)