From a3b7c3069cc067eff29a809c1295adcfe3bac100 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Sun, 17 Dec 2017 10:22:15 +0100 Subject: [PATCH] [ELPA] Update --- elpa/bind-key-20171129.2144/bind-key-pkg.el | 2 - .../bind-key-autoloads.el | 11 +- elpa/bind-key-20171210.2125/bind-key-pkg.el | 2 + .../bind-key.el | 90 +- .../page-break-lines-pkg.el | 2 - .../page-break-lines-autoloads.el | 4 +- .../page-break-lines-pkg.el | 2 + .../page-break-lines.el | 3 +- .../use-package-autoloads.el | 90 - .../use-package-pkg.el | 2 - elpa/use-package-20171201.1339/use-package.el | 1623 ----------------- elpa/use-package-20171215.2248/dir | 18 + .../use-package-autoloads.el | 209 +++ .../use-package-bind-key.el | 169 ++ .../use-package-core.el | 1528 ++++++++++++++++ .../use-package-delight.el | 91 + .../use-package-diminish.el | 80 + .../use-package-ensure.el | 214 +++ .../use-package-jump.el | 79 + .../use-package-lint.el | 84 + .../use-package-pkg.el | 8 + elpa/use-package-20171215.2248/use-package.el | 54 + .../use-package.info | 1043 +++++++++++ 23 files changed, 3651 insertions(+), 1757 deletions(-) delete mode 100644 elpa/bind-key-20171129.2144/bind-key-pkg.el rename elpa/{bind-key-20171129.2144 => bind-key-20171210.2125}/bind-key-autoloads.el (88%) create mode 100644 elpa/bind-key-20171210.2125/bind-key-pkg.el rename elpa/{bind-key-20171129.2144 => bind-key-20171210.2125}/bind-key.el (88%) delete mode 100644 elpa/page-break-lines-20171020.108/page-break-lines-pkg.el rename elpa/{page-break-lines-20171020.108 => page-break-lines-20171210.31}/page-break-lines-autoloads.el (98%) create mode 100644 elpa/page-break-lines-20171210.31/page-break-lines-pkg.el rename elpa/{page-break-lines-20171020.108 => page-break-lines-20171210.31}/page-break-lines.el (98%) delete mode 100644 elpa/use-package-20171201.1339/use-package-autoloads.el delete mode 100644 elpa/use-package-20171201.1339/use-package-pkg.el delete mode 100644 elpa/use-package-20171201.1339/use-package.el create mode 100644 elpa/use-package-20171215.2248/dir create mode 100644 elpa/use-package-20171215.2248/use-package-autoloads.el create mode 100644 elpa/use-package-20171215.2248/use-package-bind-key.el create mode 100644 elpa/use-package-20171215.2248/use-package-core.el create mode 100644 elpa/use-package-20171215.2248/use-package-delight.el create mode 100644 elpa/use-package-20171215.2248/use-package-diminish.el create mode 100644 elpa/use-package-20171215.2248/use-package-ensure.el create mode 100644 elpa/use-package-20171215.2248/use-package-jump.el create mode 100644 elpa/use-package-20171215.2248/use-package-lint.el create mode 100644 elpa/use-package-20171215.2248/use-package-pkg.el create mode 100644 elpa/use-package-20171215.2248/use-package.el create mode 100644 elpa/use-package-20171215.2248/use-package.info diff --git a/elpa/bind-key-20171129.2144/bind-key-pkg.el b/elpa/bind-key-20171129.2144/bind-key-pkg.el deleted file mode 100644 index 8fd16d5..0000000 --- a/elpa/bind-key-20171129.2144/bind-key-pkg.el +++ /dev/null @@ -1,2 +0,0 @@ -;;; -*- no-byte-compile: t -*- -(define-package "bind-key" "20171129.2144" "A simple way to manage personal keybindings" 'nil :commit "fe5d8a9f501d9151efd633c0e16f42932969f1fc" :url "https://github.com/jwiegley/use-package" :keywords '("keys" "keybinding" "config" "dotemacs")) diff --git a/elpa/bind-key-20171129.2144/bind-key-autoloads.el b/elpa/bind-key-20171210.2125/bind-key-autoloads.el similarity index 88% rename from elpa/bind-key-20171129.2144/bind-key-autoloads.el rename to elpa/bind-key-20171210.2125/bind-key-autoloads.el index 75f70ab..ac7c587 100644 --- a/elpa/bind-key-20171129.2144/bind-key-autoloads.el +++ b/elpa/bind-key-20171210.2125/bind-key-autoloads.el @@ -3,8 +3,8 @@ ;;; Code: (add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) -;;;### (autoloads nil "bind-key" "bind-key.el" (23074 63739 689897 -;;;;;; 354000)) +;;;### (autoloads nil "bind-key" "bind-key.el" (23094 13992 105416 +;;;;;; 163000)) ;;; Generated autoloads from bind-key.el (autoload 'bind-key "bind-key" "\ @@ -15,6 +15,13 @@ KEY-NAME may be a vector, in which case it is passed straight to spelled-out keystrokes, e.g., \"C-c C-z\". See documentation of `edmacro-mode' for details. +COMMAND must be an interactive function or lambda form. + +KEYMAP, if present, should be a keymap and not a quoted symbol. +For example: + + (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. Emacs can evaluate this form at any time that it does redisplay diff --git a/elpa/bind-key-20171210.2125/bind-key-pkg.el b/elpa/bind-key-20171210.2125/bind-key-pkg.el new file mode 100644 index 0000000..03d0fd2 --- /dev/null +++ b/elpa/bind-key-20171210.2125/bind-key-pkg.el @@ -0,0 +1,2 @@ +;;; -*- no-byte-compile: t -*- +(define-package "bind-key" "20171210.2125" "A simple way to manage personal keybindings" 'nil :commit "33e9a4b74042e46161bff70e19b87317b1781fc5" :url "https://github.com/jwiegley/use-package" :keywords '("keys" "keybinding" "config" "dotemacs")) diff --git a/elpa/bind-key-20171129.2144/bind-key.el b/elpa/bind-key-20171210.2125/bind-key.el similarity index 88% rename from elpa/bind-key-20171129.2144/bind-key.el rename to elpa/bind-key-20171210.2125/bind-key.el index d604194..ac10ad4 100644 --- a/elpa/bind-key-20171129.2144/bind-key.el +++ b/elpa/bind-key-20171210.2125/bind-key.el @@ -7,13 +7,13 @@ ;; Created: 16 Jun 2012 ;; Modified: 29 Nov 2017 ;; Version: 2.4 -;; Package-Version: 20171129.2144 +;; Package-Version: 20171210.2125 ;; Keywords: keys keybinding config dotemacs ;; URL: https://github.com/jwiegley/use-package ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the gnu general public license as -;; published by the free software foundation; either version 2, or (at +;; published by the free software foundation; either version 3, or (at ;; your option) any later version. ;; This program is distributed in the hope that it will be useful, but @@ -147,6 +147,13 @@ KEY-NAME may be a vector, in which case it is passed straight to spelled-out keystrokes, e.g., \"C-c C-z\". See documentation of `edmacro-mode' for details. +COMMAND must be an interactive function or lambda form. + +KEYMAP, if present, should be a keymap and not a quoted symbol. +For example: + + (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. Emacs can evaluate this form at any time that it does redisplay @@ -198,7 +205,7 @@ See `bind-key' for more details." "Similar to `bind-key', but overrides any mode-specific bindings." `(bind-key ,key-name ,command override-global-map ,predicate)) -(defun bind-keys-form (args) +(defun bind-keys-form (args keymap) "Bind multiple keys at once. Accepts keyword arguments: @@ -213,30 +220,48 @@ Accepts keyword arguments: The rest of the arguments are conses of keybinding string and a function symbol (unquoted)." - ;; jww (2016-02-26): This is a hack; this whole function needs to be - ;; rewritten to normalize arguments the way that use-package.el does. - (if (and (eq (car args) :package) - (not (eq (car (cdr (cdr args))) :map))) - (setq args (cons :map (cons 'global-map args)))) - (let* ((map (plist-get args :map)) - (doc (plist-get args :prefix-docstring)) - (prefix-map (plist-get args :prefix-map)) - (prefix (plist-get args :prefix)) - (filter (plist-get args :filter)) - (menu-name (plist-get args :menu-name)) - (pkg (plist-get args :package)) - (key-bindings (progn - (while (keywordp (car args)) - (pop args) - (pop args)) - args))) + (let (map + doc + prefix-map + prefix + filter + menu-name + pkg) + + ;; Process any initial keyword arguments + (let ((cont t)) + (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))) + ((and (eq :prefix-map (car args)) + (not (memq map '(global-map + override-global-map)))) + (setq prefix-map (cadr args))) + ((eq :prefix (car args)) + (setq prefix (cadr args))) + ((eq :filter (car args)) + (setq filter (cadr args)) t) + ((eq :menu-name (car args)) + (setq menu-name (cadr args))) + ((eq :package (car args)) + (setq pkg (cadr args)))) + (setq args (cddr 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 (and menu-name (not prefix)) (error "If :menu-name is supplied, :prefix must be too")) - (let ((args key-bindings) - saw-map first next) + + (unless map (setq map keymap)) + + ;; Process key binding arguments + (let (first next) (while args (if (keywordp (car args)) (progn @@ -246,15 +271,18 @@ function symbol (unquoted)." (nconc first (list (car args))) (setq first (list (car args)))) (setq args (cdr args)))) + (cl-flet ((wrap (map bindings) - (if (and map pkg (not (eq map 'global-map))) + (if (and map pkg (not (memq map '(global-map + override-global-map)))) `((if (boundp ',map) - (progn ,@bindings) + ,(macroexp-progn bindings) (eval-after-load ,(if (symbolp pkg) `',pkg pkg) - '(progn ,@bindings)))) + ',(macroexp-progn bindings)))) bindings))) + (append (when prefix-map `((defvar ,prefix-map) @@ -276,10 +304,9 @@ function symbol (unquoted)." `((bind-key ,(car form) ,fun nil ,filter)))))) first)) (when next - (bind-keys-form - (if pkg - (cons :package (cons pkg next)) - next)))))))) + (bind-keys-form (if pkg + (cons :package (cons pkg next)) + next) map))))))) ;;;###autoload (defmacro bind-keys (&rest args) @@ -297,12 +324,11 @@ Accepts keyword arguments: The rest of the arguments are conses of keybinding string and a function symbol (unquoted)." - (macroexp-progn (bind-keys-form args))) + (macroexp-progn (bind-keys-form args nil))) ;;;###autoload (defmacro bind-keys* (&rest args) - (macroexp-progn - (bind-keys-form `(:map override-global-map ,@args)))) + (macroexp-progn (bind-keys-form args 'override-global-map))) (defun get-binding-description (elem) (cond diff --git a/elpa/page-break-lines-20171020.108/page-break-lines-pkg.el b/elpa/page-break-lines-20171020.108/page-break-lines-pkg.el deleted file mode 100644 index 7d6581e..0000000 --- a/elpa/page-break-lines-20171020.108/page-break-lines-pkg.el +++ /dev/null @@ -1,2 +0,0 @@ -;;; -*- no-byte-compile: t -*- -(define-package "page-break-lines" "20171020.108" "Display ^L page breaks as tidy horizontal lines" '((emacs "24.4")) :commit "ae1c0065984429c7364a667abb9180e80134c4c0" :url "https://github.com/purcell/page-break-lines" :keywords '("convenience" "faces")) diff --git a/elpa/page-break-lines-20171020.108/page-break-lines-autoloads.el b/elpa/page-break-lines-20171210.31/page-break-lines-autoloads.el similarity index 98% rename from elpa/page-break-lines-20171020.108/page-break-lines-autoloads.el rename to elpa/page-break-lines-20171210.31/page-break-lines-autoloads.el index b312031..1b6f0c0 100644 --- a/elpa/page-break-lines-20171020.108/page-break-lines-autoloads.el +++ b/elpa/page-break-lines-20171210.31/page-break-lines-autoloads.el @@ -3,8 +3,8 @@ ;;; Code: (add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) -;;;### (autoloads nil "page-break-lines" "page-break-lines.el" (23028 -;;;;;; 47890 302341 377000)) +;;;### (autoloads nil "page-break-lines" "page-break-lines.el" (23094 +;;;;;; 13927 449089 481000)) ;;; Generated autoloads from page-break-lines.el (defvar page-break-lines-char 9472 "\ diff --git a/elpa/page-break-lines-20171210.31/page-break-lines-pkg.el b/elpa/page-break-lines-20171210.31/page-break-lines-pkg.el new file mode 100644 index 0000000..f0b7e0d --- /dev/null +++ b/elpa/page-break-lines-20171210.31/page-break-lines-pkg.el @@ -0,0 +1,2 @@ +;;; -*- no-byte-compile: t -*- +(define-package "page-break-lines" "20171210.31" "Display ^L page breaks as tidy horizontal lines" '((emacs "24.4")) :commit "fd3b7e38ad8747cd009ead7ef1bb150849ccc693" :url "https://github.com/purcell/page-break-lines" :keywords '("convenience" "faces")) diff --git a/elpa/page-break-lines-20171020.108/page-break-lines.el b/elpa/page-break-lines-20171210.31/page-break-lines.el similarity index 98% rename from elpa/page-break-lines-20171020.108/page-break-lines.el rename to elpa/page-break-lines-20171210.31/page-break-lines.el index db3e720..aa5c9fa 100644 --- a/elpa/page-break-lines-20171020.108/page-break-lines.el +++ b/elpa/page-break-lines-20171210.31/page-break-lines.el @@ -4,7 +4,7 @@ ;; Author: Steve Purcell ;; URL: https://github.com/purcell/page-break-lines -;; Package-Version: 20171020.108 +;; Package-Version: 20171210.31 ;; Package-X-Original-Version: 0 ;; Package-Requires: ((emacs "24.4")) ;; Keywords: convenience, faces @@ -169,7 +169,6 @@ When `major-mode' is listed in `page-break-lines-modes', then ;; Local Variables: ;; coding: utf-8 -;; byte-compile-warnings: (not cl-functions) ;; checkdoc-minor-mode: t ;; End: diff --git a/elpa/use-package-20171201.1339/use-package-autoloads.el b/elpa/use-package-20171201.1339/use-package-autoloads.el deleted file mode 100644 index 901d481..0000000 --- a/elpa/use-package-20171201.1339/use-package-autoloads.el +++ /dev/null @@ -1,90 +0,0 @@ -;;; use-package-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) - -;;;### (autoloads nil "use-package" "use-package.el" (23074 63646 -;;;;;; 149414 588000)) -;;; Generated autoloads from use-package.el - -(autoload 'use-package-autoload-keymap "use-package" "\ -Loads PACKAGE and then binds the key sequence used to invoke - this function to KEYMAP-SYMBOL. It then simulates pressing the - same key sequence a again, so that the next key pressed is routed - to the newly loaded keymap. - - This function supports use-package's :bind-keymap keyword. It - works by binding the given key sequence to an invocation of this - function for a particular keymap. The keymap is expected to be - defined by the package. In this way, loading the package is - deferred until the prefix key sequence is pressed. - -\(fn KEYMAP-SYMBOL PACKAGE OVERRIDE)" nil nil) - -(autoload 'use-package "use-package" "\ -Declare an Emacs package by specifying a group of configuration options. - -For full documentation, please see the README file that came with -this file. Usage: - - (use-package package-name - [:keyword [option]]...) - -:init Code to run before PACKAGE-NAME has been loaded. -:config Code to run after PACKAGE-NAME has been loaded. Note that - if loading is deferred for any reason, this code does not - execute until the lazy load has occurred. -:preface Code to be run before everything except `:disabled'; this - can be used to define functions for use in `:if', or that - should be seen by the byte-compiler. - -:mode Form to be added to `auto-mode-alist'. -:magic Form to be added to `magic-mode-alist'. -:magic-fallback Form to be added to `magic-fallback-mode-alist'. -:interpreter Form to be added to `interpreter-mode-alist'. - -:commands Define autoloads for commands that will be defined by the - package. This is useful if the package is being lazily - loaded, and you wish to conditionally call functions in your - `:init' block that are defined in the package. - -:bind Bind keys, and define autoloads for the bound commands. -:bind* Bind keys, and define autoloads for the bound commands, - *overriding all minor mode bindings*. -:bind-keymap Bind a key prefix to an auto-loaded keymap defined in the - package. This is like `:bind', but for keymaps. -:bind-keymap* Like `:bind-keymap', but overrides all minor mode bindings - -:defer Defer loading of a package -- this is implied when using - `:commands', `:bind', `:bind*', `:mode', `:magic', - `:magic-fallback', or `:interpreter'. This can be an integer, - to force loading after N seconds of idle time, if the package - has not already been loaded. -:after Defer loading of a package until after any of the named - features are loaded. -:demand Prevent deferred loading in all cases. - -:if EXPR Initialize and load only if EXPR evaluates to a non-nil value. -:disabled The package is ignored completely if this keyword is present. -:defines Declare certain variables to silence the byte-compiler. -:functions Declare certain functions to silence the byte-compiler. -: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 `customize-set-variable' with each variable definition. -:custom-face Call `customize-set-faces' with each face definition. -:ensure Loads the package using package.el if necessary. -:pin Pin the package to an archive. - -\(fn NAME &rest ARGS)" nil t) - -(function-put 'use-package 'lisp-indent-function '1) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; use-package-autoloads.el ends here diff --git a/elpa/use-package-20171201.1339/use-package-pkg.el b/elpa/use-package-20171201.1339/use-package-pkg.el deleted file mode 100644 index 4184353..0000000 --- a/elpa/use-package-20171201.1339/use-package-pkg.el +++ /dev/null @@ -1,2 +0,0 @@ -;;; -*- no-byte-compile: t -*- -(define-package "use-package" "20171201.1339" "A use-package declaration for simplifying your .emacs" '((emacs "24.3") (bind-key "2.4")) :commit "e8a3fdcc2e4c1557b64df25bec26851ec319d912" :url "https://github.com/jwiegley/use-package" :keywords '("dotemacs" "startup" "speed" "config" "package")) diff --git a/elpa/use-package-20171201.1339/use-package.el b/elpa/use-package-20171201.1339/use-package.el deleted file mode 100644 index 91ee0a7..0000000 --- a/elpa/use-package-20171201.1339/use-package.el +++ /dev/null @@ -1,1623 +0,0 @@ -;;; use-package.el --- A use-package declaration for simplifying your .emacs - -;; Copyright (C) 2012-2017 John Wiegley - -;; Author: John Wiegley -;; Maintainer: John Wiegley -;; Created: 17 Jun 2012 -;; Modified: 29 Nov 2017 -;; Version: 2.4 -;; Package-Version: 20171201.1339 -;; Package-Requires: ((emacs "24.3") (bind-key "2.4")) -;; Keywords: dotemacs startup speed config package -;; URL: https://github.com/jwiegley/use-package - -;; This program is free software; you can redistribute it and/or -;; modify it under the terms of the GNU General Public License as -;; published by the Free Software Foundation; either version 3, or (at -;; your option) any later version. - -;; This program is distributed in the hope that it will be useful, but -;; WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -;; General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; The `use-package' declaration macro allows you to isolate package -;; configuration in your ".emacs" in a way that is performance-oriented and, -;; well, just tidy. I created it because I have over 80 packages that I use -;; in Emacs, and things were getting difficult to manage. Yet with this -;; utility my total load time is just under 1 second, with no loss of -;; functionality! -;; -;; Please see README.md from the same repository for documentation. - -;;; Code: - -(require 'bind-key) -(require 'bytecomp) -(require 'cl-lib) -(eval-when-compile - (require 'cl) - (require 'regexp-opt)) - -(declare-function package-installed-p "package") -(declare-function package-read-all-archive-contents "package" ()) - -(defconst use-package-version "2.4" - "This version of use-package.") - -(defgroup use-package nil - "A use-package declaration for simplifying your `.emacs'." - :group 'startup) - -(defcustom use-package-verbose nil - "Whether to report about loading and configuration details. - -If you customize this, then you should require the `use-package' -feature in files that use `use-package', even if these files only -contain compiled expansions of the macros. If you don't do so, -then the expanded macros do their job silently." - :type '(choice (const :tag "Quiet" nil) (const :tag "Verbose" t) - (const :tag "Debug" debug)) - :group 'use-package) - -(defcustom use-package-debug nil - "Whether to display use-package expansions in a *use-package* buffer." - :type 'boolean - :group 'use-package) - -(defcustom use-package-check-before-init nil - "If non-nil, check that package exists before executing its `:init' block. -The check is performed by looking for the module using `locate-library'." - :type 'boolean - :group 'use-package) - -(defcustom use-package-always-defer nil - "If non-nil, assume `:defer t` unless `:demand t` is given." - :type 'boolean - :group 'use-package) - -(defcustom use-package-always-demand nil - "If non-nil, assume `:demand t` unless `:defer t` is given." - :type 'boolean - :group 'use-package) - -(defcustom use-package-always-ensure nil - "Treat every package as though it had specified `:ensure SEXP`." - :type 'sexp - :group 'use-package) - -(defcustom use-package-always-pin nil - "Treat every package as though it had specified `:pin SYM`." - :type 'symbol - :group 'use-package) - -(defcustom use-package-minimum-reported-time 0.1 - "Minimal load time that will be reported. - -Note that `use-package-verbose' has to be set to t, for anything -to be reported at all. - -If you customize this, then you should require the `use-package' -feature in files that use `use-package', even if these files only -contain compiled expansions of the macros. If you don't do so, -then the expanded macros do their job silently." - :type 'number - :group 'use-package) - -(defcustom use-package-inject-hooks nil - "If non-nil, add hooks to the `:init' and `:config' sections. -In particular, for a given package `foo', the following hooks -become available: - - `use-package--foo--pre-init-hook' - `use-package--foo--post-init-hook' - `use-package--foo--pre-config-hook' - `use-package--foo--post-config-hook' - -This way, you can add to these hooks before evaluation of a -`use-package` declaration, and exercise some control over what -happens. - -Note that if either `pre-init' hooks returns a nil value, that -block's user-supplied configuration is not evaluated, so be -certain to return `t' if you only wish to add behavior to what -the user specified." - :type 'boolean - :group 'use-package) - -(defcustom use-package-keywords - '(:disabled - :pin - :ensure - :if - :when - :unless - :requires - :load-path - :defines - :functions - :preface - :no-require - :bind - :bind* - :bind-keymap - :bind-keymap* - :interpreter - :mode - :magic - :magic-fallback - :commands - :hook - :defer - :custom - :custom-face - :init - :after - :demand - :config - :diminish - :delight) - "Establish which keywords are valid, and the order they are processed in. - -Note that `:disabled' is special, in that it causes nothing at all to happen, -even if the rest of the use-package declaration is incorrect." - :type '(repeat symbol) - :group 'use-package) - -(defcustom use-package-expand-minimally nil - "If non-nil, make the expanded code as minimal as possible. -This disables: - - Printing to the *Messages* buffer of slowly-evaluating forms - - Capture of load errors (normally redisplayed as warnings) - - Conditional loading of packages (load failures become errors) -The only advantage is that, if you know your configuration works, -then your byte-compiled init file is as minimal as possible." - :type 'boolean - :group 'use-package) - -(defcustom use-package-enable-imenu-support nil - "If non-nil, adjust `lisp-imenu-generic-expression' to include -support for finding `use-package' and `require' forms. - -Must be set before loading use-package." - :type 'boolean - :group 'use-package) - -(defcustom use-package-ensure-function 'use-package-ensure-elpa - "Function that ensures a package is installed. -This function is called with four arguments: the name of the -package declared in the `use-package' form; the argument passed -to `:ensure'; and the current `state' plist created by previous -handlers. - -Note that this function is called whenever `:ensure' is provided, -even if it is nil. It is up to the function to decide on the -semantics of the various values for `:ensure'. - -This function should return non-nil if the package is installed. - -The default value uses package.el to install the package." - :type '(choice (const :tag "package.el" use-package-ensure-elpa) - (function :tag "Custom")) - :group 'use-package) - -(defcustom use-package-defaults - '((:config '(t) t) - (:ensure use-package-always-ensure use-package-always-ensure) - (:pin use-package-always-pin use-package-always-pin)) - "Alist of default values for `use-package' keywords. -Each entry in the alist is a list of three elements. The first -element is the `use-package' keyword and the second is a form -that can be evaluated to get the default value. The third element -is a form that can be evaluated to determine whether or not to -assign a default value; if it evaluates to nil, then the default -value is not assigned even if the keyword is not present in the -`use-package' form." - :type '(repeat (list symbol sexp sexp))) - -(when use-package-enable-imenu-support - (eval-after-load 'lisp-mode - `(let ((sym-regexp (or (bound-and-true-p lisp-mode-symbol-regexp) - "\\(?:\\sw\\|\\s_\\|\\\\.\\)+"))) - (add-to-list - 'lisp-imenu-generic-expression - (list "Packages" - (concat "^\\s-*(" - ,(eval-when-compile - (regexp-opt '("use-package" "require") t)) - "\\s-+\\(" sym-regexp "\\)") - 2))))) - -(defvar use-package-form-regexp "^\\s-*(\\s-*use-package\\s-+\\_<%s\\_>" - "Regexp used in `use-package-jump-to-package-form' to find use -package forms in user files.") - -(defun use-package--find-require (package) - "Find file that required PACKAGE by searching -`load-history'. Returns an absolute file path or nil if none is -found." - (catch 'suspect - (dolist (filespec load-history) - (dolist (entry (cdr filespec)) - (when (equal entry (cons 'require package)) - (throw 'suspect (car filespec))))))) - -(defun use-package-jump-to-package-form (package) - "Attempt to find and jump to the `use-package' form that loaded -PACKAGE. This will only find the form if that form actually -required PACKAGE. If PACKAGE was previously required then this -function will jump to the file that originally required PACKAGE -instead." - (interactive (list (completing-read "Package: " features))) - (let* ((package (if (stringp package) (intern package) package)) - (requiring-file (use-package--find-require package)) - file location) - (if (null requiring-file) - (user-error "Can't find file that requires this feature.") - (setq file (if (string= (file-name-extension requiring-file) "elc") - (concat (file-name-sans-extension requiring-file) ".el") - requiring-file)) - (when (file-exists-p file) - (find-file-other-window file) - (save-excursion - (goto-char (point-min)) - (setq location - (re-search-forward - (format use-package-form-regexp package) nil t))) - (if (null location) - (message "No use-package form found.") - (goto-char location) - (beginning-of-line)))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; Utility functions -;; - -(defun use-package-as-symbol (string-or-symbol) - "If STRING-OR-SYMBOL is already a symbol, return it. Otherwise -convert it to a symbol and return that." - (if (symbolp string-or-symbol) string-or-symbol - (intern string-or-symbol))) - -(defun use-package-as-string (string-or-symbol) - "If STRING-OR-SYMBOL is already a string, return it. Otherwise -convert it to a string and return that." - (if (stringp string-or-symbol) string-or-symbol - (symbol-name string-or-symbol))) - -(defun use-package-as-mode (string-or-symbol) - "If STRING-OR-SYMBOL ends in `-mode' (or its name does), return -it as a symbol. Otherwise, return it as a symbol with `-mode' -appended." - (let ((string (use-package-as-string string-or-symbol))) - (intern (if (string-match "-mode\\'" string) string - (concat string "-mode"))))) - -(defun use-package-load-name (name &optional noerror) - "Return a form which will load or require NAME depending on -whether it's a string or symbol." - (if (stringp name) - `(load ,name ,noerror) - `(require ',name nil ,noerror))) - -(defun use-package-expand (name label form) - "FORM is a list of forms, so `((foo))' if only `foo' is being called." - (declare (indent 1)) - (when form - (if use-package-expand-minimally - form - (let ((err (make-symbol "err"))) - (list - `(condition-case-unless-debug ,err - ,(macroexp-progn form) - (error - (ignore - (display-warning 'use-package - (format "%s %s: %s" - ,name ,label (error-message-string ,err)) - :error))))))))) - -(put 'use-package-expand 'lisp-indent-function 'defun) - -(defun use-package-hook-injector (name-string keyword body) - "Wrap pre/post hook injections around a given keyword form. -ARGS is a list of forms, so `((foo))' if only `foo' is being called." - (if (not use-package-inject-hooks) - (use-package-expand name-string (format "%s" keyword) body) - (let ((keyword-name (substring (format "%s" keyword) 1))) - `((when ,(macroexp-progn - (use-package-expand name-string (format "pre-%s hook" keyword) - `((run-hook-with-args-until-failure - ',(intern (concat "use-package--" name-string - "--pre-" keyword-name "-hook")))))) - ,(macroexp-progn - (use-package-expand name-string (format "%s" keyword) body)) - ,(macroexp-progn - (use-package-expand name-string (format "post-%s hook" keyword) - `((run-hooks - ',(intern (concat "use-package--" name-string - "--post-" keyword-name "-hook"))))))))))) - -(defun use-package--require (name &optional no-require body) - (use-package--with-elapsed-timer - (format "Loading package %s" name) - (if use-package-expand-minimally - (use-package-concat - (unless no-require - (list (use-package-load-name name))) - body) - (if no-require - body - `((if (not ,(use-package-load-name name t)) - (ignore (message (format "Cannot load %s" ',name))) - ,@body)))))) - -(defun use-package--with-elapsed-timer (text body) - "BODY is a list of forms, so `((foo))' if only `foo' is being called." - (declare (indent 1)) - (if use-package-expand-minimally - body - (let ((nowvar (make-symbol "now"))) - (if (bound-and-true-p use-package-verbose) - `((let ((,nowvar (current-time))) - (message "%s..." ,text) - (prog1 - ,(macroexp-progn body) - (let ((elapsed - (float-time (time-subtract (current-time) ,nowvar)))) - (if (> elapsed ,use-package-minimum-reported-time) - (message "%s...done (%.3fs)" ,text elapsed) - (message "%s...done" ,text)))))) - body)))) - -(put 'use-package--with-elapsed-timer 'lisp-indent-function 1) - -(defsubst use-package-error (msg) - "Report MSG as an error, so the user knows it came from this package." - (error "use-package: %s" msg)) - -(defsubst use-package-plist-maybe-put (plist property value) - "Add a VALUE for PROPERTY to PLIST, if it does not already exist." - (if (plist-member plist property) - plist - (plist-put plist property value))) - -(defsubst use-package-plist-cons (plist property value) - "Cons VALUE onto the head of the list at PROPERTY in PLIST." - (plist-put plist property (cons value (plist-get plist property)))) - -(defsubst use-package-plist-append (plist property value) - "Append VALUE onto the front of the list at PROPERTY in PLIST." - (plist-put plist property (append value (plist-get plist property)))) - -(defun use-package-plist-delete (plist property) - "Delete PROPERTY from PLIST. -This is in contrast to merely setting it to 0." - (let (p) - (while plist - (if (not (eq property (car plist))) - (setq p (plist-put p (car plist) (nth 1 plist)))) - (setq plist (cddr plist))) - p)) - -(defun use-package-split-list (pred xs) - (let ((ys (list nil)) (zs (list nil)) flip) - (dolist (x xs) - (if flip - (nconc zs (list x)) - (if (funcall pred x) - (progn - (setq flip t) - (nconc zs (list x))) - (nconc ys (list x))))) - (cons (cdr ys) (cdr zs)))) - -(defun use-package-keyword-index (keyword) - (loop named outer - with index = 0 - for k in use-package-keywords do - (if (eq k keyword) - (return-from outer index)) - (incf index))) - -(defun use-package-sort-keywords (plist) - (let (plist-grouped) - (while plist - (push (cons (car plist) (cadr plist)) - plist-grouped) - (setq plist (cddr plist))) - (let (result) - (dolist (x - (nreverse - (sort plist-grouped - #'(lambda (l r) (< (use-package-keyword-index (car l)) - (use-package-keyword-index (car r))))))) - (setq result (cons (car x) (cons (cdr x) result)))) - result))) - -(defsubst use-package-concat (&rest elems) - "Delete all empty lists from ELEMS (nil or (list nil)), and append them." - (apply #'nconc (delete nil (delete (list nil) elems)))) - -(defsubst use-package--non-nil-symbolp (sym) - (and sym (symbolp sym))) - -(defconst use-package-font-lock-keywords - '(("(\\(use-package\\)\\_>[ \t']*\\(\\(?:\\sw\\|\\s_\\)+\\)?" - (1 font-lock-keyword-face) - (2 font-lock-constant-face nil t)))) - -(font-lock-add-keywords 'emacs-lisp-mode use-package-font-lock-keywords) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; Keyword processing -;; - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; Normalization functions -;; - -(defsubst use-package-regex-p (re) - "Return t if RE is some regexp-like thing." - (or (and (listp re) - (eq (car re) 'rx)) - (stringp re))) - -(defun use-package-normalize-regex (re) - "Given some regexp-like thing, resolve it down to a regular expression." - (cond - ((and (listp re) - (eq (car re) 'rx)) - (eval re)) - ((stringp re) - re) - (t - (error "Not recognized as regular expression: %s" re)))) - -(defun use-package-normalize-plist (name input) - "Given a pseudo-plist, normalize it to a regular plist." - (unless (null input) - (let* ((keyword (car input)) - (xs (use-package-split-list #'keywordp (cdr input))) - (args (car xs)) - (tail (cdr xs)) - (normalizer (intern (concat "use-package-normalize/" - (symbol-name keyword)))) - (arg - (cond - ((eq keyword :disabled) - (use-package-normalize-plist name tail)) - ((functionp normalizer) - (funcall normalizer name keyword args)) - ((= (length args) 1) - (car args)) - (t - args)))) - (if (memq keyword use-package-keywords) - (cons keyword - (cons arg (use-package-normalize-plist name tail))) - (ignore - (display-warning 'use-package - (format "Unrecognized keyword: %s" keyword) - :warning)))))) - -(defun use-package-process-keywords (name plist &optional state) - "Process the next keyword in the free-form property list PLIST. -The values in the PLIST have each been normalized by the function -use-package-normalize/KEYWORD (minus the colon). - -STATE is a property list that the function may modify and/or -query. This is useful if a package defines multiple keywords and -wishes them to have some kind of stateful interaction. - -Unless the KEYWORD being processed intends to ignore remaining -keywords, it must call this function recursively, passing in the -plist with its keyword and argument removed, and passing in the -next value for the STATE." - (declare (indent 1)) - (unless (null plist) - (let* ((keyword (car plist)) - (arg (cadr plist)) - (rest (cddr plist))) - (unless (keywordp keyword) - (use-package-error (format "%s is not a keyword" keyword))) - (let* ((handler (concat "use-package-handler/" (symbol-name keyword))) - (handler-sym (intern handler))) - (if (functionp handler-sym) - (funcall handler-sym name keyword arg rest state) - (use-package-error - (format "Keyword handler not defined: %s" handler))))))) - -(put 'use-package-process-keywords 'lisp-indent-function 'defun) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :pin -;; - -(defun use-package-only-one (label args f) - "Call F on the first member of ARGS if it has exactly one element." - (declare (indent 1)) - (cond - ((and (listp args) (listp (cdr args)) - (= (length args) 1)) - (funcall f label (car args))) - (t - (use-package-error - (concat label " wants exactly one argument"))))) - -(put 'use-package-only-one 'lisp-indent-function 'defun) - -(defun use-package-normalize/:pin (name keyword args) - (use-package-only-one (symbol-name keyword) args - (lambda (label arg) - (cond - ((stringp arg) arg) - ((use-package--non-nil-symbolp arg) (symbol-name arg)) - (t - (use-package-error - ":pin wants an archive name (a string)")))))) - -(eval-when-compile - (defvar package-pinned-packages) - (defvar package-archives)) - -(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 -manually updated package." - (if (member archive '(manual "manual")) - 't - (let ((valid nil)) - (dolist (pa package-archives) - (when (member archive (list (car pa) (intern (car pa)))) - (setq valid 't))) - valid))) - -(defun use-package-pin-package (package archive) - "Pin PACKAGE to ARCHIVE." - (unless (boundp 'package-pinned-packages) - (setq package-pinned-packages ())) - (let ((archive-symbol (if (symbolp archive) archive (intern archive))) - (archive-name (if (stringp archive) archive (symbol-name archive)))) - (if (use-package--archive-exists-p archive-symbol) - (add-to-list 'package-pinned-packages (cons package archive-name)) - (error "Archive '%s' requested for package '%s' is not available." - archive-name package)) - (unless (bound-and-true-p package--initialized) - (package-initialize t)))) - -(defun use-package-handler/:pin (name keyword archive-name rest state) - (let ((body (use-package-process-keywords name rest state)) - (pin-form (if archive-name - `(use-package-pin-package ',(use-package-as-symbol name) - ,archive-name)))) - ;; Pinning should occur just before ensuring - ;; See `use-package-handler/:ensure'. - (if (bound-and-true-p byte-compile-current-file) - (eval pin-form) ; Eval when byte-compiling, - (push pin-form body)) ; or else wait until runtime. - body)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :ensure -;; -(defvar package-archive-contents) -(defun use-package-normalize/:ensure (name keyword args) - (if (null args) - t - (use-package-only-one (symbol-name keyword) args - (lambda (label arg) - (if (symbolp arg) - arg - (use-package-error - (concat ":ensure wants an optional package name " - "(an unquoted symbol name)"))))))) - -(defun use-package-ensure-elpa (name ensure state &optional no-refresh) - (let ((package - (or (and (eq ensure t) (use-package-as-symbol name)) - ensure))) - (when package - (require 'package) - (unless (package-installed-p package) - (condition-case-unless-debug err - (progn - (when (assoc package (bound-and-true-p - package-pinned-packages)) - (package-read-all-archive-contents)) - (if (assoc package package-archive-contents) - (package-install package) - (package-refresh-contents) - (when (assoc package (bound-and-true-p - package-pinned-packages)) - (package-read-all-archive-contents)) - (package-install package)) - t) - (error - (ignore - (display-warning 'use-package - (format "Failed to install %s: %s" - name (error-message-string err)) - :error)))))))) - -(defun use-package-handler/:ensure (name keyword ensure rest state) - (let* ((body (use-package-process-keywords name rest state))) - ;; We want to avoid installing packages when the `use-package' macro is - ;; being macro-expanded by elisp completion (see `lisp--local-variables'), - ;; but still install packages when byte-compiling, to avoid requiring - ;; `package' at runtime. - (if (bound-and-true-p byte-compile-current-file) - ;; Eval when byte-compiling, - (funcall use-package-ensure-function name ensure state) - ;; or else wait until runtime. - (push `(,use-package-ensure-function ',name ',ensure ',state) - body)) - body)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :if, :when and :unless -;; - -(defsubst use-package-normalize-value (label arg) - "Normalize a value." - (cond ((null arg) nil) - ((use-package--non-nil-symbolp arg) - `(symbol-value ',arg)) - ((functionp arg) - `(funcall #',arg)) - (t arg))) - -(defun use-package-normalize-test (name keyword args) - (use-package-only-one (symbol-name keyword) args - #'use-package-normalize-value)) - -(defalias 'use-package-normalize/:if 'use-package-normalize-test) -(defalias 'use-package-normalize/:when 'use-package-normalize-test) -(defalias 'use-package-normalize/:unless 'use-package-normalize-test) - -(defun use-package-handler/:if (name keyword pred rest state) - (let ((body (use-package-process-keywords name rest state))) - `((when ,pred ,@body)))) - -(defalias 'use-package-handler/:when 'use-package-handler/:if) - -(defun use-package-handler/:unless (name keyword pred rest state) - (let ((body (use-package-process-keywords name rest state))) - `((unless ,pred ,@body)))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :requires -;; - -(defun use-package-as-one (label args f &optional allow-empty) - "Call F on the first element of ARGS if it has one element, or all of ARGS. -If ALLOW-EMPTY is non-nil, it's OK for ARGS to be an empty list." - (declare (indent 1)) - (if (if args - (and (listp args) (listp (cdr args))) - allow-empty) - (if (= (length args) 1) - (funcall f label (car args)) - (funcall f label args)) - (use-package-error - (concat label " wants a non-empty list")))) - -(put 'use-package-as-one 'lisp-indent-function 'defun) - -(defun use-package-normalize-symbols (label arg &optional recursed) - "Normalize a list of symbols." - (cond - ((use-package--non-nil-symbolp arg) - (list arg)) - ((and (not recursed) (listp arg) (listp (cdr arg))) - (mapcar #'(lambda (x) (car (use-package-normalize-symbols label x t))) arg)) - (t - (use-package-error - (concat label " wants a symbol, or list of symbols"))))) - -(defun use-package-normalize-symlist (name keyword args) - (use-package-as-one (symbol-name keyword) args - #'use-package-normalize-symbols)) - -(defun use-package-normalize-recursive-symbols (label arg) - "Normalize a list of symbols." - (cond - ((use-package--non-nil-symbolp arg) - arg) - ((and (listp arg) (listp (cdr arg))) - (mapcar #'(lambda (x) (use-package-normalize-recursive-symbols label x)) - arg)) - (t - (use-package-error - (concat label " wants a symbol, or nested list of symbols"))))) - -(defun use-package-normalize-recursive-symlist (name keyword args) - (use-package-as-one (symbol-name keyword) args - #'use-package-normalize-recursive-symbols)) - -(defalias 'use-package-normalize/:requires 'use-package-normalize-symlist) - -(defun use-package-handler/:requires (name keyword requires rest state) - (let ((body (use-package-process-keywords name rest state))) - (if (null requires) - body - `((when ,(if (listp requires) - `(not (member nil (mapcar #'featurep ',requires))) - `(featurep ',requires)) - ,@body))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :load-path -;; - -(defun use-package-normalize-paths (label arg &optional recursed) - "Normalize a list of filesystem paths." - (cond - ((and arg (or (use-package--non-nil-symbolp arg) (functionp arg))) - (let ((value (use-package-normalize-value label arg))) - (use-package-normalize-paths label (eval value)))) - ((stringp arg) - (let ((path (if (file-name-absolute-p arg) - arg - (expand-file-name arg user-emacs-directory)))) - (list path))) - ((and (not recursed) (listp arg) (listp (cdr arg))) - (mapcar #'(lambda (x) - (car (use-package-normalize-paths label x t))) arg)) - (t - (use-package-error - (concat label " wants a directory path, or list of paths"))))) - -(defun use-package-normalize/:load-path (name keyword args) - (use-package-as-one (symbol-name keyword) args - #'use-package-normalize-paths)) - -(defun use-package-handler/:load-path (name keyword arg rest state) - (let ((body (use-package-process-keywords name rest state))) - (use-package-concat - (mapcar #'(lambda (path) - `(eval-and-compile (add-to-list 'load-path ,path))) arg) - body))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :no-require -;; - -(defun use-package-normalize-predicate (name keyword args) - (if (null args) - t - (use-package-only-one (symbol-name keyword) args - #'use-package-normalize-value))) - -(defalias 'use-package-normalize/:no-require 'use-package-normalize-predicate) - -(defun use-package-handler/:no-require (name keyword arg rest state) - ;; This keyword has no functional meaning. - (use-package-process-keywords name rest - (plist-put state :no-require t))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :preface -;; - -(defun use-package-normalize-form (label args) - "Given a list of forms, return it wrapped in `progn'." - (unless (listp (car args)) - (use-package-error (concat label " wants a sexp or list of sexps"))) - (mapcar #'(lambda (form) - (if (and (consp form) - (eq (car form) 'use-package)) - (macroexpand form) - form)) args)) - -(defun use-package-normalize-forms (name keyword args) - (use-package-normalize-form (symbol-name keyword) args)) - -(defalias 'use-package-normalize/:preface 'use-package-normalize-forms) - -(defun use-package-handler/:preface (name keyword arg rest state) - (let ((body (use-package-process-keywords name rest state))) - (use-package-concat - (when arg - `((eval-and-compile ,@arg))) - body))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :bind, :bind* -;; - -(defsubst use-package-is-pair (x car-pred cdr-pred) - "Return non-nil if X is a cons satisfying the given predicates. -CAR-PRED and CDR-PRED are applied to X's `car' and `cdr', -respectively." - (and (consp x) - (funcall car-pred (car x)) - (funcall cdr-pred (cdr x)))) - -(defun use-package-normalize-pairs - (key-pred val-pred name label arg &optional recursed) - "Normalize a list of pairs. -KEY-PRED and VAL-PRED are predicates recognizing valid keys and -values, respectively. -If RECURSED is non-nil, recurse into sublists." - (cond - ((funcall key-pred arg) - (list (cons arg (use-package-as-symbol name)))) - ((use-package-is-pair arg key-pred val-pred) - (list arg)) - ((and (not recursed) (listp arg) (listp (cdr arg))) - (let (last-item) - (mapcar - #'(lambda (x) - (prog1 - (let ((ret (use-package-normalize-pairs - key-pred val-pred name label x t))) - ;; Currently, the handling of keyword arguments by - ;; `use-package' and `bind-key' is non-uniform and - ;; undocumented. As a result, `use-package-normalize-pairs' - ;; (as it is currently implemented) does not correctly handle - ;; the keyword-argument syntax of `bind-keys'. A permanent - ;; solution to this problem will require a careful - ;; consideration of the desired keyword-argument interface - ;; for `use-package' and `bind-key'. However, in the - ;; meantime, we have a quick patch to fix a serious bug in - ;; the handling of keyword arguments. Namely, the code below - ;; would normally unwrap lists that were passed as keyword - ;; arguments (for example, the `:filter' argument in `:bind') - ;; without the (not (keywordp last-item)) clause. See #447 - ;; for further discussion. - (if (and (listp ret) - (not (keywordp last-item))) - (car ret) - ret)) - (setq last-item x))) arg))) - (t arg))) - -(defun use-package--recognize-function (v &optional binding additional-pred) - "A predicate that recognizes functional constructions: - nil - sym - 'sym - (quote sym) - #'sym - (function sym) - (lambda () ...) - '(lambda () ...) - (quote (lambda () ...)) - #'(lambda () ...) - (function (lambda () ...))" - (pcase v - ((and x (guard (if binding - (symbolp x) - (use-package--non-nil-symbolp x)))) t) - (`(,(or `quote `function) - ,(pred use-package--non-nil-symbolp)) t) - ((and x (guard (if binding (commandp x) (functionp x)))) t) - (_ (and additional-pred - (funcall additional-pred v))))) - -(defun use-package--normalize-function (v) - "Reduce functional constructions to one of two normal forms: - sym - #'(lambda () ...)" - (pcase v - ((pred symbolp) v) - (`(,(or `quote `function) - ,(and sym (pred symbolp))) sym) - (`(lambda . ,_) v) - (`(quote ,(and lam `(lambda . ,_))) lam) - (`(function ,(and lam `(lambda . ,_))) lam) - (_ v))) - -(defun use-package--normalize-commands (args) - "Map over ARGS of the form ((_ . F) ...). -Normalizing functional F's and returning a list of F's -representing symbols (that may need to be autloaded)." - (let ((nargs (mapcar - #'(lambda (x) - (if (consp x) - (cons (car x) - (use-package--normalize-function (cdr x))) - x)) args))) - (cons nargs - (delete - nil (mapcar - #'(lambda (x) - (and (consp x) - (use-package--non-nil-symbolp (cdr x)) - (cdr x))) nargs))))) - -(defun use-package-normalize-binder (name keyword args) - (use-package-as-one (symbol-name keyword) args - (lambda (label arg) - (unless (consp arg) - (use-package-error - (concat label " a ( . )" - " or list of these"))) - (use-package-normalize-pairs - #'(lambda (k) - (pcase k - ((pred stringp) t) - ((pred vectorp) t))) - #'(lambda (v) (use-package--recognize-function v t #'stringp)) - name label arg)))) - -(defalias 'use-package-normalize/:bind 'use-package-normalize-binder) -(defalias 'use-package-normalize/:bind* 'use-package-normalize-binder) - -(defun use-package-handler/:bind - (name keyword args rest state &optional bind-macro) - (cl-destructuring-bind (nargs . commands) - (use-package--normalize-commands args) - (use-package-concat - (use-package-process-keywords name - (use-package-sort-keywords - (use-package-plist-maybe-put rest :defer t)) - (use-package-plist-append state :commands commands)) - `((ignore - (,(if bind-macro bind-macro 'bind-keys) - :package ,name ,@nargs)))))) - -(defun use-package-handler/:bind* (name keyword arg rest state) - (use-package-handler/:bind name keyword arg rest state 'bind-keys*)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :bind-keymap, :bind-keymap* -;; - -(defalias 'use-package-normalize/:bind-keymap 'use-package-normalize-binder) -(defalias 'use-package-normalize/:bind-keymap* 'use-package-normalize-binder) - -;;;###autoload -(defun use-package-autoload-keymap (keymap-symbol package override) - "Loads PACKAGE and then binds the key sequence used to invoke - this function to KEYMAP-SYMBOL. It then simulates pressing the - same key sequence a again, so that the next key pressed is routed - to the newly loaded keymap. - - This function supports use-package's :bind-keymap keyword. It - works by binding the given key sequence to an invocation of this - function for a particular keymap. The keymap is expected to be - defined by the package. In this way, loading the package is - deferred until the prefix key sequence is pressed." - (if (not (require package nil t)) - (use-package-error (format "Cannot load package.el: %s" package)) - (if (and (boundp keymap-symbol) - (keymapp (symbol-value keymap-symbol))) - (let* ((kv (this-command-keys-vector)) - (key (key-description kv)) - (keymap (symbol-value keymap-symbol))) - (if override - (bind-key* key keymap) - (bind-key key keymap)) - (setq unread-command-events - (listify-key-sequence kv))) - (use-package-error - (format "use-package: package.el %s failed to define keymap %s" - package keymap-symbol))))) - -(defun use-package-handler/:bind-keymap - (name keyword arg rest state &optional override) - (let ((form - (mapcar - #'(lambda (binding) - `(,(if override - 'bind-key* - 'bind-key) - ,(car binding) - #'(lambda () - (interactive) - (use-package-autoload-keymap - ',(cdr binding) ',(use-package-as-symbol name) - ,override)))) arg))) - (use-package-concat - (use-package-process-keywords name - (use-package-sort-keywords - (use-package-plist-maybe-put rest :defer t)) - state) - `((ignore ,@form))))) - -(defun use-package-handler/:bind-keymap* (name keyword arg rest state) - (use-package-handler/:bind-keymap name keyword arg rest state t)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :interpreter -;; - -(defun use-package-normalize-mode (name keyword args) - "Normalize arguments for keywords which add regexp/mode pairs to an alist." - (use-package-as-one (symbol-name keyword) args - (apply-partially #'use-package-normalize-pairs - #'use-package-regex-p - #'use-package--recognize-function - name))) - -(defun use-package-handle-mode (name alist args rest state) - "Handle keywords which add regexp/mode pairs to an alist." - (cl-destructuring-bind (nargs . commands) - (use-package--normalize-commands args) - (let ((form - (mapcar - #'(lambda (thing) - `(add-to-list - ',alist - ',(cons (use-package-normalize-regex (car thing)) - (cdr thing)))) - nargs))) - (use-package-concat - (use-package-process-keywords name - (use-package-sort-keywords - (use-package-plist-maybe-put rest :defer t)) - (use-package-plist-append state :commands commands)) - `((ignore ,@form)))))) - -(defalias 'use-package-normalize/:interpreter 'use-package-normalize-mode) - -(defun use-package-handler/:interpreter (name keyword arg rest state) - (use-package-handle-mode name 'interpreter-mode-alist arg rest state)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :mode -;; - -(defalias 'use-package-normalize/:mode 'use-package-normalize-mode) - -(defun use-package-handler/:mode (name keyword arg rest state) - (use-package-handle-mode name 'auto-mode-alist arg rest state)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :magic -;; - -(defalias 'use-package-normalize/:magic 'use-package-normalize-mode) - -(defun use-package-handler/:magic (name keyword arg rest state) - (use-package-handle-mode name 'magic-mode-alist arg rest state)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :magic-fallback -;; - -(defalias 'use-package-normalize/:magic-fallback 'use-package-normalize-mode) - -(defun use-package-handler/:magic-fallback (name keyword arg rest state) - (use-package-handle-mode name 'magic-fallback-mode-alist arg rest state)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :commands -;; - -(defalias 'use-package-normalize/:commands 'use-package-normalize-symlist) - -(defun use-package-handler/:commands (name keyword arg rest state) - ;; The actual processing for commands is done in :defer - (use-package-process-keywords name - (use-package-sort-keywords - (use-package-plist-maybe-put rest :defer t)) - (use-package-plist-append state :commands arg))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :defines -;; - -(defalias 'use-package-normalize/:defines 'use-package-normalize-symlist) - -(defun use-package-handler/:defines (name keyword arg rest state) - (use-package-process-keywords name rest state)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :functions -;; - -(defalias 'use-package-normalize/:functions 'use-package-normalize-symlist) - -(defun use-package-handler/:functions (name keyword arg rest state) - (use-package-process-keywords name rest state)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :defer -;; - -(defalias 'use-package-normalize/:defer 'use-package-normalize-predicate) - -(defun use-package-handler/:defer (name keyword arg rest state) - (let ((body (use-package-process-keywords name rest - (plist-put state :deferred t))) - (name-string (use-package-as-string name))) - (use-package-concat - ;; Load the package after a set amount of idle time, if the argument to - ;; `:defer' was a number. - (when (numberp arg) - `((run-with-idle-timer ,arg nil #'require - ',(use-package-as-symbol name) nil t))) - ;; Since we deferring load, establish any necessary autoloads, and also - ;; keep the byte-compiler happy. - (cl-mapcan - #'(lambda (command) - (when (symbolp command) - (append - `((unless (fboundp ',command) - (autoload #',command ,name-string nil t))) - (when (bound-and-true-p byte-compile-current-file) - `((eval-when-compile - (declare-function ,command ,name-string))))))) - (delete-dups (plist-get state :commands))) - - body))) - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :after -;; - -(defalias 'use-package-normalize/:after 'use-package-normalize-recursive-symlist) - -(defun use-package-require-after-load (features) - "Return form for after any of FEATURES require NAME." - (pcase features - ((and (pred use-package--non-nil-symbolp) feat) - `(lambda (body) - (list 'eval-after-load (list 'quote ',feat) - (list 'quote body)))) - (`(,(or :or :any) . ,rest) - `(lambda (body) - (append (list 'progn) - (mapcar (lambda (form) - (funcall form body)) - (list ,@(use-package-require-after-load rest)))))) - (`(,(or :and :all) . ,rest) - `(lambda (body) - (let ((result body)) - (dolist (form (list ,@(use-package-require-after-load rest))) - (setq result (funcall form result))) - result))) - (`(,feat . ,rest) - (if rest - (cons (use-package-require-after-load feat) - (use-package-require-after-load rest)) - (list (use-package-require-after-load feat)))))) - -(defun use-package-handler/:after (name keyword arg rest state) - (let ((body (use-package-process-keywords name rest - (plist-put state :deferred t))) - (name-string (use-package-as-string name))) - (if (and (consp arg) - (not (memq (car arg) '(:or :any :and :all)))) - (setq arg (cons :all arg))) - (use-package-concat - (when arg - (list (funcall - (use-package-require-after-load arg) - (macroexp-progn - (use-package--require name))))) - body))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :demand -;; - -(defalias 'use-package-normalize/:demand 'use-package-normalize-predicate) - -(defun use-package-handler/:demand (name keyword arg rest state) - (use-package-process-keywords name rest - (use-package-plist-delete state :deferred))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :init -;; - -(defalias 'use-package-normalize/:init 'use-package-normalize-forms) - -(defun use-package-handler/:init (name keyword arg rest state) - (let ((body (use-package-process-keywords name rest state))) - (use-package-concat - ;; The user's initializations - (let ((init-body - (use-package-hook-injector (use-package-as-string name) - :init arg))) - (if use-package-check-before-init - `((if (locate-library ,(use-package-as-string name)) - ,(macroexp-progn init-body))) - init-body)) - body))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :config -;; - -(defalias 'use-package-normalize/:config 'use-package-normalize-forms) - -(defun use-package-handler/:config (name keyword arg rest state) - (let* ((body (use-package-process-keywords name rest state)) - (name-symbol (use-package-as-symbol name)) - (config-body - (if (equal arg '(t)) - body - (use-package--with-elapsed-timer - (format "Configuring package %s" name-symbol) - (use-package-concat - (use-package-hook-injector (symbol-name name-symbol) - :config arg) - body - (list t)))))) - (if (plist-get state :deferred) - (unless (or (null config-body) (equal config-body '(t))) - `((eval-after-load ,(if (symbolp name) `',name name) - ',(macroexp-progn config-body)))) - (use-package--require name (plist-get state ':no-require) - config-body)))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :hook -;; - -(defun use-package-normalize/:hook (name keyword args) - (use-package-as-one (symbol-name keyword) args - (lambda (label arg) - (unless (or (use-package--non-nil-symbolp arg) (consp arg)) - (use-package-error - (concat label " a or ( . )" - " or list of these"))) - (use-package-normalize-pairs - #'(lambda (k) - (or (use-package--non-nil-symbolp k) - (and k (let ((every t)) - (while (and every k) - (if (and (consp k) - (use-package--non-nil-symbolp (car k))) - (setq k (cdr k)) - (setq every nil))) - every)))) - #'use-package--recognize-function - name label arg)))) - -(defun use-package-handler/:hook (name keyword args rest state) - "Generate use-package custom keyword code." - (cl-destructuring-bind (nargs . commands) - (use-package--normalize-commands args) - (use-package-concat - (use-package-process-keywords name - (if commands - (use-package-sort-keywords - (use-package-plist-maybe-put rest :defer t)) - rest) - (if commands - (use-package-plist-append state :commands commands) - state)) - (cl-mapcan - (lambda (def) - (let ((syms (car def)) - (fun (cdr def))) - (when fun - (mapcar - #'(lambda (sym) - `(add-hook (quote ,(intern (format "%s-hook" sym))) - (function ,fun))) - (if (use-package--non-nil-symbolp syms) (list syms) syms))))) - nargs)))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :custom -;; - -(defun use-package-normalize/:custom (name keyword args) - "Normalize use-package custom keyword." - (use-package-as-one (symbol-name keyword) args - (lambda (label arg) - (unless (listp arg) - (use-package-error - (concat label " a ( [comment])" - " or list of these"))) - (if (use-package--non-nil-symbolp (car arg)) - (list arg) - arg)))) - -(defun use-package-handler/:custom (name keyword args rest state) - "Generate use-package custom keyword code." - (let ((body (use-package-process-keywords name rest state))) - (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))) - `(customize-set-variable (quote ,variable) ,value ,comment))) - args) - body))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :custom-face -;; - -(defun use-package-normalize/:custom-face (name-symbol keyword arg) - "Normalize use-package custom-face keyword." - (let ((error-msg (format "%s wants a ( ) or list of these" name-symbol))) - (unless (listp arg) - (use-package-error error-msg)) - (dolist (def arg arg) - (unless (listp def) - (use-package-error error-msg)) - (let ((face (nth 0 def)) - (spec (nth 1 def))) - (when (or (not face) - (not spec) - (> (length arg) 2)) - (use-package-error error-msg)))))) - -(defun use-package-handler/:custom-face (name keyword args rest state) - "Generate use-package custom-face keyword code." - (let ((body (use-package-process-keywords name rest state))) - (use-package-concat - (mapcar (lambda (def) - `(custom-set-faces (quote ,def))) - args) - body))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :diminish -;; - -(defun use-package-normalize-diminish (name label arg &optional recursed) - "Normalize the arguments to diminish down to a list of one of two forms: - SYMBOL - (SYMBOL . STRING)" - (cond - ((not arg) - (list (use-package-as-mode name))) - ((use-package--non-nil-symbolp arg) - (list arg)) - ((stringp arg) - (list (cons (use-package-as-mode name) arg))) - ((and (consp arg) (stringp (cdr arg))) - (list arg)) - ((and (not recursed) (listp arg) (listp (cdr arg))) - (mapcar #'(lambda (x) (car (use-package-normalize-diminish - name label x t))) arg)) - (t - (use-package-error - (concat label " wants a string, symbol, " - "(symbol . string) or list of these"))))) - -(defun use-package-normalize/:diminish (name keyword args) - (use-package-as-one (symbol-name keyword) args - (apply-partially #'use-package-normalize-diminish name) t)) - -(defun use-package-handler/:diminish (name keyword arg rest state) - (let ((body (use-package-process-keywords name rest state))) - (use-package-concat - (mapcar #'(lambda (var) - `(if (fboundp 'diminish) - ,(if (consp var) - `(diminish ',(car var) ,(cdr var)) - `(diminish ',var)))) - arg) - body))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; :delight -;; - -(defun use-package--normalize-delight-1 (name args) - "Normalize ARGS for a single call to `delight'." - (when (eq :eval (car args)) - ;; Handle likely common mistake. - (use-package-error ":delight mode line constructs must be quoted")) - (cond ((and (= (length args) 1) - (use-package--non-nil-symbolp (car args))) - `(,(nth 0 args) nil ,name)) - ((= (length args) 2) - `(,(nth 0 args) ,(nth 1 args) ,name)) - ((= (length args) 3) - args) - (t - (use-package-error - ":delight expects `delight' arguments or a list of them")))) - -(defun use-package-normalize/:delight (name keyword args) - "Normalize arguments to delight." - (cond ((null args) - `((,(use-package-as-mode name) nil ,name))) - ((and (= (length args) 1) - (use-package--non-nil-symbolp (car args))) - `((,(car args) nil ,name))) - ((and (= (length args) 1) - (stringp (car args))) - `((,(use-package-as-mode name) ,(car args) ,name))) - ((and (= (length args) 1) - (listp (car args)) - (eq 'quote (caar args))) - `((,(use-package-as-mode name) ,@(cdar args) ,name))) - ((and (= (length args) 2) - (listp (nth 1 args)) - (eq 'quote (car (nth 1 args)))) - `((,(car args) ,@(cdr (nth 1 args)) ,name))) - (t (mapcar - (apply-partially #'use-package--normalize-delight-1 name) - (if (use-package--non-nil-symbolp (car args)) - (list args) - args))))) - -(defun use-package-handler/:delight (name keyword args rest state) - (let ((body (use-package-process-keywords name rest state))) - (use-package-concat - body - `((if (fboundp 'delight) - (delight '(,@args))))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; The main macro -;; - -;;;###autoload -(defmacro use-package (name &rest args) - "Declare an Emacs package by specifying a group of configuration options. - -For full documentation, please see the README file that came with -this file. Usage: - - (use-package package-name - [:keyword [option]]...) - -:init Code to run before PACKAGE-NAME has been loaded. -:config Code to run after PACKAGE-NAME has been loaded. Note that - if loading is deferred for any reason, this code does not - execute until the lazy load has occurred. -:preface Code to be run before everything except `:disabled'; this - can be used to define functions for use in `:if', or that - should be seen by the byte-compiler. - -:mode Form to be added to `auto-mode-alist'. -:magic Form to be added to `magic-mode-alist'. -:magic-fallback Form to be added to `magic-fallback-mode-alist'. -:interpreter Form to be added to `interpreter-mode-alist'. - -:commands Define autoloads for commands that will be defined by the - package. This is useful if the package is being lazily - loaded, and you wish to conditionally call functions in your - `:init' block that are defined in the package. - -:bind Bind keys, and define autoloads for the bound commands. -:bind* Bind keys, and define autoloads for the bound commands, - *overriding all minor mode bindings*. -:bind-keymap Bind a key prefix to an auto-loaded keymap defined in the - package. This is like `:bind', but for keymaps. -:bind-keymap* Like `:bind-keymap', but overrides all minor mode bindings - -:defer Defer loading of a package -- this is implied when using - `:commands', `:bind', `:bind*', `:mode', `:magic', - `:magic-fallback', or `:interpreter'. This can be an integer, - to force loading after N seconds of idle time, if the package - has not already been loaded. -:after Defer loading of a package until after any of the named - features are loaded. -:demand Prevent deferred loading in all cases. - -:if EXPR Initialize and load only if EXPR evaluates to a non-nil value. -:disabled The package is ignored completely if this keyword is present. -:defines Declare certain variables to silence the byte-compiler. -:functions Declare certain functions to silence the byte-compiler. -: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 `customize-set-variable' with each variable definition. -:custom-face Call `customize-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)) - (unless (member :disabled args) - (let ((name-symbol (if (stringp name) (intern name) name)) - (orig-args args) - (args (use-package-normalize-plist name args))) - (dolist (spec use-package-defaults) - (setq args (if (eval (nth 2 spec)) - (use-package-plist-maybe-put - args (nth 0 spec) (eval (nth 1 spec))) - args))) - - ;; When byte-compiling, pre-load the package so all its symbols are in - ;; scope. - (if (bound-and-true-p byte-compile-current-file) - (setq args - (use-package-plist-append - args :preface - (use-package-concat - (mapcar #'(lambda (var) `(defvar ,var)) - (plist-get args :defines)) - (mapcar #'(lambda (fn) `(declare-function - ,fn ,(use-package-as-string name))) - (plist-get args :functions)) - `((eval-when-compile - (with-demoted-errors - ,(format "Cannot load %s: %%S" name) - ,(if (eq use-package-verbose 'debug) - `(message "Compiling package %s" ',name-symbol)) - ,(unless (plist-get args :no-require) - `(load ,(if (stringp name) - name - (symbol-name name)) nil t))))))))) - - (let ((body - `(progn - ,@(use-package-process-keywords name - (let ((args* - (use-package-sort-keywords - (if (and use-package-always-demand - (not (memq :defer args))) - (plist-put args :demand t) - args)))) - ;; The :demand keyword should not override :after - (if (and (plist-member args* :after) - (plist-member args* :demand)) - (setq args* (use-package-plist-delete args* :demand))) - (when (and use-package-always-ensure - (plist-member args* :load-path) - (not (plist-member orig-args :ensure))) - (plist-put args* :ensure nil)) - (unless (plist-member args* :init) - (plist-put args* :init nil)) - (unless (plist-member args* :config) - (plist-put args* :config '(t))) - args*) - (and use-package-always-defer - (list :deferred t)))))) - (when use-package-debug - (display-buffer - (save-current-buffer - (with-current-buffer (get-buffer-create "*use-package*") - (goto-char (point-max)) - (emacs-lisp-mode) - (insert (pp-to-string body)) - (current-buffer))))) - body)))) - - -(put 'use-package 'lisp-indent-function 'defun) - -(provide 'use-package) - -;; Local Variables: -;; outline-regexp: ";;;\\(;* [^\s\t\n]\\|###autoload\\)\\|(" -;; indent-tabs-mode: nil -;; End: - -;;; use-package.el ends here diff --git a/elpa/use-package-20171215.2248/dir b/elpa/use-package-20171215.2248/dir new file mode 100644 index 0000000..0bb7c7c --- /dev/null +++ b/elpa/use-package-20171215.2248/dir @@ -0,0 +1,18 @@ +This is the file .../info/dir, which contains the +topmost node of the Info hierarchy, called (dir)Top. +The first time you invoke Info you start off looking at this node. + +File: dir, Node: Top This is the top of the INFO tree + + This (the Directory node) gives a menu of major topics. + Typing "q" exits, "?" lists all Info commands, "d" returns here, + "h" gives a primer for first-timers, + "mEmacs" visits the Emacs manual, etc. + + In Emacs, you can click mouse button 2 on a menu item or cross reference + to select it. + +* Menu: + +Emacs +* use-package: (use-package). Declarative package configuration for Emacs. diff --git a/elpa/use-package-20171215.2248/use-package-autoloads.el b/elpa/use-package-20171215.2248/use-package-autoloads.el new file mode 100644 index 0000000..1e125bb --- /dev/null +++ b/elpa/use-package-20171215.2248/use-package-autoloads.el @@ -0,0 +1,209 @@ +;;; use-package-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) + +;;;### (autoloads nil "use-package-bind-key" "use-package-bind-key.el" +;;;;;; (23094 13913 221017 92000)) +;;; Generated autoloads from use-package-bind-key.el + +(autoload 'use-package-autoload-keymap "use-package-bind-key" "\ +Loads PACKAGE and then binds the key sequence used to invoke +this function to KEYMAP-SYMBOL. It then simulates pressing the +same key sequence a again, so that the next key pressed is routed +to the newly loaded keymap. + +This function supports use-package's :bind-keymap keyword. It +works by binding the given key sequence to an invocation of this +function for a particular keymap. The keymap is expected to be +defined by the package. In this way, loading the package is +deferred until the prefix key sequence is pressed. + +\(fn KEYMAP-SYMBOL PACKAGE OVERRIDE)" nil nil) + +(autoload 'use-package-normalize-binder "use-package-bind-key" "\ + + +\(fn NAME KEYWORD ARGS)" nil nil) + +(defalias 'use-package-normalize/:bind 'use-package-normalize-binder) + +(defalias 'use-package-normalize/:bind* 'use-package-normalize-binder) + +(defalias 'use-package-autoloads/:bind 'use-package-autoloads-mode) + +(defalias 'use-package-autoloads/:bind* 'use-package-autoloads-mode) + +(autoload 'use-package-handler/:bind "use-package-bind-key" "\ + + +\(fn NAME KEYWORD ARGS REST STATE &optional BIND-MACRO)" nil nil) + +(defalias 'use-package-normalize/:bind-keymap 'use-package-normalize-binder) + +(defalias 'use-package-normalize/:bind-keymap* 'use-package-normalize-binder) + +(autoload 'use-package-handler/:bind-keymap "use-package-bind-key" "\ + + +\(fn NAME KEYWORD ARGS REST STATE &optional OVERRIDE)" nil nil) + +(autoload 'use-package-handler/:bind-keymap* "use-package-bind-key" "\ + + +\(fn NAME KEYWORD ARG REST STATE)" nil nil) + +;;;*** + +;;;### (autoloads nil "use-package-core" "use-package-core.el" (23094 +;;;;;; 13913 161016 787000)) +;;; Generated autoloads from use-package-core.el + +(autoload 'use-package "use-package-core" "\ +Declare an Emacs package by specifying a group of configuration options. + +For full documentation, please see the README file that came with +this file. Usage: + + (use-package package-name + [:keyword [option]]...) + +:init Code to run before PACKAGE-NAME has been loaded. +:config Code to run after PACKAGE-NAME has been loaded. Note that + if loading is deferred for any reason, this code does not + execute until the lazy load has occurred. +:preface Code to be run before everything except `:disabled'; this + can be used to define functions for use in `:if', or that + should be seen by the byte-compiler. + +:mode Form to be added to `auto-mode-alist'. +:magic Form to be added to `magic-mode-alist'. +:magic-fallback Form to be added to `magic-fallback-mode-alist'. +:interpreter Form to be added to `interpreter-mode-alist'. + +:commands Define autoloads for commands that will be defined by the + package. This is useful if the package is being lazily + loaded, and you wish to conditionally call functions in your + `:init' block that are defined in the package. + +:bind Bind keys, and define autoloads for the bound commands. +:bind* Bind keys, and define autoloads for the bound commands, + *overriding all minor mode bindings*. +:bind-keymap Bind a key prefix to an auto-loaded keymap defined in the + package. This is like `:bind', but for keymaps. +:bind-keymap* Like `:bind-keymap', but overrides all minor mode bindings + +:defer Defer loading of a package -- this is implied when using + `:commands', `:bind', `:bind*', `:mode', `:magic', + `:magic-fallback', or `:interpreter'. This can be an integer, + to force loading after N seconds of idle time, if the package + has not already been loaded. +:after Defer loading of a package until after any of the named + features are loaded. +:demand Prevent deferred loading in all cases. + +:if EXPR Initialize and load only if EXPR evaluates to a non-nil value. +:disabled The package is ignored completely if this keyword is present. +:defines Declare certain variables to silence the byte-compiler. +:functions Declare certain functions to silence the byte-compiler. +: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 `customize-set-variable' with each variable definition. +:custom-face Call `customize-set-faces' with each face definition. +:ensure Loads the package using package.el if necessary. +:pin Pin the package to an archive. + +\(fn NAME &rest ARGS)" nil t) + +(function-put 'use-package 'lisp-indent-function '1) + +;;;*** + +;;;### (autoloads nil "use-package-delight" "use-package-delight.el" +;;;;;; (23094 13913 181016 889000)) +;;; Generated autoloads from use-package-delight.el + +(autoload 'use-package-normalize/:delight "use-package-delight" "\ +Normalize arguments to delight. + +\(fn NAME KEYWORD ARGS)" nil nil) + +(autoload 'use-package-handler/:delight "use-package-delight" "\ + + +\(fn NAME KEYWORD ARGS REST STATE)" nil nil) + +;;;*** + +;;;### (autoloads nil "use-package-diminish" "use-package-diminish.el" +;;;;;; (23094 13913 205017 10000)) +;;; Generated autoloads from use-package-diminish.el + +(autoload 'use-package-normalize/:diminish "use-package-diminish" "\ + + +\(fn NAME KEYWORD ARGS)" nil nil) + +(autoload 'use-package-handler/:diminish "use-package-diminish" "\ + + +\(fn NAME KEYWORD ARG REST STATE)" nil nil) + +;;;*** + +;;;### (autoloads nil "use-package-ensure" "use-package-ensure.el" +;;;;;; (23094 13913 177016 868000)) +;;; Generated autoloads from use-package-ensure.el + +(autoload 'use-package-normalize/:ensure "use-package-ensure" "\ + + +\(fn NAME KEYWORD ARGS)" nil nil) + +(autoload 'use-package-handler/:ensure "use-package-ensure" "\ + + +\(fn NAME KEYWORD ENSURE REST STATE)" nil nil) + +;;;*** + +;;;### (autoloads nil "use-package-jump" "use-package-jump.el" (23094 +;;;;;; 13913 213017 52000)) +;;; Generated autoloads from use-package-jump.el + +(autoload 'use-package-jump-to-package-form "use-package-jump" "\ +Attempt to find and jump to the `use-package' form that loaded +PACKAGE. This will only find the form if that form actually +required PACKAGE. If PACKAGE was previously required then this +function will jump to the file that originally required PACKAGE +instead. + +\(fn PACKAGE)" t nil) + +;;;*** + +;;;### (autoloads nil "use-package-lint" "use-package-lint.el" (23094 +;;;;;; 13913 189016 929000)) +;;; Generated autoloads from use-package-lint.el + +(autoload 'use-package-lint "use-package-lint" "\ +Check for errors in use-package declarations. +For example, if the module's `:if' condition is met, but even +with the specified `:load-path' the module cannot be found. + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil nil ("use-package-pkg.el" "use-package.el") +;;;;;; (23094 13913 209017 32000)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; use-package-autoloads.el ends here diff --git a/elpa/use-package-20171215.2248/use-package-bind-key.el b/elpa/use-package-20171215.2248/use-package-bind-key.el new file mode 100644 index 0000000..d8fe56d --- /dev/null +++ b/elpa/use-package-20171215.2248/use-package-bind-key.el @@ -0,0 +1,169 @@ +;;; use-package-bind-key.el --- Support for the :bind/:bind-keymap keywords + +;; Copyright (C) 2012-2017 John Wiegley + +;; Author: John Wiegley +;; Maintainer: John Wiegley +;; Created: 17 Jun 2012 +;; Modified: 4 Dec 2017 +;; Version: 1.0 +;; Package-Requires: ((emacs "24.3") (use-package "2.4") (bind-key "2.4")) +;; Keywords: dotemacs startup speed config package +;; URL: https://github.com/jwiegley/use-package + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 3, or (at +;; your option) any later version. + +;; This program is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: + +;; Provides support for the :bind, :bind*, :bind-keymap and :bind-keymap* +;; keywords. Note that these are currently still baked into +;; `use-package-keywords' and `use-package-deferring-keywords', although this +;; is harmless if they are never used. + +;;; Code: + +(require 'use-package-core) +(require 'bind-key) + +;;;###autoload +(defun use-package-autoload-keymap (keymap-symbol package override) + "Loads PACKAGE and then binds the key sequence used to invoke +this function to KEYMAP-SYMBOL. It then simulates pressing the +same key sequence a again, so that the next key pressed is routed +to the newly loaded keymap. + +This function supports use-package's :bind-keymap keyword. It +works by binding the given key sequence to an invocation of this +function for a particular keymap. The keymap is expected to be +defined by the package. In this way, loading the package is +deferred until the prefix key sequence is pressed." + (if (not (require package nil t)) + (use-package-error (format "Cannot load package.el: %s" package)) + (if (and (boundp keymap-symbol) + (keymapp (symbol-value keymap-symbol))) + (let* ((kv (this-command-keys-vector)) + (key (key-description kv)) + (keymap (symbol-value keymap-symbol))) + (if override + (bind-key* key keymap) + (bind-key key keymap)) + (setq unread-command-events + (listify-key-sequence kv))) + (use-package-error + (format "package.el %s failed to define keymap %s" + package keymap-symbol))))) + +;;;###autoload +(defun use-package-normalize-binder (name keyword args) + (let ((arg args) + args*) + (while arg + (let ((x (car arg))) + (cond + ;; (KEY . COMMAND) + ((and (consp x) + (or (stringp (car x)) + (vectorp (car x))) + (or (use-package-recognize-function (cdr x) t #'stringp))) + (setq args* (nconc args* (list x))) + (setq arg (cdr arg))) + ;; KEYWORD + ;; :map KEYMAP + ;; :prefix-docstring STRING + ;; :prefix-map SYMBOL + ;; :prefix STRING + ;; :filter SEXP + ;; :menu-name STRING + ((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))) + (eq x :filter) + (and (eq x :menu-name) (stringp (cadr arg)))) + (setq args* (nconc args* (list x (cadr arg)))) + (setq arg (cddr arg))) + ((listp x) + (setq args* + (nconc args* (use-package-normalize-binder name keyword x))) + (setq arg (cdr arg))) + (t + ;; Error! + (use-package-error + (concat (symbol-name name) + " wants arguments acceptable to the `bind-keys' macro," + " or a list of such values")))))) + args*)) + +;;;; :bind, :bind* + +;;;###autoload +(defalias 'use-package-normalize/:bind 'use-package-normalize-binder) +;;;###autoload +(defalias 'use-package-normalize/:bind* 'use-package-normalize-binder) + +;; jww (2017-12-07): This is too simplistic. It will fail to determine +;; autoloads in this situation: +;; (use-package foo +;; :bind (:map foo-map (("C-a" . func)))) +;;;###autoload +(defalias 'use-package-autoloads/:bind 'use-package-autoloads-mode) +;;;###autoload +(defalias 'use-package-autoloads/:bind* 'use-package-autoloads-mode) + +;;;###autoload +(defun use-package-handler/:bind + (name keyword args rest state &optional bind-macro) + (use-package-concat + (use-package-process-keywords name rest state) + `(,@(mapcar + #'(lambda (xs) + `(,(if bind-macro bind-macro 'bind-keys) + :package ,name ,@(use-package-normalize-commands xs))) + (use-package-split-list-at-keys :break args))))) + +(defun use-package-handler/:bind* (name keyword arg rest state) + (use-package-handler/:bind name keyword arg rest state 'bind-keys*)) + +;;;; :bind-keymap, :bind-keymap* + +;;;###autoload +(defalias 'use-package-normalize/:bind-keymap 'use-package-normalize-binder) +;;;###autoload +(defalias 'use-package-normalize/:bind-keymap* 'use-package-normalize-binder) + +;;;###autoload +(defun use-package-handler/:bind-keymap + (name keyword args rest state &optional override) + (use-package-concat + (use-package-process-keywords name rest state) + (mapcar + #'(lambda (binding) + `(,(if override 'bind-key* 'bind-key) + ,(car binding) + #'(lambda () + (interactive) + (use-package-autoload-keymap + ',(cdr binding) ',(use-package-as-symbol name) + ,override)))) + args))) + +;;;###autoload +(defun use-package-handler/:bind-keymap* (name keyword arg rest state) + (use-package-handler/:bind-keymap name keyword arg rest state t)) + +(provide 'use-package-bind-key) + +;;; use-package-bind-key.el ends here diff --git a/elpa/use-package-20171215.2248/use-package-core.el b/elpa/use-package-20171215.2248/use-package-core.el new file mode 100644 index 0000000..dad6859 --- /dev/null +++ b/elpa/use-package-20171215.2248/use-package-core.el @@ -0,0 +1,1528 @@ +;;; use-package-core.el --- A configuration macro for simplifying your .emacs + +;; Copyright (C) 2012-2017 John Wiegley + +;; Author: John Wiegley +;; Maintainer: John Wiegley +;; Created: 17 Jun 2012 +;; Modified: 29 Nov 2017 +;; Version: 2.4 +;; Package-Requires: ((emacs "24.3")) +;; Keywords: dotemacs startup speed config package +;; URL: https://github.com/jwiegley/use-package + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 3, or (at +;; your option) any later version. + +;; This program is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: + +;; The `use-package' declaration macro allows you to isolate package +;; configuration in your ".emacs" in a way that is performance-oriented and, +;; well, just tidy. I created it because I have over 80 packages that I use +;; in Emacs, and things were getting difficult to manage. Yet with this +;; utility my total load time is just under 1 second, with no loss of +;; functionality! +;; +;; Please see README.md from the same repository for documentation. + +;;; Code: + +(require 'bytecomp) +(require 'cl-lib) + +(eval-when-compile + (require 'cl) + (require 'regexp-opt)) + +(defgroup use-package nil + "A use-package declaration for simplifying your `.emacs'." + :group 'startup) + +(defconst use-package-version "2.4" + "This version of use-package.") + +(defcustom use-package-keywords + '(:disabled + :load-path + :requires + :defines + :functions + :preface + :if :when :unless + :no-require + :catch + :after + :custom + :custom-face + :bind + :bind* + :bind-keymap + :bind-keymap* + :interpreter + :mode + :magic + :magic-fallback + :hook + ;; Any other keyword that also declares commands to be autoloaded (such as + ;; :bind) must appear before this keyword. + :commands + :init + :defer + :demand + :load + ;; This must occur almost last; the only forms which should appear after + ;; are those that must happen directly after the config forms. + :config) + "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 +them. Further, attention should be paid to the NEWS.md if the +default order ever changes, as they may have subtle effects on +the semantics of use-package declarations and may necessitate +changing where you had inserted a new keyword earlier. + +Note that `:disabled' is special in this list, as it causes +nothing at all to happen, even if the rest of the use-package +declaration is incorrect." + :type '(repeat symbol) + :group 'use-package) + +(defcustom use-package-deferring-keywords + '(:bind-keymap + :bind-keymap* + :commands) + "Unless `:demand' is used, keywords in this list imply deferred loading. +The reason keywords like `:hook' are not in this list is that +they only imply deferred loading if they reference actual +function symbols that can be autoloaded from the module; whereas +the default keywords provided here always defer loading unless +otherwise requested." + :type '(repeat symbol) + :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' +feature in files that use `use-package', even if these files only +contain compiled expansions of the macros. If you don't do so, +then the expanded macros do their job silently." + :type '(choice (const :tag "Quiet, without catching errors" errors) + (const :tag "Quiet" nil) + (const :tag "Verbose" t) + (const :tag "Debug" debug)) + :group 'use-package) + +(defcustom use-package-check-before-init nil + "If non-nil, check that package exists before executing its `:init' block. +This check is performed by calling `locate-library'." + :type 'boolean + :group 'use-package) + +(defcustom use-package-always-defer nil + "If non-nil, assume `:defer t' unless `:demand' is used. +See also `use-package-defaults', which uses this value." + :type 'boolean + :group 'use-package) + +(defcustom use-package-always-demand nil + "If non-nil, assume `:demand t' unless `:defer' is used. +See also `use-package-defaults', which uses this value." + :type 'boolean + :group 'use-package) + +(defcustom use-package-defaults + '(;; this '(t) has special meaning; see `use-package-handler/:config' + (:config '(t) t) + (:init nil t) + (:catch t (lambda (name args) + (not use-package-expand-minimally))) + (:defer use-package-always-defer + (lambda (name args) + (and use-package-always-defer + (not (plist-member args :defer)) + (not (plist-member args :demand))))) + (:demand use-package-always-demand + (lambda (name args) + (and use-package-always-demand + (not (plist-member args :defer)) + (not (plist-member args :demand)))))) + "Default values for specified `use-package' keywords. +Each entry in the alist is a list of three elements: +The first element is the `use-package' keyword. + +The second is a form that can be evaluated to get the default +value. It can also be a function that will receive the name of +the use-package declaration and the keyword plist given to +`use-package', in normalized form. The value it returns should +also be in normalized form (which is sometimes *not* what one +would normally write in a `use-package' declaration, so use +caution). + +The third element is a form that can be evaluated to determine +whether or not to assign a default value; if it evaluates to nil, +then the default value is not assigned even if the keyword is not +present in the `use-package' form. This third element may also be +a function, in which case it receives the name of the package (as +a symbol) and a list of keywords (in normalized form). It should +return nil or non-nil depending on whether defaulting should be +attempted." + :type `(repeat + (list (choice :tag "Keyword" + ,@(mapcar #'(lambda (k) (list 'const k)) + use-package-keywords)) + (choice :tag "Default value" sexp function) + (choice :tag "Enable if non-nil" sexp function))) + :group 'use-package) + +(defcustom use-package-merge-key-alist + '((:if . (lambda (new old) `(and ,new ,old))) + (:after . (lambda (new old) `(:all ,new ,old))) + (:defer . (lambda (new old) old)) + (:bind . (lambda (new old) (append new (list :break) old)))) + "Alist of keys and the functions used to merge multiple values. +For example, if the following form is provided: + + (use-package foo :if pred1 :if pred2) + +Then based on the above defaults, the merged result will be: + + (use-package foo :if (and pred1 pred2)) + +This is done so that, at the stage of invoking handlers, each +handler is called only once." + :type `(repeat + (cons (choice :tag "Keyword" + ,@(mapcar #'(lambda (k) (list 'const k)) + use-package-keywords) + (const :tag "Any" t)) + function)) + :group 'use-package) + +(defcustom use-package-hook-name-suffix "-hook" + "Text append to the name of hooks mentioned by :hook. +Set to nil if you don't want this to happen; it's only a +convenience." + :type '(choice string (const :tag "No suffix" nil)) + :group 'use-package) + +(defcustom use-package-minimum-reported-time 0.1 + "Minimal load time that will be reported. +Note that `use-package-verbose' has to be set to a non-nil value +for anything to be reported at all." + :type 'number + :group 'use-package) + +(defcustom use-package-inject-hooks nil + "If non-nil, add hooks to the `:init' and `:config' sections. +In particular, for a given package `foo', the following hooks +become available: + + `use-package--foo--pre-init-hook' + `use-package--foo--post-init-hook' + `use-package--foo--pre-config-hook' + `use-package--foo--post-config-hook' + +This way, you can add to these hooks before evaluation of a +`use-package` declaration, and exercise some control over what +happens. + +NOTE: These hooks are run even if the user does not specify an +`:init' or `:config' block, and they will happen at the regular +time when initialization and configuration would have been +performed. + +NOTE: If the `pre-init' hook return a nil value, that block's +user-supplied configuration is not evaluated, so be certain to +return t if you only wish to add behavior to what the user had +specified." + :type 'boolean + :group 'use-package) + +(defcustom use-package-expand-minimally nil + "If non-nil, make the expanded code as minimal as possible. +This disables: + + - Printing to the *Messages* buffer of slowly-evaluating forms + - Capturing of load errors (normally redisplayed as warnings) + - Conditional loading of packages (load failures become errors) + +The main advantage to this variable is that, if you know your +configuration works, it will make the byte-compiled file as +minimal as possible. It can also help with reading macro-expanded +definitions, to understand the main intent of what's happening." + :type 'boolean + :group 'use-package) + +(defcustom use-package-form-regexp-eval + `(concat ,(eval-when-compile + (concat "^\\s-*(" + (regexp-opt '("use-package" "require") t) + "\\s-+\\(")) + (or (bound-and-true-p lisp-mode-symbol-regexp) + "\\(?:\\sw\\|\\s_\\|\\\\.\\)+") "\\)") + "Sexp providing regexp for finding use-package forms in user files. +This is used by `use-package-jump-to-package-form' and +`use-package-enable-imenu-support'." + :type 'sexp + :group 'use-package) + +(defcustom use-package-enable-imenu-support nil + "If non-nil, cause imenu to see `use-package' declarations. +This is done by adjusting `lisp-imenu-generic-expression' to +include support for finding `use-package' and `require' forms. + +Must be set before loading use-package." + :type 'boolean + :set + #'(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))))) + :group 'use-package) + +(defconst use-package-font-lock-keywords + '(("(\\(use-package\\)\\_>[ \t']*\\(\\(?:\\sw\\|\\s_\\)+\\)?" + (1 font-lock-keyword-face) + (2 font-lock-constant-face nil t)))) + +(font-lock-add-keywords 'emacs-lisp-mode use-package-font-lock-keywords) + +(defcustom use-package-compute-statistics nil + "If non-nil, compute statistics concerned use-package declarations. +View the statistical report using `use-package-report'. Note that +if this option is enabled, you must require `use-package' in your +user init file at loadup time, or you will see errors concerning +undefined variables." + :type 'boolean + :group 'use-package) + +(defvar use-package-statistics (make-hash-table)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Utility functions +;; + +(defsubst use-package-error (msg) + "Report MSG as an error, so the user knows it came from this package." + (error "use-package: %s" msg)) + +(defsubst use-package-concat (&rest elems) + "Delete all empty lists from ELEMS (nil or (list nil)), and append them." + (apply #'append (delete nil (delete (list nil) elems)))) + +(defsubst use-package-non-nil-symbolp (sym) + (and sym (symbolp sym))) + +(defsubst use-package-as-symbol (string-or-symbol) + "If STRING-OR-SYMBOL is already a symbol, return it. Otherwise +convert it to a symbol and return that." + (if (symbolp string-or-symbol) string-or-symbol + (intern string-or-symbol))) + +(defsubst use-package-as-string (string-or-symbol) + "If STRING-OR-SYMBOL is already a string, return it. Otherwise +convert it to a string and return that." + (if (stringp string-or-symbol) string-or-symbol + (symbol-name string-or-symbol))) + +(defsubst use-package-regex-p (re) + "Return t if RE is some regexp-like thing." + (or (and (listp re) (eq (car re) 'rx)) + (stringp re))) + +(defun use-package-normalize-regex (re) + "Given some regexp-like thing in RE, resolve to a regular expression." + (cond + ((and (listp re) (eq (car re) 'rx)) (eval re)) + ((stringp re) re) + (t (error "Not recognized as regular expression: %s" re)))) + +(defsubst use-package-is-pair (x car-pred cdr-pred) + "Return non-nil if X is a cons satisfying the given predicates. +CAR-PRED and CDR-PRED are applied to X's `car' and `cdr', +respectively." + (and (consp x) + (funcall car-pred (car x)) + (funcall cdr-pred (cdr x)))) + +(defun use-package-as-mode (string-or-symbol) + "If STRING-OR-SYMBOL ends in `-mode' (or its name does), return +it as a symbol. Otherwise, return it as a symbol with `-mode' +appended." + (let ((string (use-package-as-string string-or-symbol))) + (intern (if (string-match "-mode\\'" string) + string + (concat string "-mode"))))) + +(defsubst use-package-load-name (name &optional noerror) + "Return a form which will load or require NAME. +It does the right thing no matter if NAME is a string or symbol. +Argument NOERROR means to indicate load failures as a warning." + (if (stringp name) + `(load ,name ,noerror) + `(require ',name nil ,noerror))) + +(defun use-package-hook-injector (name-string keyword body) + "Wrap pre/post hook injections around the given BODY for KEYWORD. +The BODY is a list of forms, so `((foo))' if only `foo' is being called." + (if (not use-package-inject-hooks) + body + (let ((keyword-name (substring (format "%s" keyword) 1))) + `((when (run-hook-with-args-until-failure + ',(intern (concat "use-package--" name-string + "--pre-" keyword-name "-hook"))) + ,@body + (run-hooks + ',(intern (concat "use-package--" name-string + "--post-" keyword-name "-hook")))))))) + +(defun use-package-with-elapsed-timer (text body) + "BODY is a list of forms, so `((foo))' if only `foo' is being called." + (declare (indent 1)) + (if use-package-expand-minimally + body + (let ((nowvar (make-symbol "now"))) + (if (bound-and-true-p use-package-verbose) + `((let ((,nowvar (current-time))) + (message "%s..." ,text) + (prog1 + ,(macroexp-progn body) + (let ((elapsed + (float-time (time-subtract (current-time) ,nowvar)))) + (if (> elapsed ,use-package-minimum-reported-time) + (message "%s...done (%.3fs)" ,text elapsed) + (message "%s...done" ,text)))))) + body)))) + +(put 'use-package-with-elapsed-timer 'lisp-indent-function 1) + +(defun use-package-require (name &optional no-require body) + (if use-package-expand-minimally + (use-package-concat + (unless no-require + (list (use-package-load-name name))) + body) + (if no-require + body + (use-package-with-elapsed-timer + (format "Loading package %s" name) + `((if (not ,(use-package-load-name name t)) + (display-warning 'use-package + (format "Cannot load %s" ',name) + :error) + ,@body)))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Property lists +;; + +(defun use-package-plist-delete (plist property) + "Delete PROPERTY from PLIST. +This is in contrast to merely setting it to 0." + (let (p) + (while plist + (if (not (eq property (car plist))) + (setq p (plist-put p (car plist) (nth 1 plist)))) + (setq plist (cddr plist))) + p)) + +(defun use-package-plist-delete-first (plist property) + "Delete PROPERTY from PLIST. +This is in contrast to merely setting it to 0." + (let (p) + (while plist + (if (eq property (car plist)) + (setq p (nconc p (cddr plist)) + plist nil) + (setq p (nconc p (list (car plist) (cadr plist))) + plist (cddr plist)))) + p)) + +(defsubst use-package-plist-maybe-put (plist property value) + "Add a VALUE for PROPERTY to PLIST, if it does not already exist." + (if (plist-member plist property) + plist + (plist-put plist property value))) + +(defsubst use-package-plist-cons (plist property value) + "Cons VALUE onto the head of the list at PROPERTY in PLIST." + (plist-put plist property (cons value (plist-get plist property)))) + +(defsubst use-package-plist-append (plist property value) + "Append VALUE onto the front of the list at PROPERTY in PLIST." + (plist-put plist property (append value (plist-get plist property)))) + +(defun use-package-split-list (pred xs) + (let ((ys (list nil)) (zs (list nil)) flip) + (cl-dolist (x xs) + (if flip + (nconc zs (list x)) + (if (funcall pred x) + (progn + (setq flip t) + (nconc zs (list x))) + (nconc ys (list x))))) + (cons (cdr ys) (cdr zs)))) + +(defun use-package-split-list-at-keys (key lst) + (and lst + (let ((xs (use-package-split-list (apply-partially #'eq key) lst))) + (cons (car xs) (use-package-split-list-at-keys key (cddr xs)))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Keywords +;; + +(defun use-package-keyword-index (keyword) + (cl-loop named outer + with index = 0 + for k in use-package-keywords do + (if (eq k keyword) + (cl-return-from outer index)) + (cl-incf index))) + +(defun use-package-normalize-plist (name input &optional plist merge-function) + "Given a pseudo-plist, normalize it to a regular plist. +The normalized key/value pairs from input are added to PLIST, +extending any keys already present." + (when input + (let* ((keyword (car input)) + (xs (use-package-split-list #'keywordp (cdr input))) + (args (car xs)) + (tail (cdr xs)) + (normalizer + (intern-soft (concat "use-package-normalize/" + (symbol-name keyword)))) + (arg (and (functionp normalizer) + (funcall normalizer name keyword args)))) + (if (memq keyword use-package-keywords) + (progn + (setq plist (use-package-normalize-plist + name tail plist merge-function)) + (plist-put plist keyword + (if (plist-member plist keyword) + (funcall merge-function keyword arg + (plist-get plist keyword)) + arg))) + (use-package-error (format "Unrecognized keyword: %s" keyword)))))) + +(defun use-package-unalias-keywords (name args) + (setq args (cl-nsubstitute :if :when args)) + (let (temp) + (while (setq temp (plist-get args :unless)) + (setq args (use-package-plist-delete-first args :unless) + args (append args `(:if (not ,temp)))))) + args) + +(defun use-package-merge-keys (key new old) + (let ((merger (assq key use-package-merge-key-alist))) + (if merger + (funcall (cdr merger) new old) + (append new old)))) + +(defun use-package-sort-keywords (plist) + (let (plist-grouped) + (while plist + (push (cons (car plist) (cadr plist)) + plist-grouped) + (setq plist (cddr plist))) + (let (result) + (cl-dolist + (x + (nreverse + (sort plist-grouped + #'(lambda (l r) (< (use-package-keyword-index (car l)) + (use-package-keyword-index (car r))))))) + (setq result (cons (car x) (cons (cdr x) result)))) + result))) + +(defun use-package-normalize-keywords (name args) + (let* ((name-symbol (if (stringp name) (intern name) name)) + (name-string (symbol-name name-symbol))) + + ;; Reduce the set of keywords down to its most fundamental expression. + (setq args (use-package-unalias-keywords name-symbol args)) + + ;; Normalize keyword values, coalescing multiple occurrences. + (setq args (use-package-normalize-plist name-symbol args nil + #'use-package-merge-keys)) + + ;; Add default values for keywords not specified, when applicable. + (cl-dolist (spec use-package-defaults) + (when (let ((func (nth 2 spec))) + (if (and func (functionp func)) + (funcall func name args) + (eval func))) + (setq args (use-package-plist-maybe-put + args (nth 0 spec) + (let ((func (nth 1 spec))) + (if (and func (functionp func)) + (funcall func name args) + (eval func))))))) + + ;; Determine any autoloads implied by the keywords used. + (let ((iargs args) + commands) + (while iargs + (when (keywordp (car iargs)) + (let ((autoloads + (intern-soft (concat "use-package-autoloads/" + (symbol-name (car iargs)))))) + (when (functionp autoloads) + (setq commands + ;; jww (2017-12-07): Right now we just ignored the type of + ;; the autoload being requested, and assume they are all + ;; `command'. + (append (mapcar + #'car + (funcall autoloads name-symbol (car iargs) + (cadr iargs))) + commands))))) + (setq iargs (cddr iargs))) + (when commands + (setq args + ;; Like `use-package-plist-append', but removing duplicates. + (plist-put args :commands + (delete-dups + (append commands (plist-get args :commands))))))) + + ;; If byte-compiling, pre-load the package so all its symbols are in + ;; scope. This is done by prepending statements to the :preface. + (when (bound-and-true-p byte-compile-current-file) + (setq args + (use-package-plist-append + args :preface + (use-package-concat + (mapcar #'(lambda (var) `(defvar ,var)) + (plist-get args :defines)) + (mapcar #'(lambda (fn) `(declare-function ,fn ,name-string)) + (plist-get args :functions)) + `((eval-when-compile + (with-demoted-errors + ,(format "Cannot load %s: %%S" name-string) + ,(when (eq use-package-verbose 'debug) + `(message ,(format "Compiling package %s" name-string))) + ,(unless (plist-get args :no-require) + `(load ,name-string nil t))))))))) + + ;; Certain keywords imply :defer, if :demand was not specified. + (when (and (not (plist-member args :demand)) + (not (plist-member args :defer)) + (not (or (equal '(t) (plist-get args :load)) + (equal (list (use-package-as-string name)) + (mapcar #'use-package-as-string + (plist-get args :load))))) + (cl-some #'identity + (mapcar (apply-partially #'plist-member args) + use-package-deferring-keywords))) + (setq args (append args '(:defer t)))) + + ;; The :load keyword overrides :no-require + (when (and (plist-member args :load) + (plist-member args :no-require)) + (setq args (use-package-plist-delete args :no-require))) + + ;; If at this point no :load, :defer or :no-require has been seen, then + ;; :load the package itself. + (when (and (not (plist-member args :load)) + (not (plist-member args :defer)) + (not (plist-member args :no-require))) + (setq args (append args `(:load (,name))))) + + ;; Sort the list of keywords based on the order of `use-package-keywords'. + (use-package-sort-keywords args))) + +(defun use-package-process-keywords (name plist &optional state) + "Process the next keyword in the free-form property list PLIST. +The values in the PLIST have each been normalized by the function +use-package-normalize/KEYWORD (minus the colon). + +STATE is a property list that the function may modify and/or +query. This is useful if a package defines multiple keywords and +wishes them to have some kind of stateful interaction. + +Unless the KEYWORD being processed intends to ignore remaining +keywords, it must call this function recursively, passing in the +plist with its keyword and argument removed, and passing in the +next value for the STATE." + (declare (indent 1)) + (unless (null plist) + (let* ((keyword (car plist)) + (arg (cadr plist)) + (rest (cddr plist))) + (unless (keywordp keyword) + (use-package-error (format "%s is not a keyword" keyword))) + (let* ((handler (concat "use-package-handler/" (symbol-name keyword))) + (handler-sym (intern handler))) + (if (functionp handler-sym) + (funcall handler-sym name keyword arg rest state) + (use-package-error + (format "Keyword handler not defined: %s" handler))))))) + +(put 'use-package-process-keywords 'lisp-indent-function 'defun) + +(defun use-package-list-insert (elem xs &optional anchor after test) + "Insert ELEM into the list XS. +If ANCHOR is also a keyword, place the new KEYWORD before that +one. +If AFTER is non-nil, insert KEYWORD either at the end of the +keywords list, or after the ANCHOR if one has been provided. +If TEST is non-nil, it is the test used to compare ELEM to list +elements. The default is `eq'. +The modified list is returned. The original list is not modified." + (let (result) + (dolist (k xs) + (if (funcall (or test #'eq) k anchor) + (if after + (setq result (cons k result) + result (cons elem result)) + (setq result (cons elem result) + result (cons k result))) + (setq result (cons k result)))) + (if anchor + (nreverse result) + (if after + (nreverse (cons elem result)) + (cons elem (nreverse result)))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Argument Processing +;; + +(defun use-package-only-one (label args f) + "Call F on the first member of ARGS if it has exactly one element." + (declare (indent 1)) + (cond + ((and (listp args) (listp (cdr args)) + (= (length args) 1)) + (funcall f label (car args))) + (t + (use-package-error + (concat label " wants exactly one argument"))))) + +(put 'use-package-only-one 'lisp-indent-function 'defun) + +(defun use-package-as-one (label args f &optional allow-empty) + "Call F on the first element of ARGS if it has one element, or all of ARGS. +If ALLOW-EMPTY is non-nil, it's OK for ARGS to be an empty list." + (declare (indent 1)) + (if (if args + (and (listp args) (listp (cdr args))) + allow-empty) + (if (= (length args) 1) + (funcall f label (car args)) + (funcall f label args)) + (use-package-error + (concat label " wants a non-empty list")))) + +(put 'use-package-as-one 'lisp-indent-function 'defun) + +(defun use-package-memoize (f arg) + "Ensure the macro-expansion of F applied to ARG evaluates ARG +no more than once." + (let ((loaded (cl-gentemp "use-package--loaded")) + (result (cl-gentemp "use-package--result")) + (next (cl-gentemp "use-package--next"))) + `((defvar ,loaded nil) + (defvar ,result nil) + (defvar ,next #'(lambda () (if ,loaded ,result + (setq ,loaded t ,result ,arg)))) + ,@(funcall f `((funcall ,next)))))) + +(defsubst use-package-normalize-value (label arg) + "Normalize the Lisp value given by ARG. +The argument LABEL is ignored." + (cond ((null arg) nil) + ((eq t arg) t) + ((use-package-non-nil-symbolp arg) + `(symbol-value ',arg)) + ((functionp arg) + `(funcall #',arg)) + (t arg))) + +(defun use-package-normalize-symbols (label arg &optional recursed) + "Normalize a list of symbols." + (cond + ((use-package-non-nil-symbolp arg) + (list arg)) + ((and (not recursed) (listp arg) (listp (cdr arg))) + (mapcar #'(lambda (x) (car (use-package-normalize-symbols label x t))) arg)) + (t + (use-package-error + (concat label " wants a symbol, or list of symbols"))))) + +(defun use-package-normalize-symlist (name keyword args) + (use-package-as-one (symbol-name keyword) args + #'use-package-normalize-symbols)) + +(defun use-package-normalize-recursive-symbols (label arg) + "Normalize a list of symbols." + (cond + ((use-package-non-nil-symbolp arg) + arg) + ((and (listp arg) (listp (cdr arg))) + (mapcar #'(lambda (x) (use-package-normalize-recursive-symbols label x)) + arg)) + (t + (use-package-error + (concat label " wants a symbol, or nested list of symbols"))))) + +(defun use-package-normalize-recursive-symlist (name keyword args) + (use-package-as-one (symbol-name keyword) args + #'use-package-normalize-recursive-symbols)) + +(defun use-package-normalize-paths (label arg &optional recursed) + "Normalize a list of filesystem paths." + (cond + ((and arg (or (use-package-non-nil-symbolp arg) (functionp arg))) + (let ((value (use-package-normalize-value label arg))) + (use-package-normalize-paths label (eval value)))) + ((stringp arg) + (let ((path (if (file-name-absolute-p arg) + arg + (expand-file-name arg user-emacs-directory)))) + (list path))) + ((and (not recursed) (listp arg) (listp (cdr arg))) + (mapcar #'(lambda (x) + (car (use-package-normalize-paths label x t))) arg)) + (t + (use-package-error + (concat label " wants a directory path, or list of paths"))))) + +(defun use-package-normalize-predicate (name keyword args) + (if (null args) + t + (use-package-only-one (symbol-name keyword) args + #'use-package-normalize-value))) + +(defun use-package-normalize-form (label args) + "Given a list of forms, return it wrapped in `progn'." + (unless (listp (car args)) + (use-package-error (concat label " wants a sexp or list of sexps"))) + (mapcar #'(lambda (form) + (if (and (consp form) + (memq (car form) + '(use-package bind-key bind-key* + unbind-key bind-keys bind-keys*))) + (macroexpand form) + form)) args)) + +(defun use-package-normalize-forms (name keyword args) + (use-package-normalize-form (symbol-name keyword) args)) + +(defun use-package-normalize-pairs + (key-pred val-pred name label arg &optional recursed) + "Normalize a list of pairs. +KEY-PRED and VAL-PRED are predicates recognizing valid keys and +values, respectively. +If RECURSED is non-nil, recurse into sublists." + (cond + ((funcall key-pred arg) + (list (cons arg (use-package-as-symbol name)))) + ((use-package-is-pair arg key-pred val-pred) + (list arg)) + ((and (not recursed) (listp arg) (listp (cdr arg))) + (let (last-item) + (mapcar + #'(lambda (x) + (prog1 + (let ((ret (use-package-normalize-pairs + key-pred val-pred name label x t))) + (if (and (listp ret) + (not (keywordp last-item))) + (car ret) + ret)) + (setq last-item x))) arg))) + (t arg))) + +(defun use-package-recognize-function (v &optional binding additional-pred) + "A predicate that recognizes functional constructions: + nil + sym + 'sym + (quote sym) + #'sym + (function sym) + (lambda () ...) + '(lambda () ...) + (quote (lambda () ...)) + #'(lambda () ...) + (function (lambda () ...))" + (or (if binding + (symbolp v) + (use-package-non-nil-symbolp v)) + (and (listp v) + (memq (car v) '(quote function)) + (use-package-non-nil-symbolp (cadr v))) + (if binding (commandp v) (functionp v)) + (and additional-pred + (funcall additional-pred v)))) + +(defun use-package-normalize-function (v) + "Reduce functional constructions to one of two normal forms: + sym + #'(lambda () ...)" + (cond ((symbolp v) v) + ((and (listp v) + (memq (car v) '(quote function)) + (use-package-non-nil-symbolp (cadr v))) + (cadr v)) + ((and (consp v) + (eq 'lambda (car v))) + v) + ((and (listp v) + (memq '(quote function) (car v)) + (eq 'lambda (car (cadr v)))) + (cadr v)) + (t v))) + +(defun use-package-normalize-commands (args) + "Map over ARGS of the form ((_ . F) ...), normalizing functional F's." + (mapcar #'(lambda (x) + (if (consp x) + (cons (car x) (use-package-normalize-function (cdr x))) + x)) + args)) + +(defun use-package-normalize-mode (name keyword args) + "Normalize arguments for keywords which add regexp/mode pairs to an alist." + (use-package-as-one (symbol-name keyword) args + (apply-partially #'use-package-normalize-pairs + #'use-package-regex-p + #'use-package-recognize-function + name))) + +(defun use-package-autoloads-mode (name keyword args) + (mapcar + #'(lambda (x) (cons (cdr x) 'command)) + (cl-remove-if-not #'(lambda (x) + (and (consp x) + (use-package-non-nil-symbolp (cdr x)))) + args))) + +(defun use-package-handle-mode (name alist args rest state) + "Handle keywords which add regexp/mode pairs to an alist." + (use-package-concat + (use-package-process-keywords name rest state) + (mapcar + #'(lambda (thing) + `(add-to-list + ',alist + ',(cons (use-package-normalize-regex (car thing)) + (cdr thing)))) + (use-package-normalize-commands args)))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Statistics +;; + +(defun use-package-reset-statistics () + (interactive) + (setq use-package-statistics (make-hash-table))) + +(defun use-package-report () + "Show current statistics gathered about use-package declarations. +In the table that's generated, the status field has the following +meaning: + Configured :config has been processed (the package is loaded!) + Initialized :init has been processed (load status unknown) + Prefaced :preface has been processed + Declared the use-package declaration was seen" + (interactive) + (with-current-buffer (get-buffer-create "*use-package statistics*") + (delete-region (point-min) (point-max)) + (insert "|Package|Status|Last Event|Time|\n") + (insert "|-\n") + (maphash + #'(lambda (key hash) + (insert + (format "|%s |%s|%s |%.2f|\n" key + (cond ((gethash :config hash) "Configured") + ((gethash :init hash) "Initialized") + ((gethash :preface hash) "Prefaced") + ((gethash :use-package hash) "Declared")) + (format-time-string "[%Y-%m-%d %a %H:%M]" + (or (gethash :config hash) + (gethash :init hash) + (gethash :preface hash) + (gethash :use-package hash))) + (+ (float-time (gethash :config-secs hash 0)) + (float-time (gethash :init-secs hash 0)) + (float-time (gethash :preface-secs hash 0)) + (float-time (gethash :use-package-secs hash 0)))))) + use-package-statistics) + (display-buffer (current-buffer)))) + +(defun use-package-statistics-gather (keyword name after) + (let* ((hash (gethash name use-package-statistics + (make-hash-table))) + (before (and after (gethash keyword hash (current-time))))) + (puthash keyword (current-time) hash) + (when after + (puthash (intern (concat (symbol-name keyword) "-secs")) + (time-subtract (current-time) before) hash)) + (puthash name hash use-package-statistics))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Handlers +;; + +;;;; :disabled + +;; Don't alias this to `ignore', as that will cause the resulting +;; function to be interactive. +(defun use-package-normalize/:disabled (name keyword arg)) + +(defun use-package-handler/:disabled (name keyword arg rest state) + (use-package-process-keywords name rest state)) + +;;;; :if, :when and :unless + +(defun use-package-normalize-test (name keyword args) + (use-package-only-one (symbol-name keyword) args + #'use-package-normalize-value)) + +(defalias 'use-package-normalize/:if 'use-package-normalize-test) + +(defun use-package-handler/:if (name keyword pred rest state) + (let ((body (use-package-process-keywords name rest state))) + `((when ,pred ,@body)))) + +(defalias 'use-package-normalize/:when 'use-package-normalize-test) + +(defalias 'use-package-handler/:when 'use-package-handler/:if) + +(defalias 'use-package-normalize/:unless 'use-package-normalize-test) + +(defun use-package-handler/:unless (name keyword pred rest state) + (let ((body (use-package-process-keywords name rest state))) + `((unless ,pred ,@body)))) + +;;;; :requires + +(defalias 'use-package-normalize/:requires 'use-package-normalize-symlist) + +(defun use-package-handler/:requires (name keyword requires rest state) + (let ((body (use-package-process-keywords name rest state))) + (if (null requires) + body + `((when ,(if (> (length requires) 1) + `(not (member nil (mapcar #'featurep ',requires))) + `(featurep ',(car requires))) + ,@body))))) + +;;;; :load-path + +(defun use-package-normalize/:load-path (name keyword args) + (use-package-as-one (symbol-name keyword) args + #'use-package-normalize-paths)) + +(defun use-package-handler/:load-path (name keyword arg rest state) + (let ((body (use-package-process-keywords name rest state))) + (use-package-concat + (mapcar #'(lambda (path) + `(eval-and-compile (add-to-list 'load-path ,path))) + arg) + body))) + +;;;; :no-require + +(defalias 'use-package-normalize/:no-require 'use-package-normalize-predicate) + +(defun use-package-handler/:no-require (name keyword arg rest state) + (use-package-process-keywords name rest state)) + +;;;; :defines + +(defalias 'use-package-normalize/:defines 'use-package-normalize-symlist) + +(defun use-package-handler/:defines (name keyword arg rest state) + (use-package-process-keywords name rest state)) + +;;;; :functions + +(defalias 'use-package-normalize/:functions 'use-package-normalize-symlist) + +(defun use-package-handler/:functions (name keyword arg rest state) + (use-package-process-keywords name rest state)) + +;;;; :preface + +(defalias 'use-package-normalize/:preface 'use-package-normalize-forms) + +(defun use-package-handler/:preface (name keyword arg rest state) + (let ((body (use-package-process-keywords name rest state))) + (use-package-concat + (when use-package-compute-statistics + `((use-package-statistics-gather :preface ',name nil))) + (when arg + `((eval-and-compile ,@arg))) + body + (when use-package-compute-statistics + `((use-package-statistics-gather :preface ',name t)))))) + +;;;; :catch + +(defvar use-package--form) +(defvar use-package--hush-function #'(lambda (keyword body) body)) + +(defsubst use-package-hush (context keyword body) + `((condition-case-unless-debug err + ,(macroexp-progn body) + (error (funcall ,context ,keyword err))))) + +(defun use-package-normalize/:catch (name keyword args) + (if (null args) + t + (use-package-only-one (symbol-name keyword) args + use-package--hush-function))) + +(defun use-package-handler/:catch (name keyword arg rest state) + (let* ((context (cl-gentemp "use-package--warning"))) + (cond + ((not arg) + (use-package-process-keywords name rest state)) + ((eq arg t) + `((defvar ,context + #'(lambda (keyword err) + (let ((msg (format "%s/%s: %s" ',name keyword + (error-message-string err)))) + ,@(when (eq use-package-verbose 'debug) + `((with-current-buffer + (get-buffer-create "*use-package*") + (goto-char (point-max)) + (insert "-----\n" msg ,use-package--form) + (emacs-lisp-mode)) + (setq msg + (concat msg + " (see the *use-package* buffer)")))) + (display-warning 'use-package msg :error)))) + ,@(let ((use-package--hush-function + (apply-partially #'use-package-hush context))) + (funcall use-package--hush-function keyword + (use-package-process-keywords name rest state))))) + ((functionp arg) + `((defvar ,context ,arg) + ,@(let ((use-package--hush-function + (apply-partially #'use-package-hush context))) + (funcall use-package--hush-function keyword + (use-package-process-keywords name rest state))))) + (t + (use-package-error "The :catch keyword expects 't' or a function"))))) + +;;;; :interpreter + +(defalias 'use-package-normalize/:interpreter 'use-package-normalize-mode) +(defalias 'use-package-autoloads/:interpreter 'use-package-autoloads-mode) + +(defun use-package-handler/:interpreter (name keyword arg rest state) + (use-package-handle-mode name 'interpreter-mode-alist arg rest state)) + +;;;; :mode + +(defalias 'use-package-normalize/:mode 'use-package-normalize-mode) +(defalias 'use-package-autoloads/:mode 'use-package-autoloads-mode) + +(defun use-package-handler/:mode (name keyword arg rest state) + (use-package-handle-mode name 'auto-mode-alist arg rest state)) + +;;;; :magic + +(defalias 'use-package-normalize/:magic 'use-package-normalize-mode) +(defalias 'use-package-autoloads/:magic 'use-package-autoloads-mode) + +(defun use-package-handler/:magic (name keyword arg rest state) + (use-package-handle-mode name 'magic-mode-alist arg rest state)) + +;;;; :magic-fallback + +(defalias 'use-package-normalize/:magic-fallback 'use-package-normalize-mode) +(defalias 'use-package-autoloads/:magic-fallback 'use-package-autoloads-mode) + +(defun use-package-handler/:magic-fallback (name keyword arg rest state) + (use-package-handle-mode name 'magic-fallback-mode-alist arg rest state)) + +;;;; :hook + +(defun use-package-normalize/:hook (name keyword args) + (use-package-as-one (symbol-name keyword) args + #'(lambda (label arg) + (unless (or (use-package-non-nil-symbolp arg) (consp arg)) + (use-package-error + (concat label " a or ( . )" + " or list of these"))) + (use-package-normalize-pairs + #'(lambda (k) + (or (use-package-non-nil-symbolp k) + (and k (let ((every t)) + (while (and every k) + (if (and (consp k) + (use-package-non-nil-symbolp (car k))) + (setq k (cdr k)) + (setq every nil))) + every)))) + #'use-package-recognize-function + name label arg)))) + +(defalias 'use-package-autoloads/:hook 'use-package-autoloads-mode) + +(defun use-package-handler/:hook (name keyword args rest state) + "Generate use-package custom keyword code." + (use-package-concat + (use-package-process-keywords name rest state) + (cl-mapcan + #'(lambda (def) + (let ((syms (car def)) + (fun (cdr def))) + (when fun + (mapcar + #'(lambda (sym) + `(add-hook + (quote ,(intern + (concat (symbol-name sym) + use-package-hook-name-suffix))) + (function ,fun))) + (if (use-package-non-nil-symbolp syms) (list syms) syms))))) + (use-package-normalize-commands args)))) + +;;;; :commands + +(defalias 'use-package-normalize/:commands 'use-package-normalize-symlist) + +(defun use-package-handler/:commands (name keyword arg rest state) + (use-package-concat + ;; Since we deferring load, establish any necessary autoloads, and also + ;; keep the byte-compiler happy. + (let ((name-string (use-package-as-string name))) + (cl-mapcan + #'(lambda (command) + (when (symbolp command) + (append + (unless (plist-get state :demand) + `((unless (fboundp ',command) + (autoload #',command ,name-string nil t)))) + (when (bound-and-true-p byte-compile-current-file) + `((eval-when-compile + (declare-function ,command ,name-string))))))) + (delete-dups arg))) + (use-package-process-keywords name rest state))) + +;;;; :defer + +(defalias 'use-package-normalize/:defer 'use-package-normalize-predicate) + +(defun use-package-handler/:defer (name keyword arg rest state) + (let ((body (use-package-process-keywords name rest state))) + (use-package-concat + ;; Load the package after a set amount of idle time, if the argument to + ;; `:defer' was a number. + (when (numberp arg) + `((run-with-idle-timer ,arg nil #'require + ',(use-package-as-symbol name) nil t))) + (if (or (not arg) (null body)) + body + `((eval-after-load ',name ',(macroexp-progn body))))))) + +;;;; :after + +(defun use-package-normalize/:after (name keyword args) + (setq args (use-package-normalize-recursive-symlist name keyword args)) + (if (consp args) + args + (list args))) + +(defun use-package-after-count-uses (features) + "Count the number of time the body would appear in the result." + (cond ((use-package-non-nil-symbolp features) + 1) + ((and (consp features) + (memq (car features) '(:or :any))) + (let ((num 0)) + (cl-dolist (next (cdr features)) + (setq num (+ num (use-package-after-count-uses next)))) + num)) + ((and (consp features) + (memq (car features) '(:and :all))) + (apply #'max (mapcar #'use-package-after-count-uses + (cdr features)))) + ((listp features) + (use-package-after-count-uses (cons :all features))))) + +(defun use-package-require-after-load (features body) + "Generate `eval-after-load' statements to represents FEATURES. +FEATURES is a list containing keywords `:and' and `:all', where +no keyword implies `:all'." + (cond + ((use-package-non-nil-symbolp features) + `((eval-after-load ',features ',(macroexp-progn body)))) + ((and (consp features) + (memq (car features) '(:or :any))) + (cl-mapcan #'(lambda (x) (use-package-require-after-load x body)) + (cdr features))) + ((and (consp features) + (memq (car features) '(:and :all))) + (cl-dolist (next (cdr features)) + (setq body (use-package-require-after-load next body))) + body) + ((listp features) + (use-package-require-after-load (cons :all features) body)))) + +(defun use-package-handler/:after (name keyword arg rest state) + (let ((body (use-package-process-keywords name rest state)) + (uses (use-package-after-count-uses arg))) + (if (or (null uses) (null body)) + body + (if (<= uses 1) + (use-package-require-after-load arg body) + (use-package-memoize + (apply-partially #'use-package-require-after-load arg) + (macroexp-progn body)))))) + +;;;; :demand + +(defalias 'use-package-normalize/:demand 'use-package-normalize-predicate) + +(defun use-package-handler/:demand (name keyword arg rest state) + (use-package-process-keywords name rest state)) + +;;;; :custom + +(defun use-package-normalize/:custom (name keyword args) + "Normalize use-package custom keyword." + (use-package-as-one (symbol-name keyword) args + #'(lambda (label arg) + (unless (listp arg) + (use-package-error + (concat label " a ( [comment])" + " or list of these"))) + (if (use-package-non-nil-symbolp (car arg)) + (list arg) + arg)))) + +(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))) + `(customize-set-variable (quote ,variable) ,value ,comment))) + args) + (use-package-process-keywords name rest state))) + +;;;; :custom-face + +(defun use-package-normalize/:custom-face (name-symbol keyword arg) + "Normalize use-package custom-face keyword." + (let ((error-msg + (format "%s wants a ( ) or list of these" + name-symbol))) + (unless (listp arg) + (use-package-error error-msg)) + (cl-dolist (def arg arg) + (unless (listp def) + (use-package-error error-msg)) + (let ((face (nth 0 def)) + (spec (nth 1 def))) + (when (or (not face) + (not spec) + (> (length arg) 2)) + (use-package-error error-msg)))))) + +(defun use-package-handler/:custom-face (name keyword args rest state) + "Generate use-package custom-face keyword code." + (use-package-concat + (mapcar #'(lambda (def) `(custom-set-faces (quote ,def))) args) + (use-package-process-keywords name rest state))) + +;;;; :init + +(defalias 'use-package-normalize/:init 'use-package-normalize-forms) + +(defun use-package-handler/:init (name keyword arg rest state) + (use-package-concat + (when use-package-compute-statistics + `((use-package-statistics-gather :init ',name nil))) + (let ((init-body + (use-package-hook-injector (use-package-as-string name) + :init arg))) + (when init-body + (funcall use-package--hush-function :init + (if use-package-check-before-init + `((when (locate-library ,(use-package-as-string name)) + ,@init-body)) + init-body)))) + (use-package-process-keywords name rest state) + (when use-package-compute-statistics + `((use-package-statistics-gather :init ',name t))))) + +;;;; :load + +(defun use-package-normalize/:load (name keyword args) + (setq args (use-package-normalize-recursive-symlist name keyword args)) + (if (consp args) + args + (list args))) + +(defun use-package-handler/:load (name keyword arg rest state) + (let ((body (use-package-process-keywords name rest state))) + (cl-dolist (pkg arg) + (setq body (use-package-require (if (eq t pkg) name pkg) nil body))) + body)) + +;;;; :config + +(defalias 'use-package-normalize/:config 'use-package-normalize-forms) + +(defun use-package-handler/:config (name keyword arg rest state) + (let* ((body (use-package-process-keywords name rest state)) + (name-symbol (use-package-as-symbol name))) + (use-package-concat + (when use-package-compute-statistics + `((use-package-statistics-gather :config ',name nil))) + (if (or (null arg) (equal arg '(t))) + body + (use-package-with-elapsed-timer + (format "Configuring package %s" name-symbol) + (funcall use-package--hush-function :config + (use-package-concat + (use-package-hook-injector + (symbol-name name-symbol) :config arg) + body + (list t))))) + (when use-package-compute-statistics + `((use-package-statistics-gather :config ',name t)))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; The main macro +;; + +(defmacro use-package-core (name args) + `(let* ((args* (use-package-normalize-keywords ,name ,args)) + (use-package--form + (if (eq use-package-verbose 'debug) + (concat "\n\n" + (pp-to-string `(use-package ,name ,@,args)) + "\n -->\n\n" + (pp-to-string `(use-package ,name ,@args*)) + "\n ==>\n\n" + (pp-to-string + (macroexp-progn + (let ((use-package-verbose 'errors) + (use-package-expand-minimally t)) + (use-package-process-keywords name args* + (and (plist-get args* :demand) + (list :demand t))))))) + ""))) + (use-package-process-keywords name args* + (and (plist-get args* :demand) + (list :demand t))))) + +;;;###autoload +(defmacro use-package (name &rest args) + "Declare an Emacs package by specifying a group of configuration options. + +For full documentation, please see the README file that came with +this file. Usage: + + (use-package package-name + [:keyword [option]]...) + +:init Code to run before PACKAGE-NAME has been loaded. +:config Code to run after PACKAGE-NAME has been loaded. Note that + if loading is deferred for any reason, this code does not + execute until the lazy load has occurred. +:preface Code to be run before everything except `:disabled'; this + can be used to define functions for use in `:if', or that + should be seen by the byte-compiler. + +:mode Form to be added to `auto-mode-alist'. +:magic Form to be added to `magic-mode-alist'. +:magic-fallback Form to be added to `magic-fallback-mode-alist'. +:interpreter Form to be added to `interpreter-mode-alist'. + +:commands Define autoloads for commands that will be defined by the + package. This is useful if the package is being lazily + loaded, and you wish to conditionally call functions in your + `:init' block that are defined in the package. + +:bind Bind keys, and define autoloads for the bound commands. +:bind* Bind keys, and define autoloads for the bound commands, + *overriding all minor mode bindings*. +:bind-keymap Bind a key prefix to an auto-loaded keymap defined in the + package. This is like `:bind', but for keymaps. +:bind-keymap* Like `:bind-keymap', but overrides all minor mode bindings + +:defer Defer loading of a package -- this is implied when using + `:commands', `:bind', `:bind*', `:mode', `:magic', + `:magic-fallback', or `:interpreter'. This can be an integer, + to force loading after N seconds of idle time, if the package + has not already been loaded. +:after Defer loading of a package until after any of the named + features are loaded. +:demand Prevent deferred loading in all cases. + +:if EXPR Initialize and load only if EXPR evaluates to a non-nil value. +:disabled The package is ignored completely if this keyword is present. +:defines Declare certain variables to silence the byte-compiler. +:functions Declare certain functions to silence the byte-compiler. +: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 `customize-set-variable' with each variable definition. +:custom-face Call `customize-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)) + (unless (memq :disabled args) + (macroexp-progn + (use-package-concat + (when use-package-compute-statistics + `((use-package-statistics-gather :use-package ',name nil))) + (if (eq use-package-verbose 'errors) + (use-package-core name args) + (condition-case-unless-debug err + (use-package-core name args) + (error + (display-warning + 'use-package + (format "Failed to parse package %s: %s" + name (error-message-string err)) :error)))) + (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: +;; indent-tabs-mode: nil +;; End: + +;;; use-package-core.el ends here diff --git a/elpa/use-package-20171215.2248/use-package-delight.el b/elpa/use-package-20171215.2248/use-package-delight.el new file mode 100644 index 0000000..9d4f6ac --- /dev/null +++ b/elpa/use-package-20171215.2248/use-package-delight.el @@ -0,0 +1,91 @@ +;;; use-package-delight.el --- Support for the :delight keyword + +;; Copyright (C) 2012-2017 John Wiegley + +;; Author: John Wiegley +;; Maintainer: John Wiegley +;; Created: 17 Jun 2012 +;; Modified: 3 Dec 2017 +;; Version: 1.0 +;; Package-Requires: ((emacs "24.3") (use-package "2.4")) +;; Keywords: dotemacs startup speed config package +;; URL: https://github.com/jwiegley/use-package + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 3, or (at +;; your option) any later version. + +;; This program is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: + +;; Provides support for the :delight keyword, which is made available by +;; default by requiring `use-package'. + +;;; Code: + +(require 'use-package-core) + +(defun use-package-normalize-delight (name args) + "Normalize ARGS for a single call to `delight'." + (when (eq :eval (car args)) + ;; Handle likely common mistake. + (use-package-error ":delight mode line constructs must be quoted")) + (cond ((and (= (length args) 1) + (use-package-non-nil-symbolp (car args))) + `(,(nth 0 args) nil ,name)) + ((= (length args) 2) + `(,(nth 0 args) ,(nth 1 args) ,name)) + ((= (length args) 3) + args) + (t + (use-package-error + ":delight expects `delight' arguments or a list of them")))) + +;;;###autoload +(defun use-package-normalize/:delight (name keyword args) + "Normalize arguments to delight." + (cond ((null args) + `((,(use-package-as-mode name) nil ,name))) + ((and (= (length args) 1) + (use-package-non-nil-symbolp (car args))) + `((,(car args) nil ,name))) + ((and (= (length args) 1) + (stringp (car args))) + `((,(use-package-as-mode name) ,(car args) ,name))) + ((and (= (length args) 1) + (listp (car args)) + (eq 'quote (caar args))) + `((,(use-package-as-mode name) ,@(cdar args) ,name))) + ((and (= (length args) 2) + (listp (nth 1 args)) + (eq 'quote (car (nth 1 args)))) + `((,(car args) ,@(cdr (nth 1 args)) ,name))) + (t (mapcar + (apply-partially #'use-package-normalize-delight name) + (if (use-package-non-nil-symbolp (car args)) + (list args) + args))))) + +;;;###autoload +(defun use-package-handler/:delight (name keyword args rest state) + (let ((body (use-package-process-keywords name rest state))) + (use-package-concat + body + `((if (fboundp 'delight) + (delight '(,@args))))))) + +(add-to-list 'use-package-keywords :delight t) + +(provide 'use-package-delight) + +;;; use-package-delight.el ends here diff --git a/elpa/use-package-20171215.2248/use-package-diminish.el b/elpa/use-package-20171215.2248/use-package-diminish.el new file mode 100644 index 0000000..c2da622 --- /dev/null +++ b/elpa/use-package-20171215.2248/use-package-diminish.el @@ -0,0 +1,80 @@ +;;; use-package-diminish.el --- Support for the :diminish keyword + +;; Copyright (C) 2012-2017 John Wiegley + +;; Author: John Wiegley +;; Maintainer: John Wiegley +;; Created: 17 Jun 2012 +;; Modified: 3 Dec 2017 +;; Version: 1.0 +;; Package-Requires: ((emacs "24.3") (use-package "2.4")) +;; Keywords: dotemacs startup speed config package +;; URL: https://github.com/jwiegley/use-package + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 3, or (at +;; your option) any later version. + +;; This program is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: + +;; Provides support for the :diminish keyword, which is made available by +;; default by requiring `use-package'. + +;;; Code: + +(require 'use-package-core) + +(defun use-package-normalize-diminish (name label arg &optional recursed) + "Normalize the arguments to diminish down to a list of one of two forms: + SYMBOL + (SYMBOL . STRING)" + (cond + ((not arg) + (list (use-package-as-mode name))) + ((use-package-non-nil-symbolp arg) + (list arg)) + ((stringp arg) + (list (cons (use-package-as-mode name) arg))) + ((and (consp arg) (stringp (cdr arg))) + (list arg)) + ((and (not recursed) (listp arg) (listp (cdr arg))) + (mapcar #'(lambda (x) (car (use-package-normalize-diminish + name label x t))) arg)) + (t + (use-package-error + (concat label " wants a string, symbol, " + "(symbol . string) or list of these"))))) + +;;;###autoload +(defun use-package-normalize/:diminish (name keyword args) + (use-package-as-one (symbol-name keyword) args + (apply-partially #'use-package-normalize-diminish name) t)) + +;;;###autoload +(defun use-package-handler/:diminish (name keyword arg rest state) + (let ((body (use-package-process-keywords name rest state))) + (use-package-concat + (mapcar #'(lambda (var) + `(if (fboundp 'diminish) + ,(if (consp var) + `(diminish ',(car var) ,(cdr var)) + `(diminish ',var)))) + arg) + body))) + +(add-to-list 'use-package-keywords :diminish t) + +(provide 'use-package-diminish) + +;;; use-package-diminish.el ends here diff --git a/elpa/use-package-20171215.2248/use-package-ensure.el b/elpa/use-package-20171215.2248/use-package-ensure.el new file mode 100644 index 0000000..1a76b88 --- /dev/null +++ b/elpa/use-package-20171215.2248/use-package-ensure.el @@ -0,0 +1,214 @@ +;;; use-package-ensure.el --- Support for the :ensure and :pin keywords + +;; Copyright (C) 2012-2017 John Wiegley + +;; Author: John Wiegley +;; Maintainer: John Wiegley +;; Created: 17 Jun 2012 +;; Modified: 3 Dec 2017 +;; Version: 1.0 +;; Package-Requires: ((emacs "24.3") (use-package "2.4")) +;; Keywords: dotemacs startup speed config package +;; URL: https://github.com/jwiegley/use-package + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 3, or (at +;; your option) any later version. + +;; This program is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: + +;; Provides support for the :ensure and :pin keywords, which is made available +;; by default by requiring `use-package'. + +;;; Code: + +(require 'cl-lib) +(require 'use-package-core) + +(defgroup use-package-ensure nil + "Support for :ensure and :pin keywords in use-package declarations." + :group 'use-package) + +(eval-when-compile + (declare-function package-installed-p "package") + (declare-function package-read-all-archive-contents "package" ())) + +(defcustom use-package-always-ensure nil + "Treat every package as though it had specified using `:ensure SEXP'. +See also `use-package-defaults', which uses this value." + :type 'sexp + :group 'use-package-ensure) + +(defcustom use-package-always-pin nil + "Treat every package as though it had specified using `:pin SYM'. +See also `use-package-defaults', which uses this value." + :type 'symbol + :group 'use-package-ensure) + +(defcustom use-package-ensure-function 'use-package-ensure-elpa + "Function that ensures a package is installed. +This function is called with three arguments: the name of the +package declared in the `use-package' form; the arguments passed +to all `:ensure' keywords (always a list, even if only one); and +the current `state' plist created by previous handlers. + +Note that this function is called whenever `:ensure' is provided, +even if it is nil. It is up to the function to decide on the +semantics of the various values for `:ensure'. + +This function should return non-nil if the package is installed. + +The default value uses package.el to install the package." + :type '(choice (const :tag "package.el" use-package-ensure-elpa) + (function :tag "Custom")) + :group 'use-package-ensure) + +;;;; :pin + +(defun use-package-normalize/:pin (name keyword args) + (use-package-only-one (symbol-name keyword) args + #'(lambda (label arg) + (cond + ((stringp arg) arg) + ((use-package-non-nil-symbolp arg) (symbol-name arg)) + (t + (use-package-error + ":pin wants an archive name (a string)")))))) + +(eval-when-compile + (defvar package-pinned-packages) + (defvar package-archives)) + +(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 +manually updated package." + (if (member archive '(manual "manual")) + 't + (let ((valid nil)) + (dolist (pa package-archives) + (when (member archive (list (car pa) (intern (car pa)))) + (setq valid 't))) + valid))) + +(defun use-package-pin-package (package archive) + "Pin PACKAGE to ARCHIVE." + (unless (boundp 'package-pinned-packages) + (setq package-pinned-packages ())) + (let ((archive-symbol (if (symbolp archive) archive (intern archive))) + (archive-name (if (stringp archive) archive (symbol-name archive)))) + (if (use-package-archive-exists-p archive-symbol) + (add-to-list 'package-pinned-packages (cons package archive-name)) + (error "Archive '%s' requested for package '%s' is not available." + archive-name package)) + (unless (bound-and-true-p package--initialized) + (package-initialize t)))) + +(defun use-package-handler/:pin (name keyword archive-name rest state) + (let ((body (use-package-process-keywords name rest state)) + (pin-form (if archive-name + `(use-package-pin-package ',(use-package-as-symbol name) + ,archive-name)))) + ;; Pinning should occur just before ensuring + ;; See `use-package-handler/:ensure'. + (if (bound-and-true-p byte-compile-current-file) + (eval pin-form) ; Eval when byte-compiling, + (push pin-form body)) ; or else wait until runtime. + body)) + +;;;; :ensure + +(defvar package-archive-contents) + +;;;###autoload +(defun use-package-normalize/:ensure (name keyword args) + (if (null args) + (list t) + (use-package-only-one (symbol-name keyword) args + #'(lambda (label arg) + (cond + ((symbolp arg) + (list arg)) + ((and (listp arg) (= 3 (length arg)) + (symbolp (nth 0 arg)) + (eq :pin (nth 1 arg)) + (or (stringp (nth 2 arg)) + (symbolp (nth 2 arg)))) + (list (cons (nth 0 arg) (nth 2 arg)))) + (t + (use-package-error + (concat ":ensure wants an optional package name " + "(an unquoted symbol name), or ( :pin )")))))))) + +(defun use-package-ensure-elpa (name args state &optional no-refresh) + (dolist (ensure args) + (let ((package + (or (and (eq ensure t) (use-package-as-symbol name)) + ensure))) + (when package + (require 'package) + (when (consp package) + (use-package-pin-package (car package) (cdr package)) + (setq package (car package))) + (unless (package-installed-p package) + (condition-case-unless-debug err + (progn + (when (assoc package (bound-and-true-p + package-pinned-packages)) + (package-read-all-archive-contents)) + (if (assoc package package-archive-contents) + (package-install package) + (package-refresh-contents) + (when (assoc package (bound-and-true-p + package-pinned-packages)) + (package-read-all-archive-contents)) + (package-install package)) + t) + (error + (display-warning 'use-package + (format "Failed to install %s: %s" + name (error-message-string err)) + :error)))))))) + +;;;###autoload +(defun use-package-handler/:ensure (name keyword ensure rest state) + (let* ((body (use-package-process-keywords name rest state))) + ;; We want to avoid installing packages when the `use-package' macro is + ;; being macro-expanded by elisp completion (see `lisp--local-variables'), + ;; but still install packages when byte-compiling, to avoid requiring + ;; `package' at runtime. + (if (bound-and-true-p byte-compile-current-file) + ;; Eval when byte-compiling, + (funcall use-package-ensure-function name ensure state) + ;; or else wait until runtime. + (push `(,use-package-ensure-function ',name ',ensure ',state) + body)) + body)) + +(add-to-list 'use-package-defaults + '(:ensure (list use-package-always-ensure) + (lambda (name args) + (and use-package-always-ensure + (not (plist-member args :load-path))))) t) + +(add-to-list 'use-package-defaults + '(:pin use-package-always-pin use-package-always-pin) t) + +(add-to-list 'use-package-keywords :ensure) +(add-to-list 'use-package-keywords :pin) + +(provide 'use-package-ensure) + +;;; use-package-ensure.el ends here diff --git a/elpa/use-package-20171215.2248/use-package-jump.el b/elpa/use-package-20171215.2248/use-package-jump.el new file mode 100644 index 0000000..31d1b05 --- /dev/null +++ b/elpa/use-package-20171215.2248/use-package-jump.el @@ -0,0 +1,79 @@ +;;; use-package-jump.el --- Attempt to jump to a use-package declaration + +;; Copyright (C) 2012-2017 John Wiegley + +;; Author: John Wiegley +;; Maintainer: John Wiegley +;; Created: 17 Jun 2012 +;; Modified: 3 Dec 2017 +;; Version: 1.0 +;; Package-Requires: ((emacs "24.3") (use-package "2.4")) +;; Keywords: dotemacs startup speed config package +;; URL: https://github.com/jwiegley/use-package + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 3, or (at +;; your option) any later version. + +;; This program is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: + +;; Provides the command `M-x use-package-jump-to-package-form', however it +;; only works if the package being jumped to was required during +;; initialization. If it was delay-loaded, it will not work. Improvements are +;; needed. + +;;; Code: + +(require 'use-package-core) + +(defun use-package-find-require (package) + "Find file that required PACKAGE by searching `load-history'. +Returns an absolute file path or nil if none is found." + (catch 'suspect + (dolist (filespec load-history) + (dolist (entry (cdr filespec)) + (when (equal entry (cons 'require package)) + (throw 'suspect (car filespec))))))) + +;;;###autoload +(defun use-package-jump-to-package-form (package) + "Attempt to find and jump to the `use-package' form that loaded +PACKAGE. This will only find the form if that form actually +required PACKAGE. If PACKAGE was previously required then this +function will jump to the file that originally required PACKAGE +instead." + (interactive (list (completing-read "Package: " features))) + (let* ((package (if (stringp package) (intern package) package)) + (requiring-file (use-package-find-require package)) + file location) + (if (null requiring-file) + (user-error "Can't find file requiring file; may have been autoloaded") + (setq file (if (string= (file-name-extension requiring-file) "elc") + (concat (file-name-sans-extension requiring-file) ".el") + requiring-file)) + (when (file-exists-p file) + (find-file-other-window file) + (save-excursion + (goto-char (point-min)) + (setq location + (re-search-forward + (format (eval use-package-form-regexp-eval) package) nil t))) + (if (null location) + (message "No use-package form found.") + (goto-char location) + (beginning-of-line)))))) + +(provide 'use-package-jump) + +;;; use-package-jump.el ends here diff --git a/elpa/use-package-20171215.2248/use-package-lint.el b/elpa/use-package-20171215.2248/use-package-lint.el new file mode 100644 index 0000000..53c6828 --- /dev/null +++ b/elpa/use-package-20171215.2248/use-package-lint.el @@ -0,0 +1,84 @@ +;;; use-package-lint.el --- Attempt to find errors in use-package declarations + +;; Copyright (C) 2012-2017 John Wiegley + +;; Author: John Wiegley +;; Maintainer: John Wiegley +;; Created: 17 Jun 2012 +;; Modified: 3 Dec 2017 +;; Version: 1.0 +;; Package-Requires: ((emacs "24.3") (use-package "2.4")) +;; Keywords: dotemacs startup speed config package +;; URL: https://github.com/jwiegley/use-package + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 3, or (at +;; your option) any later version. + +;; This program is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: + +;; Provides the command `M-x use-package-lint'. + +;;; Code: + +(require 'cl-lib) +(require 'use-package-core) + +(defun use-package-lint-declaration (name plist) + (dolist (path (plist-get plist :load-path)) + (unless (file-exists-p path) + (display-warning + 'use-package + (format "%s :load-path does not exist: %s" + name path) :error))) + + (unless (or (plist-member plist :disabled) + (plist-get plist :no-require) + (locate-library (use-package-as-string name) nil + (plist-get plist :load-path))) + (display-warning + 'use-package + (format "%s module cannot be located" name) :error)) + + ;; (dolist (command (plist-get plist :commands)) + ;; (unless (string= (find-lisp-object-file-name command nil) + ;; (locate-library (use-package-as-string name) nil + ;; (plist-get plist :load-path))) + ;; (display-warning + ;; 'use-package + ;; (format "%s :command is from different path: %s" + ;; name (symbol-name command)) :error))) + ) + +;;;###autoload +(defun use-package-lint () + "Check for errors in use-package declarations. +For example, if the module's `:if' condition is met, but even +with the specified `:load-path' the module cannot be found." + (interactive) + (save-excursion + (goto-char (point-min)) + (let ((re (eval use-package-form-regexp-eval))) + (while (re-search-forward re nil t) + (goto-char (match-beginning 0)) + (let ((decl (read (current-buffer)))) + (when (eq (car decl) 'use-package) + (use-package-lint-declaration + (use-package-as-string (cadr decl)) + (use-package-normalize-keywords + (cadr decl) (cddr decl))))))))) + +(provide 'use-package-lint) + +;;; use-package-lint.el ends here diff --git a/elpa/use-package-20171215.2248/use-package-pkg.el b/elpa/use-package-20171215.2248/use-package-pkg.el new file mode 100644 index 0000000..5bc351d --- /dev/null +++ b/elpa/use-package-20171215.2248/use-package-pkg.el @@ -0,0 +1,8 @@ +(define-package "use-package" "20171215.2248" "A configuration macro for simplifying your .emacs" + '((emacs "24.3") + (bind-key "2.4")) + :url "https://github.com/jwiegley/use-package" :keywords + '("dotemacs" "startup" "speed" "config" "package")) +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/elpa/use-package-20171215.2248/use-package.el b/elpa/use-package-20171215.2248/use-package.el new file mode 100644 index 0000000..5f98db1 --- /dev/null +++ b/elpa/use-package-20171215.2248/use-package.el @@ -0,0 +1,54 @@ +;;; use-package.el --- A configuration macro for simplifying your .emacs + +;; Copyright (C) 2012-2017 John Wiegley + +;; Author: John Wiegley +;; Maintainer: John Wiegley +;; Created: 17 Jun 2012 +;; Modified: 29 Nov 2017 +;; Version: 2.4 +;; Package-Requires: ((emacs "24.3") (bind-key "2.4")) +;; Keywords: dotemacs startup speed config package +;; URL: https://github.com/jwiegley/use-package + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 3, or (at +;; your option) any later version. + +;; This program is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: + +;; The `use-package' declaration macro allows you to isolate package +;; configuration in your ".emacs" in a way that is performance-oriented and, +;; well, just tidy. I created it because I have over 80 packages that I use +;; in Emacs, and things were getting difficult to manage. Yet with this +;; utility my total load time is just under 1 second, with no loss of +;; functionality! +;; +;; Please see README.md from the same repository for documentation. + +;;; Code: + +(require 'use-package-core) + +(require 'use-package-bind-key) +(require 'use-package-diminish) +(require 'use-package-delight) +(require 'use-package-ensure) + +(declare-function use-package-jump-to-package-form "use-package-jump") +(autoload #'use-package-jump-to-package-form "use-package-jump" nil t) + +(provide 'use-package) + +;;; use-package.el ends here diff --git a/elpa/use-package-20171215.2248/use-package.info b/elpa/use-package-20171215.2248/use-package.info new file mode 100644 index 0000000..500ec44 --- /dev/null +++ b/elpa/use-package-20171215.2248/use-package.info @@ -0,0 +1,1043 @@ +This is use-package.info, produced by makeinfo version 5.2 from +use-package.texi. + + Copyright (C) 2012-2017 John Wiegley + + You can redistribute this document and/or modify it under the terms + of the GNU General Public License as published by the Free Software + Foundation, either version 3 of the License, or (at your option) + any later version. + + This document is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. +INFO-DIR-SECTION Emacs +START-INFO-DIR-ENTRY +* use-package: (use-package). Declarative package configuration for Emacs. +END-INFO-DIR-ENTRY + + +File: use-package.info, Node: Top, Next: Introduction, Up: (dir) + +use-package User Manual +*********************** + +use-package is… + + Copyright (C) 2012-2017 John Wiegley + + You can redistribute this document and/or modify it under the terms + of the GNU General Public License as published by the Free Software + Foundation, either version 3 of the License, or (at your option) + any later version. + + This document is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + +* Menu: + +* Introduction:: +* Installation:: +* Getting Started:: +* Keywords:: +* FAQ:: +* Debugging Tools:: +* Command Index:: +* Function Index:: +* Variable Index:: + +— The Detailed Node Listing — + + +Installation + +* Installing from an Elpa Archive:: +* Installing from the Git Repository:: +* Post-Installation Tasks:: + + + + +Keywords + +* ‘:after’: ‘after’. +* ‘:bind-keymap’, ‘:bind-keymap*’: ‘bind-keymap’ ‘bind-keymap*’. +* ‘:bind’, ‘:bind*’: ‘bind’ ‘bind*’. +* ‘:commands’: ‘commands’. +* ‘:preface’, ‘:init’, ‘:config’: ‘preface’ ‘init’ ‘config’. +* ‘:custom’: ‘custom’. +* ‘:custom-face’: ‘custom-face’. +* ‘:defer’, ‘:demand’: ‘defer’ ‘demand’. +* ‘:defines’, ‘:functions’: ‘defines’ ‘functions’. +* ‘:diminish’, ‘:delight’: ‘diminish’ ‘delight’. +* ‘:disabled’: ‘disabled’. +* ‘:ensure’, ‘:pin’: ‘ensure’ ‘pin’. +* ‘:hook’: ‘hook’. +* ‘:if’, ‘:when’, ‘:unless’: ‘if’ ‘when’ ‘unless’. +* ‘:load-path’: ‘load-path’. +* ‘:mode’, ‘:interpreter’: ‘mode’ ‘interpreter’. +* ‘:magic’, ‘:magic-fallback’: ‘magic’ ‘magic-fallback’. +* ‘:no-require’: ‘no-require’. +* ‘:requires’: ‘requires’. + + + +‘:bind’, ‘:bind*’ + +* Binding to local keymaps:: + +FAQ + +* FAQ - How to …?:: +* FAQ - Issues and Errors:: + +FAQ - How to …? + +* This is a question:: + + +FAQ - Issues and Errors + +* This is an issues:: + + +File: use-package.info, Node: Introduction, Next: Installation, Prev: Top, Up: Top + +1 Introduction +************** + +TODO + + +File: use-package.info, Node: Installation, Next: Getting Started, Prev: Introduction, Up: Top + +2 Installation +************** + +use-package can be installed using Emacs’ package manager or manually +from its development repository. + +* Menu: + +* Installing from an Elpa Archive:: +* Installing from the Git Repository:: +* Post-Installation Tasks:: + + +File: use-package.info, Node: Installing from an Elpa Archive, Next: Installing from the Git Repository, Up: Installation + +2.1 Installing from an Elpa Archive +=================================== + +use-package is available from Melpa and Melpa-Stable. If you haven’t +used Emacs’ package manager before, then it is high time you familiarize +yourself with it by reading the documentation in the Emacs manual, see +*note (emacs)Packages::. Then add one of the archives to +‘package-archives’: + + • To use Melpa: + + (require 'package) + (add-to-list 'package-archives + '("melpa" . "http://melpa.org/packages/") t) + + • To use Melpa-Stable: + + (require 'package) + (add-to-list 'package-archives + '("melpa-stable" . "http://stable.melpa.org/packages/") t) + + Once you have added your preferred archive, you need to update the +local package list using: + + M-x package-refresh-contents RET + + Once you have done that, you can install use-package and its +dependencies using: + + M-x package-install RET use-package RET + + Now see *note Post-Installation Tasks::. + + +File: use-package.info, Node: Installing from the Git Repository, Next: Post-Installation Tasks, Prev: Installing from an Elpa Archive, Up: Installation + +2.2 Installing from the Git Repository +====================================== + +First, use Git to clone the use-package repository: + + $ git clone https://github.com/jwiegley/use-package.git ~/.emacs.d/site-lisp/use-package + $ cd ~/.emacs.d/site-lisp/use-package + + Then compile the libraries and generate the info manuals: + + $ make + + You may need to create ‘/path/to/use-package/config.mk’ with the +following content before running ‘make’: + + LOAD_PATH = -L /path/to/use-package + + Finally add this to your init file: + + (add-to-list 'load-path "~/.emacs.d/site-lisp/use-package") + (require 'use-package) + + (with-eval-after-load 'info + (info-initialize) + (add-to-list 'Info-directory-list + "~/.emacs.d/site-lisp/use-package/")) + + Note that elements of ‘load-path’ should not end with a slash, while +those of ‘Info-directory-list’ should. + + Instead of running use-package directly from the repository by adding +it to the ‘load-path’, you might want to instead install it in some +other directory using ‘sudo make install’ and setting ‘load-path’ +accordingly. + + To update use-package use: + + $ git pull + $ make + + At times it might be necessary to run ‘make clean all’ instead. + + To view all available targets use ‘make help’. + + Now see *note Post-Installation Tasks::. + + +File: use-package.info, Node: Post-Installation Tasks, Prev: Installing from the Git Repository, Up: Installation + +2.3 Post-Installation Tasks +=========================== + +After installing use-package you should verify that you are indeed using +the use-package release you think you are using. It’s best to restart +Emacs before doing so, to make sure you are not using an outdated value +for ‘load-path’. + + C-h v use-package-version RET + + should display something like + + use-package-version’s value is "2.4" + + If you are completely new to use-package then see *note Getting +Started::. + + If you run into problems, then please see the *note FAQ::. Also see +the *note Debugging Tools::. + + +File: use-package.info, Node: Getting Started, Next: Keywords, Prev: Installation, Up: Top + +3 Getting Started +***************** + +TODO. For now, see ‘README.md’. + + +File: use-package.info, Node: Keywords, Next: FAQ, Prev: Getting Started, Up: Top + +4 Keywords +********** + +* Menu: + +* ‘:after’: ‘after’. +* ‘:bind-keymap’, ‘:bind-keymap*’: ‘bind-keymap’ ‘bind-keymap*’. +* ‘:bind’, ‘:bind*’: ‘bind’ ‘bind*’. +* ‘:commands’: ‘commands’. +* ‘:preface’, ‘:init’, ‘:config’: ‘preface’ ‘init’ ‘config’. +* ‘:custom’: ‘custom’. +* ‘:custom-face’: ‘custom-face’. +* ‘:defer’, ‘:demand’: ‘defer’ ‘demand’. +* ‘:defines’, ‘:functions’: ‘defines’ ‘functions’. +* ‘:diminish’, ‘:delight’: ‘diminish’ ‘delight’. +* ‘:disabled’: ‘disabled’. +* ‘:ensure’, ‘:pin’: ‘ensure’ ‘pin’. +* ‘:hook’: ‘hook’. +* ‘:if’, ‘:when’, ‘:unless’: ‘if’ ‘when’ ‘unless’. +* ‘:load-path’: ‘load-path’. +* ‘:mode’, ‘:interpreter’: ‘mode’ ‘interpreter’. +* ‘:magic’, ‘:magic-fallback’: ‘magic’ ‘magic-fallback’. +* ‘:no-require’: ‘no-require’. +* ‘:requires’: ‘requires’. + + +File: use-package.info, Node: ‘after’, Next: ‘bind-keymap’ ‘bind-keymap*’, Up: Keywords + +4.1 ‘:after’ +============ + +Sometimes it only makes sense to configure a package after another has +been loaded, because certain variables or functions are not in scope +until that time. This can achieved using an ‘:after’ keyword that +allows a fairly rich description of the exact conditions when loading +should occur. Here is an example: + + (use-package hydra + :load-path "site-lisp/hydra") + + (use-package ivy + :load-path "site-lisp/swiper") + + (use-package ivy-hydra + :after (ivy hydra)) + + In this case, because all of these packages are demand-loaded in the +order they occur, the use of ‘:after’ is not strictly necessary. By +using it, however, the above code becomes order-independent, without an +implicit depedence on the nature of your init file. + + By default, ‘:after (foo bar)’ is the same as ‘:after (:all foo +bar)’, meaning that loading of the given package will not happen until +both ‘foo’ and ‘bar’ have been loaded. Here are some of the other +possibilities: + + :after (foo bar) + :after (:all foo bar) + :after (:any foo bar) + :after (:all (:any foo bar) (:any baz quux)) + :after (:any (:all foo bar) (:all baz quux)) + + When you nest selectors, such as ‘(:any (:all foo bar) (:all baz +quux))’, it means that the package will be loaded when either both ‘foo’ +and ‘bar’ have been loaded, or both ‘baz’ and ‘quux’ have been loaded. + + +File: use-package.info, Node: ‘bind-keymap’ ‘bind-keymap*’, Next: ‘bind’ ‘bind*’, Prev: ‘after’, Up: Keywords + +4.2 ‘:bind-keymap’, ‘:bind-keymap*’ +=================================== + +Normally ‘:bind’ expects that commands are functions that will be +autoloaded from the given package. However, this does not work if one +of those commands is actually a keymap, since keymaps are not functions, +and cannot be autoloaded using Emacs’ ‘autoload’ mechanism. + + To handle this case, ‘use-package’ offers a special, limited variant +of ‘:bind’ called ‘:bind-keymap’. The only difference is that the +"commands" bound to by ‘:bind-keymap’ must be keymaps defined in the +package, rather than command functions. This is handled behind the +scenes by generating custom code that loads the package containing the +keymap, and then re-executes your keypress after the first load, to +reinterpret that keypress as a prefix key. + + For example: + + (use-package projectile + :bind-keymap + ("C-c p" . projectile-command-map) + + +File: use-package.info, Node: ‘bind’ ‘bind*’, Next: ‘commands’, Prev: ‘bind-keymap’ ‘bind-keymap*’, Up: Keywords + +4.3 ‘:bind’, ‘:bind*’ +===================== + +Another common thing to do when loading a module is to bind a key to +primary commands within that module: + + (use-package ace-jump-mode + :bind ("C-." . ace-jump-mode)) + + This does two things: first, it creates an autoload for the +‘ace-jump-mode’ command and defers loading of ‘ace-jump-mode’ until you +actually use it. Second, it binds the key ‘C-.’ to that command. After +loading, you can use ‘M-x describe-personal-keybindings’ to see all such +keybindings you’ve set throughout your ‘.emacs’ file. + + A more literal way to do the exact same thing is: + + (use-package ace-jump-mode + :commands ace-jump-mode + :init + (bind-key "C-." 'ace-jump-mode)) + + When you use the ‘:commands’ keyword, it creates autoloads for those +commands and defers loading of the module until they are used. Since +the ‘:init’ form is always run—even if ‘ace-jump-mode’ might not be on +your system—remember to restrict ‘:init’ code to only what would succeed +either way. + + The ‘:bind’ keyword takes either a cons or a list of conses: + + (use-package hi-lock + :bind (("M-o l" . highlight-lines-matching-regexp) + ("M-o r" . highlight-regexp) + ("M-o w" . highlight-phrase))) + + The ‘:commands’ keyword likewise takes either a symbol or a list of +symbols. + + NOTE: Special keys like ‘tab’ or ‘F1’-‘Fn’ can be written in square +brackets, i.e. ‘[tab]’ instead of ‘"tab"’. The syntax for the +keybindings is similar to the "kbd" syntax: see the Emacs Manual +(https://www.gnu.org/software/emacs/manual/html_node/emacs/Init-Rebinding.html) +for more information. + + Examples: + + (use-package helm + :bind (("M-x" . helm-M-x) + ("M-" . helm-find-files) + ([f10] . helm-buffers-list) + ([S-f10] . helm-recentf))) + +* Menu: + +* Binding to local keymaps:: + + +File: use-package.info, Node: Binding to local keymaps, Up: ‘bind’ ‘bind*’ + +4.3.1 Binding to local keymaps +------------------------------ + +Slightly different from binding a key to a keymap, is binding a key +*within* a local keymap that only exists after the package is loaded. +‘use-package’ supports this with a ‘:map’ modifier, taking the local +keymap to bind to: + + (use-package helm + :bind (:map helm-command-map + ("C-c h" . helm-execute-persistent-action))) + + The effect of this statement is to wait until ‘helm’ has loaded, and +then to bind the key ‘C-c h’ to ‘helm-execute-persistent-action’ within +Helm’s local keymap, ‘helm-mode-map’. + + Multiple uses of ‘:map’ may be specified. Any binding occurring +before the first use of ‘:map’ are applied to the global keymap: + + (use-package term + :bind (("C-c t" . term) + :map term-mode-map + ("M-p" . term-send-up) + ("M-n" . term-send-down) + :map term-raw-map + ("M-o" . other-window) + ("M-p" . term-send-up) + ("M-n" . term-send-down))) + + +File: use-package.info, Node: ‘commands’, Next: ‘preface’ ‘init’ ‘config’, Prev: ‘bind’ ‘bind*’, Up: Keywords + +4.4 ‘:commands’ +=============== + + +File: use-package.info, Node: ‘preface’ ‘init’ ‘config’, Next: ‘custom’, Prev: ‘commands’, Up: Keywords + +4.5 ‘:preface’, ‘:init’, ‘:config’ +================================== + +Here is the simplest ‘use-package’ declaration: + + ;; This is only needed once, near the top of the file + (eval-when-compile + ;; Following line is not needed if use-package.el is in ~/.emacs.d + (add-to-list 'load-path "") + (require 'use-package)) + + (use-package foo) + + This loads in the package ‘foo’, but only if ‘foo’ is available on +your system. If not, a warning is logged to the ‘*Messages*’ buffer. +If it succeeds, a message about ‘"Loading foo"’ is logged, along with +the time it took to load, if it took over 0.1 seconds. + + Use the ‘:init’ keyword to execute code before a package is loaded. +It accepts one or more forms, up until the next keyword: + + (use-package foo + :init + (setq foo-variable t)) + + Similarly, ‘:config’ can be used to execute code after a package is +loaded. In cases where loading is done lazily (see more about +autoloading below), this execution is deferred until after the autoload +occurs: + + (use-package foo + :init + (setq foo-variable t) + :config + (foo-mode 1)) + + As you might expect, you can use ‘:init’ and ‘:config’ together: + + (use-package color-moccur + :commands (isearch-moccur isearch-all) + :bind (("M-s O" . moccur) + :map isearch-mode-map + ("M-o" . isearch-moccur) + ("M-O" . isearch-moccur-all)) + :init + (setq isearch-lazy-highlight t) + :config + (use-package moccur-edit)) + + In this case, I want to autoload the commands ‘isearch-moccur’ and +‘isearch-all’ from ‘color-moccur.el’, and bind keys both at the global +level and within the ‘isearch-mode-map’ (see next section). When the +package is actually loaded (by using one of these commands), +‘moccur-edit’ is also loaded, to allow editing of the ‘moccur’ buffer. + + +File: use-package.info, Node: ‘custom’, Next: ‘custom-face’, Prev: ‘preface’ ‘init’ ‘config’, Up: Keywords + +4.6 ‘:custom’ +============= + +The ‘:custom’ keyword allows customization of package custom variables. + + (use-package comint + :custom + (comint-buffer-maximum-size 20000 "Increase comint buffer size.") + (comint-prompt-read-only t "Make the prompt read only.")) + + The documentation string is not mandatory. + + +File: use-package.info, Node: ‘custom-face’, Next: ‘defer’ ‘demand’, Prev: ‘custom’, Up: Keywords + +4.7 ‘:custom-face’ +================== + +The ‘:custom-face’ keyword allows customization of package custom faces. + + (use-package eruby-mode + :custom-face + (eruby-standard-face ((t (:slant italic))))) + + +File: use-package.info, Node: ‘defer’ ‘demand’, Next: ‘defines’ ‘functions’, Prev: ‘custom-face’, Up: Keywords + +4.8 ‘:defer’, ‘:demand’ +======================= + +In almost all cases you don’t need to manually specify ‘:defer t’. This +is implied whenever ‘:bind’ or ‘:mode’ or ‘:interpreter’ is used. +Typically, you only need to specify ‘:defer’ if you know for a fact that +some other package will do something to cause your package to load at +the appropriate time, and thus you would like to defer loading even +though use-package isn’t creating any autoloads for you. + + You can override package deferral with the ‘:demand’ keyword. Thus, +even if you use ‘:bind’, using ‘:demand’ will force loading to occur +immediately and not establish an autoload for the bound key. + + +File: use-package.info, Node: ‘defines’ ‘functions’, Next: ‘diminish’ ‘delight’, Prev: ‘defer’ ‘demand’, Up: Keywords + +4.9 ‘:defines’, ‘:functions’ +============================ + +Another feature of ‘use-package’ is that it always loads every file that +it can when ‘.emacs’ is being byte-compiled. This helps to silence +spurious warnings about unknown variables and functions. + + However, there are times when this is just not enough. For those +times, use the ‘:defines’ and ‘:functions’ keywords to introduce dummy +variable and function declarations solely for the sake of the +byte-compiler: + + (use-package texinfo + :defines texinfo-section-list + :commands texinfo-mode + :init + (add-to-list 'auto-mode-alist '("\\.texi$" . texinfo-mode))) + + If you need to silence a missing function warning, you can use +‘:functions’: + + (use-package ruby-mode + :mode "\\.rb\\'" + :interpreter "ruby" + :functions inf-ruby-keys + :config + (defun my-ruby-mode-hook () + (require 'inf-ruby) + (inf-ruby-keys)) + + (add-hook 'ruby-mode-hook 'my-ruby-mode-hook)) + + +File: use-package.info, Node: ‘diminish’ ‘delight’, Next: ‘disabled’, Prev: ‘defines’ ‘functions’, Up: Keywords + +4.10 ‘:diminish’, ‘:delight’ +============================ + +‘use-package’ also provides built-in support for the diminish and +delight utilities—if you have them installed. Their purpose is to +remove or change minor mode strings in your mode-line. + + diminish (https://github.com/myrjola/diminish.el) is invoked with the +‘:diminish’ keyword, which is passed either a minor mode symbol, a cons +of the symbol and its replacement string, or just a replacement string, +in which case the minor mode symbol is guessed to be the package name +with "-mode" appended at the end: + + (use-package abbrev + :diminish abbrev-mode + :config + (if (file-exists-p abbrev-file-name) + (quietly-read-abbrev-file))) + + delight (https://elpa.gnu.org/packages/delight.html) is invoked with +the ‘:delight’ keyword, which is passed a minor mode symbol, a +replacement string or quoted mode-line data +(https://www.gnu.org/software/emacs/manual/html_node/elisp/Mode-Line-Data.html) +(in which case the minor mode symbol is guessed to be the package name +with "-mode" appended at the end), both of these, or several lists of +both. If no arguments are provided, the default mode name is hidden +completely. + + ;; Don't show anything for rainbow-mode. + (use-package rainbow-mode + :delight) + + ;; Don't show anything for auto-revert-mode, which doesn't match + ;; its package name. + (use-package autorevert + :delight auto-revert-mode) + + ;; Remove the mode name for projectile-mode, but show the project name. + (use-package projectile + :delight '(:eval (concat " " (projectile-project-name)))) + + ;; Completely hide visual-line-mode and change auto-fill-mode to " AF". + (use-package emacs + :delight + (auto-fill-function " AF") + (visual-line-mode)) + + +File: use-package.info, Node: ‘disabled’, Next: ‘ensure’ ‘pin’, Prev: ‘diminish’ ‘delight’, Up: Keywords + +4.11 ‘:disabled’ +================ + +The ‘:disabled’ keyword can turn off a module you’re having difficulties +with, or stop loading something you’re not using at the present time: + + (use-package ess-site + :disabled + :commands R) + + When byte-compiling your ‘.emacs’ file, disabled declarations are +omitted from the output entirely, to accelerate startup times. + + +File: use-package.info, Node: ‘ensure’ ‘pin’, Next: ‘hook’, Prev: ‘disabled’, Up: Keywords + +4.12 ‘:ensure’, ‘:pin’ +====================== + +You can use ‘use-package’ to load packages from ELPA with ‘package.el’. +This is particularly useful if you share your ‘.emacs’ among several +machines; the relevant packages are downloaded automatically once +declared in your ‘.emacs’. The ‘:ensure’ keyword causes the package(s) +to be installed automatically if not already present on your system (set +‘(setq use-package-always-ensure t)’ if you wish this behavior to be +global for all packages): + + (use-package magit + :ensure t) + + If you need to install a different package from the one named by +‘use-package’, you can specify it like this: + + (use-package tex + :ensure auctex) + + Lastly, when running on Emacs 24.4 or later, use-package can pin a +package to a specific archive, allowing you to mix and match packages +from different archives. The primary use-case for this is preferring +packages from the ‘melpa-stable’ and ‘gnu’ archives, but using specific +packages from ‘melpa’ when you need to track newer versions than what is +available in the ‘stable’ archives is also a valid use-case. + + By default ‘package.el’ prefers ‘melpa’ over ‘melpa-stable’ due to +the versioning ‘(> evil-20141208.623 evil-1.0.9)’, so even if you are +tracking only a single package from ‘melpa’, you will need to tag all +the non-‘melpa’ packages with the appropriate archive. If this really +annoys you, then you can set ‘use-package-always-pin’ to set a default. + + If you want to manually keep a package updated and ignore upstream +updates, you can pin it to ‘manual’, which as long as there is no +repository by that name, will Just Work(tm). + + ‘use-package’ throws an error if you try to pin a package to an +archive that has not been configured using ‘package-archives’ (apart +from the magic ‘manual’ archive mentioned above): + + Archive 'foo' requested for package 'bar' is not available. + + Example: + + (use-package company + :ensure t + :pin melpa-stable) + + (use-package evil + :ensure t) + ;; no :pin needed, as package.el will choose the version in melpa + + (use-package adaptive-wrap + :ensure t + ;; as this package is available only in the gnu archive, this is + ;; technically not needed, but it helps to highlight where it + ;; comes from + :pin gnu) + + (use-package org + :ensure t + ;; ignore org-mode from upstream and use a manually installed version + :pin manual) + + *NOTE*: the ‘:pin’ argument has no effect on emacs versions < 24.4. + + +File: use-package.info, Node: ‘hook’, Next: ‘if’ ‘when’ ‘unless’, Prev: ‘ensure’ ‘pin’, Up: Keywords + +4.13 ‘:hook’ +============ + +The ‘:hook’ keyword allows adding functions onto hooks, here only the +basename of the hook is required. Thus, all of the following are +equivalent: + + (use-package ace-jump-mode + :hook prog-mode) + + (use-package ace-jump-mode + :hook (prog-mode . ace-jump-mode)) + + (use-package ace-jump-mode + :commands ace-jump-mode + :init + (add-hook 'prog-mode-hook #'ace-jump-mode)) + + And likewise, when multiple hooks should be applied, the following +are also equivalent: + + (use-package ace-jump-mode + :hook (prog-mode text-mode)) + + (use-package ace-jump-mode + :hook ((prog-mode text-mode) . ace-jump-mode)) + + (use-package ace-jump-mode + :hook ((prog-mode . ace-jump-mode) + (text-mode . ace-jump-mode))) + + (use-package ace-jump-mode + :commands ace-jump-mode + :init + (add-hook 'prog-mode-hook #'ace-jump-mode) + (add-hook 'text-mode-hook #'ace-jump-mode)) + + The use of ‘:hook’, as with ‘:bind’, ‘:mode’, ‘:interpreter’, etc., +causes the functions being hooked to implicitly be read as ‘:commands’ +(meaning they will establish interactive ‘autoload’ definitions for that +module, if not already defined as functions), and so ‘:defer t’ is also +implied by ‘:hook’. + + +File: use-package.info, Node: ‘if’ ‘when’ ‘unless’, Next: ‘load-path’, Prev: ‘hook’, Up: Keywords + +4.14 ‘:if’, ‘:when’, ‘:unless’ +============================== + +You can use the ‘:if’ keyword to predicate the loading and +initialization of modules. + + For example, I only want ‘edit-server’ running for my main, graphical +Emacs, not for other Emacsen I may start at the command line: + + (use-package edit-server + :if window-system + :init + (add-hook 'after-init-hook 'server-start t) + (add-hook 'after-init-hook 'edit-server-start t)) + + In another example, we can load things conditional on the operating +system: + + (use-package exec-path-from-shell + :if (memq window-system '(mac ns)) + :ensure t + :config + (exec-path-from-shell-initialize)) + + Note that ‘:when’ is provided as an alias for ‘:if’, and ‘:unless +foo’ means the same thing as ‘:if (not foo)’. + + +File: use-package.info, Node: ‘load-path’, Next: ‘mode’ ‘interpreter’, Prev: ‘if’ ‘when’ ‘unless’, Up: Keywords + +4.15 ‘:load-path’ +================= + +If your package needs a directory added to the ‘load-path’ in order to +load, use ‘:load-path’. This takes a symbol, a function, a string or a +list of strings. If the path is relative, it is expanded within +‘user-emacs-directory’: + + (use-package ess-site + :load-path "site-lisp/ess/lisp/" + :commands R) + + Note that when using a symbol or a function to provide a dynamically +generated list of paths, you must inform the byte-compiler of this +definition so the value is available at byte-compilation time. This is +done by using the special form ‘eval-and-compile’ (as opposed to +‘eval-when-compile’). Further, this value is fixed at whatever was +determined during compilation, to avoid looking up the same information +again on each startup: + + (eval-and-compile + (defun ess-site-load-path () + (shell-command "find ~ -path ess/lisp"))) + + (use-package ess-site + :load-path (lambda () (list (ess-site-load-path))) + :commands R) + + +File: use-package.info, Node: ‘mode’ ‘interpreter’, Next: ‘magic’ ‘magic-fallback’, Prev: ‘load-path’, Up: Keywords + +4.16 ‘:mode’, ‘:interpreter’ +============================ + +Similar to ‘:bind’, you can use ‘:mode’ and ‘:interpreter’ to establish +a deferred binding within the ‘auto-mode-alist’ and +‘interpreter-mode-alist’ variables. The specifier to either keyword can +be a cons cell, a list of cons cells, or a string or regexp: + + (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’, ‘:bind*’, ‘:bind-keymap’, +‘:bind-keymap*’, ‘:mode’, or ‘:interpreter’ (all of which imply +‘:defer’; see the docstring for ‘use-package’ for a brief description of +each), you can still defer loading with the ‘:defer’ keyword: + + (use-package ace-jump-mode + :defer t + :init + (autoload 'ace-jump-mode "ace-jump-mode" nil t) + (bind-key "C-." 'ace-jump-mode)) + + This does exactly the same thing as the following: + + (use-package ace-jump-mode + :bind ("C-." . ace-jump-mode)) + + +File: use-package.info, Node: ‘magic’ ‘magic-fallback’, Next: ‘no-require’, Prev: ‘mode’ ‘interpreter’, Up: Keywords + +4.17 ‘:magic’, ‘:magic-fallback’ +================================ + +Similar to ‘:mode‘ and ‘:interpreter‘, you can also use ‘:magic‘ and +‘:magic-fallback‘ to cause certain function to be run if the beginning +of a file matches a given regular expression. The difference between +the two is that ‘:magic-fallback‘ has a lower priority than ‘:mode‘. +For example: + + “‘ elisp (use-package pdf-tools :load-path "site-lisp/pdf-tools/lisp" +:magic ("%PDF" . pdf-view-mode) :config (pdf-tools-install)) “‘ + + This registers an autoloaded command for ‘pdf-view-mode‘, defers +loading of ‘pdf-tools‘, and runs ‘pdf-view-mode‘ if the beginning of a +buffer matches the string ‘"%PDF"‘. + + +File: use-package.info, Node: ‘no-require’, Next: ‘requires’, Prev: ‘magic’ ‘magic-fallback’, Up: Keywords + +4.18 ‘:no-require’ +================== + +Normally, ‘use-package’ will load each package at compile time before +compiling the configuration, to ensure that any necessary symbols are in +scope to satisfy the byte-compiler. At times this can cause problems, +since a package may have special loading requirements, and all that you +want to use ‘use-package’ for is to add a configuration to the +‘eval-after-load’ hook. In such cases, use the ‘:no-require’ keyword: + + (use-package foo + :no-require t + :config + (message "This is evaluated when `foo' is loaded")) + + +File: use-package.info, Node: ‘requires’, Prev: ‘no-require’, Up: Keywords + +4.19 ‘:requires’ +================ + +While the ‘:after’ keyword delays loading until the dependencies are +loaded, the somewhat simpler ‘:requires’ keyword simply never loads the +package if the dependencies are not available at the time the +‘use-package’ declaration is encountered. By "available" in this +context it means that ‘foo’ is available of ‘(featurep 'foo)’ evaulates +to a non-nil value. For example: + + (use-package abbrev + :requires foo) + + This is the same as: + + (use-package abbrev + :if (featurep 'foo)) + + As a convenience, a list of such packages may be specified: + + (use-package abbrev + :requires (foo bar baz)) + + For more complex logic, such as that supported by ‘:after’, simply +use ‘:if’ and the appropriate Lisp expression. + + +File: use-package.info, Node: FAQ, Next: Debugging Tools, Prev: Keywords, Up: Top + +Appendix A FAQ +************** + +The next two nodes lists frequently asked questions. + + Please also use the *note Debugging Tools::. + +* Menu: + +* FAQ - How to …?:: +* FAQ - Issues and Errors:: + + +File: use-package.info, Node: FAQ - How to …?, Next: FAQ - Issues and Errors, Up: FAQ + +A.1 FAQ - How to …? +=================== + +* Menu: + +* This is a question:: + + +File: use-package.info, Node: This is a question, Up: FAQ - How to …? + +A.1.1 This is a question +------------------------ + +This is an answer. + + +File: use-package.info, Node: FAQ - Issues and Errors, Prev: FAQ - How to …?, Up: FAQ + +A.2 FAQ - Issues and Errors +=========================== + +* Menu: + +* This is an issues:: + + +File: use-package.info, Node: This is an issues, Up: FAQ - Issues and Errors + +A.2.1 This is an issues +----------------------- + +This is a description. + + +File: use-package.info, Node: Debugging Tools, Next: Command Index, Prev: FAQ, Up: Top + +B Debugging Tools +***************** + +TODO + + Please also see the *note FAQ::. + + +File: use-package.info, Node: Command Index, Next: Function Index, Prev: Debugging Tools, Up: Top + +Appendix C Command Index +************************ + + +File: use-package.info, Node: Function Index, Next: Variable Index, Prev: Command Index, Up: Top + +Appendix D Function Index +************************* + + +File: use-package.info, Node: Variable Index, Prev: Function Index, Up: Top + +Appendix E Variable Index +************************* + + + +Tag Table: +Node: Top784 +Node: Introduction3024 +Node: Installation3151 +Node: Installing from an Elpa Archive3503 +Node: Installing from the Git Repository4616 +Node: Post-Installation Tasks6152 +Node: Getting Started6865 +Node: Keywords7037 +Node: ‘after’8161 +Node: ‘bind-keymap’ ‘bind-keymap*’9711 +Node: ‘bind’ ‘bind*’10794 +Node: Binding to local keymaps12864 +Node: ‘commands’13967 +Node: ‘preface’ ‘init’ ‘config’14145 +Node: ‘custom’16253 +Node: ‘custom-face’16723 +Node: ‘defer’ ‘demand’17067 +Node: ‘defines’ ‘functions’17909 +Node: ‘diminish’ ‘delight’19090 +Node: ‘disabled’21063 +Node: ‘ensure’ ‘pin’21588 +Node: ‘hook’24342 +Node: ‘if’ ‘when’ ‘unless’25796 +Node: ‘load-path’26772 +Node: ‘mode’ ‘interpreter’27954 +Node: ‘magic’ ‘magic-fallback’29295 +Node: ‘no-require’30170 +Node: ‘requires’30898 +Node: FAQ31797 +Node: FAQ - How to …?32080 +Node: This is a question32250 +Node: FAQ - Issues and Errors32398 +Node: This is an issues32581 +Node: Debugging Tools32736 +Node: Command Index32910 +Node: Function Index33066 +Node: Variable Index33223 + +End Tag Table + + +Local Variables: +coding: utf-8 +End: