summaryrefslogtreecommitdiff
path: root/lisp/use-package
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/use-package')
-rw-r--r--lisp/use-package/bind-chord.el83
-rw-r--r--lisp/use-package/bind-key.el149
-rw-r--r--lisp/use-package/use-package-bind-key.el7
-rw-r--r--lisp/use-package/use-package-chords.el6
-rw-r--r--lisp/use-package/use-package-core.el158
-rw-r--r--lisp/use-package/use-package-ensure-system-package.el13
-rw-r--r--lisp/use-package/use-package-ensure.el2
-rw-r--r--lisp/use-package/use-package.el2
8 files changed, 330 insertions, 90 deletions
diff --git a/lisp/use-package/bind-chord.el b/lisp/use-package/bind-chord.el
index e5184bff60e..ff19c81fc78 100644
--- a/lisp/use-package/bind-chord.el
+++ b/lisp/use-package/bind-chord.el
@@ -1,11 +1,11 @@
-;;; bind-chord.el --- key-chord binding helper for use-package-chords
+;;; bind-chord.el --- key-chord binding helper for use-package-chords -*- lexical-binding: t; -*-
-;; Copyright (C) 2015-2017 Justin Talbott
+;; Copyright (C) 2015-2019 Justin Talbott
;; Author: Justin Talbott <justin@waymondo.com>
;; Keywords: convenience, tools, extensions
-;; URL: https://github.com/waymondo/use-package-chords
-;; Version: 0.2
+;; URL: https://github.com/jwiegley/use-package
+;; Version: 0.2.1
;; Package-Requires: ((bind-key "1.0") (key-chord "0.6"))
;; Filename: bind-chord.el
;; License: GNU General Public License version 3, or (at your option) any later version
@@ -30,6 +30,63 @@
(bind-key (vector 'key-chord ,key1 ,key2) ,command ,keymap)
(bind-key (vector 'key-chord ,key2 ,key1) ,command ,keymap)))))
+(defun bind-chords-form (args keymap)
+ "Bind multiple chords at once.
+
+Accepts keyword arguments:
+:map MAP - a keymap into which the keybindings should be
+ added
+
+The rest of the arguments are conses of keybinding string and a
+function symbol (unquoted)."
+ (let (map pkg)
+ (let ((cont t))
+ (while (and cont args)
+ (if (cond ((eq :map (car args))
+ (setq map (cadr args)))
+ ((eq :package (car args))
+ (setq pkg (cadr args))))
+ (setq args (cddr args))
+ (setq cont nil))))
+
+ (unless map (setq map keymap))
+
+ (let (first next)
+ (while args
+ (if (keywordp (car args))
+ (progn
+ (setq next args)
+ (setq args nil))
+ (if first
+ (nconc first (list (car args)))
+ (setq first (list (car args))))
+ (setq args (cdr args))))
+
+ (cl-flet
+ ((wrap (map bindings)
+ (if (and map pkg (not (memq map '(global-map
+ override-global-map))))
+ `((if (boundp ',map)
+ ,(macroexp-progn bindings)
+ (eval-after-load
+ ,(if (symbolp pkg) `',pkg pkg)
+ ',(macroexp-progn bindings))))
+ bindings)))
+
+ (append
+ (wrap map
+ (cl-mapcan
+ (lambda (form)
+ (let ((fun (and (cdr form) (list 'function (cdr form)))))
+ (if (and map (not (eq map 'global-map)))
+ `((bind-chord ,(car form) ,fun ,map))
+ `((bind-chord ,(car form) ,fun nil)))))
+ first))
+ (when next
+ (bind-chords-form (if pkg
+ (cons :package (cons pkg next))
+ next) map)))))))
+
;;;###autoload
(defmacro bind-chords (&rest args)
"Bind multiple chords at once.
@@ -39,23 +96,7 @@ Accepts keyword argument:
The rest of the arguments are conses of keybinding string and a
function symbol (unquoted)."
- (let* ((map (plist-get args :map))
- (maps (if (listp map) map (list map)))
- (key-bindings (progn
- (while (keywordp (car args))
- (pop args)
- (pop args))
- args)))
- (macroexp-progn
- (apply
- #'nconc
- (mapcar (lambda (form)
- (if maps
- (mapcar
- #'(lambda (m)
- `(bind-chord ,(car form) ',(cdr form) ,m)) maps)
- `((bind-chord ,(car form) ',(cdr form)))))
- key-bindings)))))
+ (macroexp-progn (bind-chords-form args nil)))
(provide 'bind-chord)
diff --git a/lisp/use-package/bind-key.el b/lisp/use-package/bind-key.el
index fef23740c67..1f775711ef3 100644
--- a/lisp/use-package/bind-key.el
+++ b/lisp/use-package/bind-key.el
@@ -1,4 +1,4 @@
-;;; bind-key.el --- A simple way to manage personal keybindings
+;;; bind-key.el --- A simple way to manage personal keybindings -*- lexical-binding: t; -*-
;; Copyright (c) 2012-2017 John Wiegley
@@ -131,7 +131,8 @@
(define-minor-mode override-global-mode
"A minor mode so that keymap settings override other modes."
- t "")
+ :init-value t
+ :lighter "")
;; the keymaps in `emulation-mode-map-alists' take precedence over
;; `minor-mode-map-alist'
@@ -159,7 +160,7 @@ For example:
(bind-key \"M-h\" #'some-interactive-function my-mode-map)
- (bind-key \"M-h\" #'some-interactive-function 'my-mode-map)
+ (bind-key \"M-h\" #'some-interactive-function \\='my-mode-map)
If PREDICATE is non-nil, it is a form evaluated to determine when
a key should be bound. It must return non-nil in such cases.
@@ -168,16 +169,20 @@ or operates on menu data structures, so you should write it so it
can safely be called at any time."
(let ((namevar (make-symbol "name"))
(keyvar (make-symbol "key"))
+ (kmapvar (make-symbol "kmap"))
(kdescvar (make-symbol "kdesc"))
(bindingvar (make-symbol "binding")))
`(let* ((,namevar ,key-name)
- (,keyvar (if (vectorp ,namevar) ,namevar
- (read-kbd-macro ,namevar)))
- (kmap (if (and ,keymap (symbolp ,keymap)) (symbol-value ,keymap) ,keymap))
+ (,keyvar ,(if (stringp key-name) (read-kbd-macro key-name)
+ `(if (vectorp ,namevar) ,namevar
+ (read-kbd-macro ,namevar))))
+ (,kmapvar (or (if (and ,keymap (symbolp ,keymap))
+ (symbol-value ,keymap) ,keymap)
+ global-map))
(,kdescvar (cons (if (stringp ,namevar) ,namevar
(key-description ,namevar))
(if (symbolp ,keymap) ,keymap (quote ,keymap))))
- (,bindingvar (lookup-key (or kmap global-map) ,keyvar)))
+ (,bindingvar (lookup-key ,kmapvar ,keyvar)))
(let ((entry (assoc ,kdescvar personal-keybindings))
(details (list ,command
(unless (numberp ,bindingvar)
@@ -186,27 +191,57 @@ can safely be called at any time."
(setcdr entry details)
(add-to-list 'personal-keybindings (cons ,kdescvar details))))
,(if predicate
- `(define-key (or kmap global-map) ,keyvar
+ `(define-key ,kmapvar ,keyvar
'(menu-item "" nil :filter (lambda (&optional _)
(when ,predicate
,command))))
- `(define-key (or kmap global-map) ,keyvar ,command)))))
+ `(define-key ,kmapvar ,keyvar ,command)))))
;;;###autoload
(defmacro unbind-key (key-name &optional keymap)
"Unbind the given KEY-NAME, within the KEYMAP (if specified).
See `bind-key' for more details."
- `(progn
- (bind-key ,key-name nil ,keymap)
- (setq personal-keybindings
- (cl-delete-if #'(lambda (k)
- ,(if keymap
- `(and (consp (car k))
- (string= (caar k) ,key-name)
- (eq (cdar k) ',keymap))
- `(and (stringp (car k))
- (string= (car k) ,key-name))))
- personal-keybindings))))
+ (let ((namevar (make-symbol "name"))
+ (kdescvar (make-symbol "kdesc")))
+ `(let* ((,namevar ,key-name)
+ (,kdescvar (cons (if (stringp ,namevar) ,namevar
+ (key-description ,namevar))
+ (if (symbolp ,keymap) ,keymap (quote ,keymap)))))
+ (bind-key--remove (if (vectorp ,namevar) ,namevar
+ (read-kbd-macro ,namevar))
+ (or (if (and ,keymap (symbolp ,keymap))
+ (symbol-value ,keymap) ,keymap)
+ global-map))
+ (setq personal-keybindings
+ (cl-delete-if (lambda (k) (equal (car k) ,kdescvar))
+ personal-keybindings))
+ nil)))
+
+(defun bind-key--remove (key keymap)
+ "Remove KEY from KEYMAP.
+
+In contrast to `define-key', this function removes the binding from the keymap."
+ (define-key keymap key nil)
+ ;; Split M-key in ESC key
+ (setq key (mapcan (lambda (k)
+ (if (and (integerp k) (/= (logand k ?\M-\0) 0))
+ (list ?\e (logxor k ?\M-\0))
+ (list k)))
+ key))
+ ;; Delete single keys directly
+ (if (= (length key) 1)
+ (delete key keymap)
+ ;; Lookup submap and delete key from there
+ (let* ((prefix (vconcat (butlast key)))
+ (submap (lookup-key keymap prefix)))
+ (unless (keymapp submap)
+ (error "Not a keymap for %s" key))
+ (when (symbolp submap)
+ (setq submap (symbol-function submap)))
+ (delete (last key) submap)
+ ;; Delete submap if it is empty
+ (when (= 1 (length submap))
+ (bind-key--remove prefix keymap)))))
;;;###autoload
(defmacro bind-key* (key-name command &optional predicate)
@@ -224,30 +259,60 @@ Accepts keyword arguments:
for these bindings
:prefix-docstring STR - docstring for the prefix-map variable
:menu-name NAME - optional menu string for prefix map
+:repeat-docstring STR - docstring for the repeat-map variable
+:repeat-map MAP - name of the repeat map that should be created
+ for these bindings. If specified, the
+ `repeat-map' property of each command bound
+ (within the scope of the `:repeat-map' keyword)
+ is set to this map.
+:exit BINDINGS - Within the scope of `:repeat-map' will bind the
+ key in the repeat map, but will not set the
+ `repeat-map' property of the bound command.
+:continue BINDINGS - Within the scope of `:repeat-map' forces the
+ same behaviour as if no special keyword had
+ been used (that is, the command is bound, and
+ it's `repeat-map' property set)
:filter FORM - optional form to determine when bindings apply
The rest of the arguments are conses of keybinding string and a
function symbol (unquoted)."
(let (map
- doc
+ prefix-doc
prefix-map
prefix
+ repeat-map
+ repeat-doc
+ repeat-type ;; Only used internally
filter
menu-name
pkg)
;; Process any initial keyword arguments
- (let ((cont t))
+ (let ((cont t)
+ (arg-change-func 'cddr))
(while (and cont args)
(if (cond ((and (eq :map (car args))
(not prefix-map))
(setq map (cadr args)))
((eq :prefix-docstring (car args))
- (setq doc (cadr args)))
+ (setq prefix-doc (cadr args)))
((and (eq :prefix-map (car args))
(not (memq map '(global-map
override-global-map))))
(setq prefix-map (cadr args)))
+ ((eq :repeat-docstring (car args))
+ (setq repeat-doc (cadr args)))
+ ((and (eq :repeat-map (car args))
+ (not (memq map '(global-map
+ override-global-map))))
+ (setq repeat-map (cadr args))
+ (setq map repeat-map))
+ ((eq :continue (car args))
+ (setq repeat-type :continue
+ arg-change-func 'cdr))
+ ((eq :exit (car args))
+ (setq repeat-type :exit
+ arg-change-func 'cdr))
((eq :prefix (car args))
(setq prefix (cadr args)))
((eq :filter (car args))
@@ -256,13 +321,17 @@ function symbol (unquoted)."
(setq menu-name (cadr args)))
((eq :package (car args))
(setq pkg (cadr args))))
- (setq args (cddr args))
+ (setq args (funcall arg-change-func args))
(setq cont nil))))
(when (or (and prefix-map (not prefix))
(and prefix (not prefix-map)))
(error "Both :prefix-map and :prefix must be supplied"))
+ (when repeat-type
+ (unless repeat-map
+ (error ":continue and :exit require specifying :repeat-map")))
+
(when (and menu-name (not prefix))
(error "If :menu-name is supplied, :prefix must be too"))
@@ -294,13 +363,16 @@ function symbol (unquoted)."
(append
(when prefix-map
`((defvar ,prefix-map)
- ,@(when doc `((put ',prefix-map 'variable-documentation ,doc)))
+ ,@(when prefix-doc `((put ',prefix-map 'variable-documentation ,prefix-doc)))
,@(if menu-name
`((define-prefix-command ',prefix-map nil ,menu-name))
`((define-prefix-command ',prefix-map)))
,@(if (and map (not (eq map 'global-map)))
(wrap map `((bind-key ,prefix ',prefix-map ,map ,filter)))
`((bind-key ,prefix ',prefix-map nil ,filter)))))
+ (when repeat-map
+ `((defvar ,repeat-map (make-sparse-keymap)
+ ,@(when repeat-doc `(,repeat-doc)))))
(wrap map
(cl-mapcan
(lambda (form)
@@ -308,13 +380,19 @@ function symbol (unquoted)."
(if prefix-map
`((bind-key ,(car form) ,fun ,prefix-map ,filter))
(if (and map (not (eq map 'global-map)))
- `((bind-key ,(car form) ,fun ,map ,filter))
+ ;; Only needed in this branch, since when
+ ;; repeat-map is non-nil, map is always
+ ;; non-nil
+ `(,@(when (and repeat-map (not (eq repeat-type :exit)))
+ `((put ,fun 'repeat-map ',repeat-map)))
+ (bind-key ,(car form) ,fun ,map ,filter))
`((bind-key ,(car form) ,fun nil ,filter))))))
first))
(when next
- (bind-keys-form (if pkg
- (cons :package (cons pkg next))
- next) map)))))))
+ (bind-keys-form `(,@(when repeat-map `(:repeat-map ,repeat-map))
+ ,@(if pkg
+ (cons :package (cons pkg next))
+ next)) map)))))))
;;;###autoload
(defmacro bind-keys (&rest args)
@@ -328,6 +406,19 @@ Accepts keyword arguments:
for these bindings
:prefix-docstring STR - docstring for the prefix-map variable
:menu-name NAME - optional menu string for prefix map
+:repeat-docstring STR - docstring for the repeat-map variable
+:repeat-map MAP - name of the repeat map that should be created
+ for these bindings. If specified, the
+ `repeat-map' property of each command bound
+ (within the scope of the `:repeat-map' keyword)
+ is set to this map.
+:exit BINDINGS - Within the scope of `:repeat-map' will bind the
+ key in the repeat map, but will not set the
+ `repeat-map' property of the bound command.
+:continue BINDINGS - Within the scope of `:repeat-map' forces the
+ same behaviour as if no special keyword had
+ been used (that is, the command is bound, and
+ it's `repeat-map' property set)
:filter FORM - optional form to determine when bindings apply
The rest of the arguments are conses of keybinding string and a
diff --git a/lisp/use-package/use-package-bind-key.el b/lisp/use-package/use-package-bind-key.el
index e476b060ad6..9642f311750 100644
--- a/lisp/use-package/use-package-bind-key.el
+++ b/lisp/use-package/use-package-bind-key.el
@@ -86,13 +86,20 @@ deferred until the prefix key sequence is pressed."
;; :prefix-docstring STRING
;; :prefix-map SYMBOL
;; :prefix STRING
+ ;; :repeat-docstring STRING
+ ;; :repeat-map SYMBOL
;; :filter SEXP
;; :menu-name STRING
;; :package SYMBOL
+ ;; :continue and :exit are used within :repeat-map
((or (and (eq x :map) (symbolp (cadr arg)))
(and (eq x :prefix) (stringp (cadr arg)))
(and (eq x :prefix-map) (symbolp (cadr arg)))
(and (eq x :prefix-docstring) (stringp (cadr arg)))
+ (and (eq x :repeat-map) (symbolp (cadr arg)))
+ (eq x :continue)
+ (eq x :exit)
+ (and (eq x :repeat-docstring) (stringp (cadr arg)))
(eq x :filter)
(and (eq x :menu-name) (stringp (cadr arg)))
(and (eq x :package) (symbolp (cadr arg))))
diff --git a/lisp/use-package/use-package-chords.el b/lisp/use-package/use-package-chords.el
index 547adc27427..cf390dbe593 100644
--- a/lisp/use-package/use-package-chords.el
+++ b/lisp/use-package/use-package-chords.el
@@ -1,11 +1,11 @@
;;; use-package-chords.el --- key-chord keyword for use-package -*- lexical-binding: t; -*-
-;; Copyright (C) 2015-2017 Justin Talbott
+;; Copyright (C) 2015-2019 Justin Talbott
;; Author: Justin Talbott <justin@waymondo.com>
;; Keywords: convenience, tools, extensions
-;; URL: https://github.com/waymondo/use-package-chords
-;; Version: 0.2
+;; URL: https://github.com/jwiegley/use-package
+;; Version: 0.2.1
;; Package-Requires: ((use-package "2.1") (bind-key "1.0") (bind-chord "0.2") (key-chord "0.6"))
;; Filename: use-package-chords.el
;; License: GNU General Public License version 3, or (at your option) any later version
diff --git a/lisp/use-package/use-package-core.el b/lisp/use-package/use-package-core.el
index b5671ee249f..0734dcf1c80 100644
--- a/lisp/use-package/use-package-core.el
+++ b/lisp/use-package/use-package-core.el
@@ -6,7 +6,7 @@
;; Maintainer: John Wiegley <johnw@newartisans.com>
;; Created: 17 Jun 2012
;; Modified: 29 Nov 2017
-;; Version: 2.4
+;; Version: 2.4.1
;; Package-Requires: ((emacs "24.3"))
;; Keywords: dotemacs startup speed config package
;; URL: https://github.com/jwiegley/use-package
@@ -43,6 +43,16 @@
(require 'cl-lib)
(require 'tabulated-list)
+(eval-and-compile
+ ;; Declare a synthetic theme for :custom variables.
+ ;; Necessary in order to avoid having those variables saved by custom.el.
+ (deftheme use-package))
+
+(enable-theme 'use-package)
+;; Remove the synthetic use-package theme from the enabled themes, so
+;; iterating over them to "disable all themes" won't disable it.
+(setq custom-enabled-themes (remq 'use-package custom-enabled-themes))
+
(if (and (eq emacs-major-version 24) (eq emacs-minor-version 3))
(defsubst hash-table-keys (hash-table)
"Return a list of keys in HASH-TABLE."
@@ -56,7 +66,7 @@
"A use-package declaration for simplifying your `.emacs'."
:group 'startup)
-(defconst use-package-version "2.4"
+(defconst use-package-version "2.4.1"
"This version of use-package.")
(defcustom use-package-keywords
@@ -90,7 +100,8 @@
:load
;; This must occur almost last; the only forms which should appear after
;; are those that must happen directly after the config forms.
- :config)
+ :config
+ :local)
"The set of valid keywords, in the order they are processed in.
The order of this list is *very important*, so it is only
advisable to insert new keywords, never to delete or reorder
@@ -125,6 +136,13 @@ arguments will be ignored in the `use-package' expansion."
:type 'boolean
:group 'use-package)
+(defcustom use-package-use-theme t
+ "If non-nil, use a custom theme to avoid saving :custom
+variables twice (once in the Custom file, once in the use-package
+call)."
+ :type 'boolean
+ :group 'use-package)
+
(defcustom use-package-verbose nil
"Whether to report about loading and configuration details.
If you customize this, then you should require the `use-package'
@@ -299,14 +317,15 @@ include support for finding `use-package' and `require' forms.
Must be set before loading use-package."
:type 'boolean
:set
- #'(lambda (_sym value)
+ #'(lambda (sym value)
(eval-after-load 'lisp-mode
(if value
`(add-to-list 'lisp-imenu-generic-expression
(list "Packages" ,use-package-form-regexp-eval 2))
`(setq lisp-imenu-generic-expression
(remove (list "Packages" ,use-package-form-regexp-eval 2)
- lisp-imenu-generic-expression)))))
+ lisp-imenu-generic-expression))))
+ (set-default sym value))
:group 'use-package)
(defcustom use-package-compute-statistics nil
@@ -882,12 +901,12 @@ If RECURSED is non-nil, recurse into sublists."
"A predicate that recognizes functional constructions:
nil
sym
- 'sym
+ \\='sym
(quote sym)
#'sym
(function sym)
(lambda () ...)
- '(lambda () ...)
+ \\='(lambda () ...)
(quote (lambda () ...))
#'(lambda () ...)
(function (lambda () ...))"
@@ -974,11 +993,10 @@ If RECURSED is non-nil, recurse into sublists."
(defun use-package-statistics-last-event (package)
"Return the date when PACKAGE's status last changed.
The date is returned as a string."
- (format-time-string "%Y-%m-%d %a %H:%M"
- (or (gethash :config package)
- (gethash :init package)
- (gethash :preface package)
- (gethash :use-package package))))
+ (or (gethash :config package)
+ (gethash :init package)
+ (gethash :preface package)
+ (gethash :use-package package)))
(defun use-package-statistics-time (package)
"Return the time is took for PACKAGE to load."
@@ -998,7 +1016,9 @@ The information is formatted in a way suitable for
(vector
(symbol-name package)
(use-package-statistics-status statistics)
- (use-package-statistics-last-event statistics)
+ (format-time-string
+ "%H:%M:%S.%6N"
+ (use-package-statistics-last-event statistics))
(format "%.2f" (use-package-statistics-time statistics))))))
(defun use-package-report ()
@@ -1018,15 +1038,43 @@ meaning:
(tabulated-list-print)
(display-buffer (current-buffer))))
+(defvar use-package-statistics-status-order
+ '(("Declared" . 0)
+ ("Prefaced" . 1)
+ ("Initialized" . 2)
+ ("Configured" . 3)))
+
(define-derived-mode use-package-statistics-mode tabulated-list-mode
"use-package statistics"
"Show current statistics gathered about use-package declarations."
(setq tabulated-list-format
;; The sum of column width is 80 characters:
[("Package" 25 t)
- ("Status" 13 t)
- ("Last Event" 23 t)
- ("Time" 10 t)])
+ ("Status" 13
+ (lambda (a b)
+ (< (assoc-default
+ (use-package-statistics-status
+ (gethash (car a) use-package-statistics))
+ use-package-statistics-status-order)
+ (assoc-default
+ (use-package-statistics-status
+ (gethash (car b) use-package-statistics))
+ use-package-statistics-status-order))))
+ ("Last Event" 23
+ (lambda (a b)
+ (< (float-time
+ (use-package-statistics-last-event
+ (gethash (car a) use-package-statistics)))
+ (float-time
+ (use-package-statistics-last-event
+ (gethash (car b) use-package-statistics))))))
+ ("Time" 10
+ (lambda (a b)
+ (< (use-package-statistics-time
+ (gethash (car a) use-package-statistics))
+ (use-package-statistics-time
+ (gethash (car b) use-package-statistics)))))])
+ (setq tabulated-list-sort-key '("Time" . t))
(tabulated-list-init-header))
(defun use-package-statistics-gather (keyword name after)
@@ -1260,9 +1308,13 @@ meaning:
(concat (symbol-name sym)
use-package-hook-name-suffix)))
(function ,fun)))
- (if (use-package-non-nil-symbolp syms) (list syms) syms)))))
+ (use-package-hook-handler-normalize-mode-symbols syms)))))
(use-package-normalize-commands args))))
+(defun use-package-hook-handler-normalize-mode-symbols (syms)
+ "Ensure that `SYMS' turns into a list of modes."
+ (if (use-package-non-nil-symbolp syms) (list syms) syms))
+
;;;; :commands
(defalias 'use-package-normalize/:commands 'use-package-normalize-symlist)
@@ -1380,17 +1432,34 @@ no keyword implies `:all'."
(defun use-package-handler/:custom (name _keyword args rest state)
"Generate use-package custom keyword code."
(use-package-concat
- (mapcar
- #'(lambda (def)
- (let ((variable (nth 0 def))
- (value (nth 1 def))
- (comment (nth 2 def)))
- (unless (and comment (stringp comment))
- (setq comment (format "Customized with use-package %s" name)))
- `(funcall (or (get (quote ,variable) 'custom-set) #'set-default)
- (quote ,variable)
- ,value)))
- args)
+ (if (bound-and-true-p use-package-use-theme)
+ `((let ((custom--inhibit-theme-enable nil))
+ ;; Declare the theme here so use-package can be required inside
+ ;; eval-and-compile without warnings about unknown theme.
+ (unless (memq 'use-package custom-known-themes)
+ (deftheme use-package)
+ (enable-theme 'use-package)
+ (setq custom-enabled-themes (remq 'use-package custom-enabled-themes)))
+ (custom-theme-set-variables
+ 'use-package
+ ,@(mapcar
+ #'(lambda (def)
+ (let ((variable (nth 0 def))
+ (value (nth 1 def))
+ (comment (nth 2 def)))
+ (unless (and comment (stringp comment))
+ (setq comment (format "Customized with use-package %s" name)))
+ `'(,variable ,value nil () ,comment)))
+ args))))
+ (mapcar
+ #'(lambda (def)
+ (let ((variable (nth 0 def))
+ (value (nth 1 def))
+ (comment (nth 2 def)))
+ (unless (and comment (stringp comment))
+ (setq comment (format "Customized with use-package %s" name)))
+ `(customize-set-variable (quote ,variable) ,value ,comment)))
+ args))
(use-package-process-keywords name rest state)))
;;;; :custom-face
@@ -1476,6 +1545,31 @@ no keyword implies `:all'."
(when use-package-compute-statistics
`((use-package-statistics-gather :config ',name t))))))
+;;;; :local
+
+(defun use-package-normalize/:local (name keyword args)
+ (let ((first-arg-name (symbol-name (caar args))))
+ (if (not (string-suffix-p "-hook" first-arg-name))
+ (let* ((sym-name (symbol-name name))
+ (addition (if (string-suffix-p "-mode" sym-name)
+ "-hook"
+ "-mode-hook"))
+ (hook (intern (concat sym-name addition))))
+ `((,hook . ,(use-package-normalize-forms name keyword args))))
+ (cl-loop for (hook . code) in args
+ collect `(,hook . ,(use-package-normalize-forms name keyword code))))))
+
+(defun use-package-handler/:local (name _keyword arg rest state)
+ (let* ((body (use-package-process-keywords name rest state)))
+ (use-package-concat
+ body
+ (cl-loop for (hook . code) in arg
+ for func-name = (intern (concat "use-package-func/" (symbol-name hook)))
+ collect (progn
+ (push 'progn code)
+ `(defun ,func-name () ,code))
+ collect `(add-hook ',hook ',func-name)))))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; The main macro
@@ -1556,13 +1650,13 @@ this file. Usage:
:load-path Add to the `load-path' before attempting to load the package.
:diminish Support for diminish.el (if installed).
:delight Support for delight.el (if installed).
-:custom Call `custom-set' or `set-default' with each variable
+:custom Call `Custom-set' or `set-default' with each variable
definition without modifying the Emacs `custom-file'.
(compare with `custom-set-variables').
-:custom-face Call `customize-set-faces' with each face definition.
+:custom-face Call `custom-set-faces' with each face definition.
:ensure Loads the package using package.el if necessary.
:pin Pin the package to an archive."
- (declare (indent 1))
+ (declare (indent defun))
(unless (memq :disabled args)
(macroexp-progn
(use-package-concat
@@ -1581,8 +1675,6 @@ this file. Usage:
(when use-package-compute-statistics
`((use-package-statistics-gather :use-package ',name t)))))))
-(put 'use-package 'lisp-indent-function 'defun)
-
(provide 'use-package-core)
;; Local Variables:
diff --git a/lisp/use-package/use-package-ensure-system-package.el b/lisp/use-package/use-package-ensure-system-package.el
index 87abf407020..7c591af7d9b 100644
--- a/lisp/use-package/use-package-ensure-system-package.el
+++ b/lisp/use-package/use-package-ensure-system-package.el
@@ -25,6 +25,8 @@
(eval-when-compile
(declare-function system-packages-get-command "system-packages"))
+(defvar use-package-ensure-system-package--custom-packages '()
+ "List of custom packages installed.")
(defun use-package-ensure-system-package-consify (arg)
"Turn `arg' into a cons of (`package-name' . `install-command')."
@@ -38,15 +40,22 @@
((not (cdr arg))
(use-package-ensure-system-package-consify (car arg)))
((stringp (cdr arg))
- (cons (car arg) `(async-shell-command ,(cdr arg))))
+ (progn
+ (push (cdr arg) use-package-ensure-system-package--custom-packages)
+ (cons (car arg) `(async-shell-command ,(cdr arg)))))
(t
(cons (car arg)
`(system-packages-install ,(symbol-name (cdr arg)))))))))
+(defun use-package-ensure-system-package-update-custom-packages ()
+ (interactive)
+ (dolist (cmd use-package-ensure-system-package--custom-packages)
+ (async-shell-command cmd)))
+
;;;###autoload
(defun use-package-normalize/:ensure-system-package (_name-symbol keyword args)
"Turn `arg' into a list of cons-es of (`package-name' . `install-command')."
- (use-package-only-one (symbol-name keyword) args
+ (use-package-as-one (symbol-name keyword) args
(lambda (_label arg)
(cond
((and (listp arg) (listp (cdr arg)))
diff --git a/lisp/use-package/use-package-ensure.el b/lisp/use-package/use-package-ensure.el
index 50005a9e990..cb31b4b7dd4 100644
--- a/lisp/use-package/use-package-ensure.el
+++ b/lisp/use-package/use-package-ensure.el
@@ -93,7 +93,7 @@ The default value uses package.el to install the package."
(defun use-package-archive-exists-p (archive)
"Check if a given ARCHIVE is enabled.
-ARCHIVE can be a string or a symbol or 'manual to indicate a
+ARCHIVE can be a string or a symbol or `manual' to indicate a
manually updated package."
(if (member archive '(manual "manual"))
't
diff --git a/lisp/use-package/use-package.el b/lisp/use-package/use-package.el
index 1a8fff895f6..0e194d5f182 100644
--- a/lisp/use-package/use-package.el
+++ b/lisp/use-package/use-package.el
@@ -6,7 +6,7 @@
;; Maintainer: John Wiegley <johnw@newartisans.com>
;; Created: 17 Jun 2012
;; Modified: 29 Nov 2017
-;; Version: 2.4
+;; Version: 2.4.1
;; Package-Requires: ((emacs "24.3") (bind-key "2.4"))
;; Keywords: dotemacs startup speed config package
;; URL: https://github.com/jwiegley/use-package