Codebase list use-package / 18dc92a
Update upstream source from tag 'upstream/2.4.1' Update to upstream version '2.4.1' with Debian dir f8c053702c3b7d15f67615d55be82e650ee68060 Lev Lamberov 3 years ago
12 changed file(s) with 310 addition(s) and 80 deletion(s). Raw diff Collapse all Expand all
1414 - tar xf emacs-bin-${EMACS_VERSION}.tar.gz -C /
1515 - export EMACS=/tmp/emacs/bin/emacs
1616 - $EMACS --version
17 dist: trusty
17 dist: bionic
1818 addons:
1919 apt:
2020 packages:
2121 - texinfo
22 - libgnutls30
2223 script:
2324 - make
2425 - make test
5252 $(info make test-interactive - run tests interactively)
5353 $(info make emacs-Q - run emacs -Q plus Use-Package)
5454 $(info )
55 $(info Release Managment)
56 $(info =================)
55 $(info Release Management)
56 $(info ==================)
5757 $(info )
5858 $(info make texi - regenerate texi from org)
5959 $(info make stats - regenerate statistics)
00 # Changes
1
2 ## 2.4.1
3
4 This is mostly a bug-fix release:
5
6 - Update the documentation for :custom as per #850
7
8 - Fix broken test due to #850
9
10 - better tests
11
12 - add test for #845
13
14 - Support keymap symbol in bind-key. Fix #845
15
16 - use-package-core.el: use the Emacs set-default function to avoid saving :custom vars twice
17
18 - Fix Travis
19
20 - typo, should be a vector, not a bytecode object
21
22 Solves https://github.com/jwiegley/use-package/issues/842
23
24 - Add special value back again, in case needed for backwards compat
25
26 I don't know why this special value exists, but perhaps old client code uses it.
27
28 The additional `t' in the macro expansion is accidental but not harmful I guess.
29
30 - Even when there's no :config, run any pre/post config hooks
31
32 i.e., following the existing docs for use-package-inject-hooks, these hooks are
33 run:
34
35 use-package--foo--pre-config-hook
36 use-package--foo--post-config-hook
37
38 This should make config customisations more predictable (for example, spacemacs
39 uses these hooks extensively to allow 'layers' to be customised).
40
41 I got rid of the "special" default value for :config, because it doesn't seem to
42 be treated any differently than nil.
43
44 Fixes #785
45
46 - Clarify the documentation for :after
47
48 - add table of contents to README
49
50 - Fix typos
51
52 Typos found with codespell.
53
54 - Fix typos
55
56 - Attempt to explain omit "-hook" better
57
58 - Update tests
59
60 - Switch from `require' to `load' + `featurep'
61
62 - Use `require', not `load', when byte-compiling
63
64 - Make custom-face evaluate elisp.
65
66 Fix #696.
67
68 - Add a line of documentation for (use-pacakage ... :hook).
69
70 - Fix typo in README
71
72 - Fix documentation for defer
73
74 - Add no-query option for pdf-tools-install
75
76 - Fix typo in README
77
78 - Fix all notes in README
79
80 - Mention use-package-ensure in README
81
82 Without requiring `use-package-ensure`, setting `use-package-always-ensure`
83 did not actually work for me.
184
285 ## 2.4
386
175258
176259 - For extension authors, there is a new customization variable
177260 `use-package-merge-key-alist` that specifies how values passed to multiple
178 occurences of the same key should be merged into a single value, during
261 occurrences of the same key should be merged into a single value, during
179262 normalization of the `use-package` declaration into a proper plist. The
180263 default behavior is to simply append the values together (since they are
181264 always normalized to lists).
1010 were getting difficult to manage. Yet with this utility my total load time is
1111 around 2 seconds, with no loss of functionality!
1212
13 Note that `use-package` is **not** a package manager! Although `use-package`
13 **NOTE**: `use-package` is **not** a package manager! Although `use-package`
1414 does have the useful capability to interface with package managers (see
1515 [below](#package-installation)), its primary purpose is for the configuration
1616 and loading of packages.
1717
1818 Notes for users upgrading to 2.x are located [at the bottom](#upgrading-to-2x).
1919
20 - [Installing use-package](#installing-use-package)
21 - [Getting started](#getting-started)
22 - [Key-binding](#key-binding)
23 + [Binding to keymaps](#binding-to-keymaps)
24 + [Binding within local keymaps](#binding-within-local-keymaps)
25 - [Modes and interpreters](#modes-and-interpreters)
26 - [Magic handlers](#magic-handlers)
27 - [Hooks](#hooks)
28 - [Package customization](#package-customization)
29 + [Customizing variables](#customizing-variables)
30 + [Customizing faces](#customizing-faces)
31 - [Notes about lazy loading](#notes-about-lazy-loading)
32 - [Information about package loads](#information-about-package-loads)
33 - [Conditional loading](#conditional-loading)
34 + [Conditional loading before :preface](#conditional-loading-before-preface)
35 + [Loading packages in a sequence](#loading-packages-in-sequence)
36 + [Prevent loading if dependencies are missing](#prevent-loading-if-dependencies-are-missing)
37 - [Byte compiling your .emacs](#byte-compiling-your-emacs)
38 + [Prevent a package from loading at compile-time](#prevent-a-package-from-loading-at-compile-time)
39 - [Extending the load-path](#extending-the-load-path)
40 - [Catching errors during use-package expansion](#catching-errors-during-use-package-expansion)
41 - [Diminishing and delighting minor modes](#diminishing-and-delighting-minor-modes)
42 - [Package installation](#package-installation)
43 + [Usage with other package managers](#usage-with-other-package-managers)
44 - [Gathering Statistics](#gathering-statistics)
45 - [Keyword Extensions](#keyword-extensions)
46 + [use-package-ensure-system-package](#use-package-ensure-system-package)
47 + [use-package-chords](#use-package-chords)
48 + [How to create an extension](#how-to-create-an-extension)
49 + [First step: Add the keyword](#first-step-add-the-keyword)
50 + [Second step: Create a normalizer](#second-step-create-a-normalizer)
51 + [Third step: Create a handler](#third-step-create-a-handler)
52 + [Fourth step: Test it out](#fourth-step-test-it-out)
53 - [Some timing results](#some-timing-results)
54 * [Upgrading to 2.x](#upgrading-to-2x)
55 + [Semantics of :init is now consistent](#semantics-of-init-is-now-consistent)
56 + [:idle has been removed](#idle-has-been-removed)
57 + [:defer now accepts an optional numeric argument](#defer-now-accepts-an-optional-numeric-argument)
58 + [Add :preface, occuring before everything except :disabled](#add-preface-occurring-before-everything-except-disabled)
59 + [Add :functions, for declaring functions to the byte-compiler](#add-functions-for-declaring-functions-to-the-byte-compiler)
60 + [use-package.el is no longer needed at runtime](#use-packageel-is-no-longer-needed-at-runtime)
2061 ## Installing use-package
2162
2263 Either clone from this GitHub repository or install from
122163
123164 The `:commands` keyword likewise takes either a symbol or a list of symbols.
124165
125 NOTE: Inside strings, special keys like `tab` or `F1`-`Fn` have to be written inside angle brackets, e.g. `"C-<up>"`.
166 **NOTE**: inside strings, special keys like `tab` or `F1`-`Fn` have to be written inside angle brackets, e.g. `"C-<up>"`.
126167 Standalone special keys (and some combinations) can be written in square brackets, e.g. `[tab]` instead of `"<tab>"`. The syntax for the keybindings is similar to
127168 the "kbd" syntax: see [https://www.gnu.org/software/emacs/manual/html_node/emacs/Init-Rebinding.html](https://www.gnu.org/software/emacs/manual/html_node/emacs/Init-Rebinding.html)
128169 for more information.
251292 :load-path "site-lisp/pdf-tools/lisp"
252293 :magic ("%PDF" . pdf-view-mode)
253294 :config
254 (pdf-tools-install))
295 (pdf-tools-install :no-query))
255296 ```
256297
257298 This registers an autoloaded command for `pdf-view-mode`, defers loading of
260301
261302 ## Hooks
262303
263 The `:hook` keyword allows adding functions onto hooks, here only the basename
264 of the hook is required. Thus, all of the following are equivalent:
304 The `:hook` keyword allows adding functions onto package hooks. Thus,
305 all of the following are equivalent:
265306
266307 ``` elisp
267308 (use-package ace-jump-mode
297338 (add-hook 'text-mode-hook #'ace-jump-mode))
298339 ```
299340
341 When using `:hook` omit the "-hook" suffix if you specify the hook
342 explicitly, as this is appended by default. For example the following
343 code will not work as it attempts to add to the `prog-mode-hook-hook`
344 which does not exist:
345
346 ``` elisp
347 ;; DOES NOT WORK
348 (use-package ace-jump-mode
349 :hook (prog-mode-hook . ace-jump-mode))
350 ```
351
352 If you do not like this behaviour, set `use-package-hook-name-suffix`
353 to nil. By default the value of this variable is "-hook".
354
300355 The use of `:hook`, as with `:bind`, `:mode`, `:interpreter`, etc., causes the
301356 functions being hooked to implicitly be read as `:commands` (meaning they will
302357 establish interactive `autoload` definitions for that module, if not already
317372
318373 The documentation string is not mandatory.
319374
320 **NOTE**: These are only for people who wish to keep customizations with their
375 **NOTE**: these are only for people who wish to keep customizations with their
321376 accompanying use-package declarations. Functionally, the only benefit over
322377 using `setq` in a `:config` block is that customizations might execute code
323 when values are assigned. If you currently use `M-x customize-option` and save
324 to a settings file, you do not want to use this option.
378 when values are assigned.
379
380 **NOTE**: The customized values are **not** saved in the Emacs `custom-file`.
381 Thus you should either use the `:custom` option **or** you should use `M-x
382 customize-option` which will save customized values in the Emacs `custom-file`.
383 Do not use both.
325384
326385 ### Customizing faces
327386
399458 When byte-compiling your `.emacs` file, disabled declarations are omitted
400459 from the output entirely, to accelerate startup times.
401460
402 Note that `:when` is provided as an alias for `:if`, and `:unless foo` means
461 **NOTE**: `:when` is provided as an alias for `:if`, and `:unless foo` means
403462 the same thing as `:if (not foo)`. For example, the following will also stop
404463 `:ensure` from happening on Mac systems:
405464
457516 means that the package will be loaded when either both `foo` and `bar` have
458517 been loaded, or both `baz` and `quux` have been loaded.
459518
460 Note: Pay attention if you set `use-package-always-defer` to t, and also use
519 **NOTE**: pay attention if you set `use-package-always-defer` to t, and also use
461520 the `:after` keyword, as you will need to specify how the declared package is
462 to be loaded: e.g., by some `:bind`. If you're not using one of tho mechanisms
521 to be loaded: e.g., by some `:bind`. If you're not using one of the mechanisms
463522 that registers autoloads, such as `:bind` or `:hook`, and your package manager
464523 does not provide autoloads, it's possible that without adding `:demand t` to
465524 those declarations, your package will never be loaded.
470529 the somewhat simpler `:requires` keyword simply never loads the package if the
471530 dependencies are not available at the time the `use-package` declaration is
472531 encountered. By "available" in this context it means that `foo` is available
473 of `(featurep 'foo)` evaulates to a non-nil value. For example:
532 if `(featurep 'foo)` evaluates to a non-nil value. For example:
474533
475534 ``` elisp
476535 (use-package abbrev
556615 :commands R)
557616 ```
558617
559 Note that when using a symbol or a function to provide a dynamically generated
618 **NOTE**: when using a symbol or a function to provide a dynamically generated
560619 list of paths, you must inform the byte-compiler of this definition so the
561620 value is available at byte-compilation time. This is done by using the
562621 special form `eval-and-compile` (as opposed to `eval-when-compile`). Further,
668727 is particularly useful if you share your `.emacs` among several machines; the
669728 relevant packages are downloaded automatically once declared in your `.emacs`.
670729 The `:ensure` keyword causes the package(s) to be installed automatically if
671 not already present on your system (set `(setq use-package-always-ensure t)`
672 if you wish this behavior to be global for all packages):
730 not already present on your system:
673731
674732 ``` elisp
675733 (use-package magit
684742 :ensure auctex)
685743 ```
686744
687 Note that `:ensure` will install a package if it is not already installed, but
745 Enable `use-package-always-ensure` if you wish this behavior to be global
746 for all packages:
747
748 ``` elisp
749 (require 'use-package-ensure)
750 (setq use-package-always-ensure t)
751 ```
752
753 **NOTE**: `:ensure` will install a package if it is not already installed, but
688754 it does not keep it up-to-date. If you want to keep your packages updated
689755 automatically, one option is to use
690756 [auto-package-update](https://github.com/rranelli/auto-package-update.el),
803869 This will expect a global binary package to exist called `rg`. If it
804870 does not, it will use your system package manager (using the package
805871 [`system-packages`](https://gitlab.com/jabranham/system-packages)) to
806 attempt an install of a binary by the same name asyncronously. For
872 attempt an install of a binary by the same name asynchronously. For
807873 example, for most `macOS` users this would call: `brew install rg`.
808874
809875 If the package is named differently than the binary, you can use a
10261092 It's possible that the user could use `featurep` in their idle to test for
10271093 this case, but that's a subtlety I'd rather avoid.
10281094
1029 ## :defer now accepts an optional integer argument
1095 ## :defer now accepts an optional numeric argument
10301096
10311097 `:defer [N]` causes the package to be loaded -- if it has not already been --
10321098 after `N` seconds of idle time.
10481114 definitions are unknown because you have them within a guard block), and 2)
10491115 allow you to define code that can be used in an `:if` test.
10501116
1051 Note that whatever is specified within `:preface` is evaluated both at load
1117 **NOTE**: whatever is specified within `:preface` is evaluated both at load
10521118 time and at byte-compilation time, in order to ensure that definitions are
10531119 seen by both the Lisp evaluator and the byte-compiler, so you should avoid
10541120 having any side-effects in your preface, and restrict it merely to symbol
9393 ;;
9494 ;; M-x describe-personal-keybindings
9595 ;;
96 ;; This display will tell you if you've overriden a default keybinding, and
96 ;; This display will tell you if you've overridden a default keybinding, and
9797 ;; what the default was. Also, it will tell you if the key was rebound after
9898 ;; your binding it with `bind-key', and what it was rebound it to.
9999
153153
154154 COMMAND must be an interactive function or lambda form.
155155
156 KEYMAP, if present, should be a keymap and not a quoted symbol.
156 KEYMAP, if present, should be a keymap variable or symbol.
157157 For example:
158158
159159 (bind-key \"M-h\" #'some-interactive-function my-mode-map)
160
161 (bind-key \"M-h\" #'some-interactive-function 'my-mode-map)
160162
161163 If PREDICATE is non-nil, it is a form evaluated to determine when
162164 a key should be bound. It must return non-nil in such cases.
170172 `(let* ((,namevar ,key-name)
171173 (,keyvar (if (vectorp ,namevar) ,namevar
172174 (read-kbd-macro ,namevar)))
175 (kmap (if (and ,keymap (symbolp ,keymap)) (symbol-value ,keymap) ,keymap))
173176 (,kdescvar (cons (if (stringp ,namevar) ,namevar
174177 (key-description ,namevar))
175 (quote ,keymap)))
176 (,bindingvar (lookup-key (or ,keymap global-map) ,keyvar)))
178 (if (symbolp ,keymap) ,keymap (quote ,keymap))))
179 (,bindingvar (lookup-key (or kmap global-map) ,keyvar)))
177180 (let ((entry (assoc ,kdescvar personal-keybindings))
178181 (details (list ,command
179182 (unless (numberp ,bindingvar)
182185 (setcdr entry details)
183186 (add-to-list 'personal-keybindings (cons ,kdescvar details))))
184187 ,(if predicate
185 `(define-key (or ,keymap global-map) ,keyvar
188 `(define-key (or kmap global-map) ,keyvar
186189 '(menu-item "" nil :filter (lambda (&optional _)
187190 (when ,predicate
188191 ,command))))
189 `(define-key (or ,keymap global-map) ,keyvar ,command)))))
192 `(define-key (or kmap global-map) ,keyvar ,command)))))
190193
191194 ;;;###autoload
192195 (defmacro unbind-key (key-name &optional keymap)
6262
6363 ## Versions ##########################################################
6464
65 VERSION = 2.4
65 VERSION = 2.4.1
6666
67 USE_PACKAGE_VERSION = 2.4
67 USE_PACKAGE_VERSION = 2.4.1
6868
6969 EMACS_VERSION = 24.3
7070
1111 git clone git@github.com:digitalcraftsman/hugo-alabaster-theme.git themes/hugo-alabaster-theme
1212 ```
1313
14 > This theme uses the latest developement version of Hugo. Therefore, it doesn't work with the official releases. Look [here](https://github.com/spf13/hugo#build-and-install-the-binaries-from-source-advanced-install) if you want to know how to build Hugo from source.
14 > This theme uses the latest development version of Hugo. Therefore, it doesn't work with the official releases. Look [here](https://github.com/spf13/hugo#build-and-install-the-binaries-from-source-advanced-install) if you want to know how to build Hugo from source.
1515
1616 Next, take a look in the `exampleSite` folder at. This directory contains an example config file and the content for the demo. It serves as an example setup for your documentation.
1717
55 ;; Maintainer: John Wiegley <johnw@newartisans.com>
66 ;; Created: 17 Jun 2012
77 ;; Modified: 29 Nov 2017
8 ;; Version: 2.4
8 ;; Version: 2.4.1
99 ;; Package-Requires: ((emacs "24.3"))
1010 ;; Keywords: dotemacs startup speed config package
1111 ;; URL: https://github.com/jwiegley/use-package
5555 "A use-package declaration for simplifying your `.emacs'."
5656 :group 'startup)
5757
58 (defconst use-package-version "2.4"
58 (defconst use-package-version "2.4.1"
5959 "This version of use-package.")
6060
6161 (defcustom use-package-keywords
650650 ,(when (eq use-package-verbose 'debug)
651651 `(message ,(format "Compiling package %s" name-string)))
652652 ,(unless (plist-get args :no-require)
653 `(load ,name-string nil t)))))))))
653 `(unless (featurep ',name-symbol)
654 (load ,name-string nil t))))))))))
654655
655656 ;; Certain keywords imply :defer, if :demand was not specified.
656657 (when (and (not (plist-member args :demand))
10271028 "use-package statistics"
10281029 "Show current statistics gathered about use-package declarations."
10291030 (setq tabulated-list-format
1030 ;; The sum of column width is 80 caracters:
1031 #[("Package" 25 t)
1032 ("Status" 13 t)
1033 ("Last Event" 23 t)
1034 ("Time" 10 t)])
1031 ;; The sum of column width is 80 characters:
1032 [("Package" 25 t)
1033 ("Status" 13 t)
1034 ("Last Event" 23 t)
1035 ("Time" 10 t)])
10351036 (tabulated-list-init-header))
10361037
10371038 (defun use-package-statistics-gather (keyword name after)
13921393 (comment (nth 2 def)))
13931394 (unless (and comment (stringp comment))
13941395 (setq comment (format "Customized with use-package %s" name)))
1395 `(customize-set-variable (quote ,variable) ,value ,comment)))
1396 `(funcall (or (get (quote ,variable) 'custom-set) #'set-default)
1397 (quote ,variable)
1398 ,value)))
13961399 args)
13971400 (use-package-process-keywords name rest state)))
13981401
14181421 (defun use-package-handler/:custom-face (name _keyword args rest state)
14191422 "Generate use-package custom-face keyword code."
14201423 (use-package-concat
1421 (mapcar #'(lambda (def) `(custom-set-faces (quote ,def))) args)
1424 (mapcar #'(lambda (def) `(custom-set-faces (backquote ,def))) args)
14221425 (use-package-process-keywords name rest state)))
14231426
14241427 ;;;; :init
14661469 (use-package-concat
14671470 (when use-package-compute-statistics
14681471 `((use-package-statistics-gather :config ',name nil)))
1469 (if (or (null arg) (equal arg '(t)))
1472 (if (and (or (null arg) (equal arg '(t))) (not use-package-inject-hooks))
14701473 body
14711474 (use-package-with-elapsed-timer
14721475 (format "Configuring package %s" name-symbol)
15321535 package. This is useful if the package is being lazily
15331536 loaded, and you wish to conditionally call functions in your
15341537 `:init' block that are defined in the package.
1538 :hook Specify hook(s) to attach this package to.
15351539
15361540 :bind Bind keys, and define autoloads for the bound commands.
15371541 :bind* Bind keys, and define autoloads for the bound commands,
15411545 :bind-keymap* Like `:bind-keymap', but overrides all minor mode bindings
15421546
15431547 :defer Defer loading of a package -- this is implied when using
1544 `:commands', `:bind', `:bind*', `:mode', `:magic',
1548 `:commands', `:bind', `:bind*', `:mode', `:magic', `:hook',
15451549 `:magic-fallback', or `:interpreter'. This can be an integer,
15461550 to force loading after N seconds of idle time, if the package
15471551 has not already been loaded.
1548 :after Defer loading of a package until after any of the named
1549 features are loaded.
1550 :demand Prevent deferred loading in all cases.
1552 :after Delay the use-package declaration until after the named modules
1553 have loaded. Once load, it will be as though the use-package
1554 declaration (without `:after') had been seen at that moment.
1555 :demand Prevent the automatic deferred loading introduced by constructs
1556 such as `:bind' (see `:defer' for the complete list).
15511557
15521558 :if EXPR Initialize and load only if EXPR evaluates to a non-nil value.
15531559 :disabled The package is ignored completely if this keyword is present.
15561562 :load-path Add to the `load-path' before attempting to load the package.
15571563 :diminish Support for diminish.el (if installed).
15581564 :delight Support for delight.el (if installed).
1559 :custom Call `customize-set-variable' with each variable definition.
1565 :custom Call `custom-set' or `set-default' with each variable
1566 definition without modifying the Emacs `custom-file'.
1567 (compare with `custom-set-variables').
15601568 :custom-face Call `customize-set-faces' with each face definition.
15611569 :ensure Loads the package using package.el if necessary.
15621570 :pin Pin the package to an archive."
161161 (eval-when-compile
162162 (with-demoted-errors
163163 "Cannot load foo: %S" nil
164 (load "foo" nil t)))
164 (unless (featurep 'foo)
165 (load "foo" nil t))))
165166 (t))
166167 (require 'foo nil nil)))))
167168
181182 (eval-when-compile
182183 (with-demoted-errors
183184 "Cannot load foo: %S" nil
184 (load "foo" nil t)))
185 (unless (featurep 'foo)
186 (load "foo" nil t))))
185187 (preface))
186188 (init)
187189 (require 'foo nil nil)
205207 (eval-when-compile
206208 (with-demoted-errors
207209 "Cannot load foo: %S" nil
208 (load "foo" nil t)))
210 (unless (featurep 'foo)
211 (load "foo" nil t))))
209212 (preface))
210213 (init)
211214 (eval-after-load 'foo
452455 (eval-when-compile
453456 (with-demoted-errors
454457 "Cannot load foo: %S" nil
455 (load "foo" nil t))))
458 (unless (featurep 'foo)
459 (load "foo" nil t)))))
456460 (require 'foo nil nil)))))
457461
458462 (ert-deftest use-package-test/:requires-3 ()
469473 (eval-and-compile
470474 (eval-when-compile
471475 (with-demoted-errors "Cannot load foo: %S" nil
472 (load "foo" nil t))))
476 (unless (featurep 'foo)
477 (load "foo" nil t)))))
473478 (require 'foo nil nil)))))
474479
475480 (ert-deftest use-package-test/:load-path-1 ()
498503 (eval-and-compile
499504 (eval-when-compile
500505 (with-demoted-errors "Cannot load foo: %S" nil
501 (load "foo" nil t))))
506 (unless (featurep 'foo)
507 (load "foo" nil t)))))
502508 (require 'foo nil nil)))))
503509
504510 (ert-deftest use-package-test/:load-path-3 ()
815821 (eval-and-compile
816822 (eval-when-compile
817823 (with-demoted-errors "Cannot load foo: %S" nil
818 (load "foo" nil t))))
824 (unless (featurep 'foo)
825 (load "foo" nil t)))))
819826 (unless (fboundp 'bar)
820827 (autoload #'bar "foo" nil t))
821828 (eval-when-compile
870877 (eval-and-compile
871878 (eval-when-compile
872879 (with-demoted-errors "Cannot load gnus-harvest: %S" nil
873 (load "gnus-harvest" nil t))))
880 (unless (featurep 'gnus-harvest)
881 (load "gnus-harvest" nil t)))))
874882 (eval-when-compile
875883 (declare-function gnus-harvest-install "gnus-harvest"))
876884 (require 'gnus-harvest nil nil)
895903 (eval-when-compile
896904 (with-demoted-errors
897905 "Cannot load foo: %S" nil
898 (load "foo" nil t))))
906 (unless (featurep 'foo)
907 (load "foo" nil t)))))
899908 (require 'foo nil nil)))))
900909
901910 (ert-deftest use-package-test/:functions-1 ()
913922 (eval-when-compile
914923 (with-demoted-errors
915924 "Cannot load foo: %S" nil
916 (load "foo" nil t))))
925 (unless (featurep 'foo)
926 (load "foo" nil t)))))
917927 (require 'foo nil nil)))))
918928
919929 (ert-deftest use-package-test/:functions-3 ()
929939 (declare-function bar "foo")
930940 (eval-when-compile
931941 (with-demoted-errors "Cannot load foo: %S" nil
932 (load "foo" nil t)))))))
942 (unless (featurep 'foo)
943 (load "foo" nil t))))))))
933944
934945 (ert-deftest use-package-test/:functions-5 ()
935946 (let ((byte-compile-current-file t))
941952 (eval-when-compile
942953 (with-demoted-errors
943954 "Cannot load foo: %S" nil
944 (load "foo" nil t))))
955 (unless (featurep 'foo)
956 (load "foo" nil t)))))
945957 (eval-after-load 'foo
946958 '(progn
947959 (config)
960972 (eval-and-compile
961973 (eval-when-compile
962974 (with-demoted-errors "Cannot load foo: %S" nil
963 (load "foo" nil t))))
975 (unless (featurep 'foo)
976 (load "foo" nil t)))))
964977 (require 'foo nil nil)))))
965978
966979 (ert-deftest use-package-test/:defer-3 ()
975988 `(eval-and-compile
976989 (eval-when-compile
977990 (with-demoted-errors "Cannot load foo: %S" nil
978 (load "foo" nil t)))))))
991 (unless (featurep 'foo)
992 (load "foo" nil t))))))))
979993
980994 (ert-deftest use-package-test-normalize/:hook ()
981995 (flet ((norm (&rest args)
10081022 (eval-when-compile
10091023 (with-demoted-errors
10101024 "Cannot load foo: %S" nil
1011 (load "foo" nil t))))
1025 (unless (featurep 'foo)
1026 (load "foo" nil t)))))
10121027 (unless
10131028 (fboundp 'key)
10141029 (autoload #'key "foo" nil t))
11171132 (match-expansion
11181133 (use-package foo :custom (foo bar))
11191134 `(progn
1120 (customize-set-variable 'foo bar "Customized with use-package foo")
1135 (funcall
1136 (or
1137 (get 'foo 'custom-set)
1138 (function set-default))
1139 'foo bar)
11211140 (require 'foo nil nil))))
11221141
11231142 (ert-deftest use-package-test/:custom-face-1 ()
11241143 (match-expansion
11251144 (use-package foo :custom-face (foo ((t (:background "#e4edfc")))))
11261145 `(progn
1127 (custom-set-faces '(foo ((t (:background "#e4edfc")))))
1146 (custom-set-faces (backquote (foo ((t (:background "#e4edfc"))))))
11281147 (require 'foo nil nil))))
11291148
11301149 (ert-deftest use-package-test/:init-1 ()
11421161 (eval-and-compile
11431162 (eval-when-compile
11441163 (with-demoted-errors "Cannot load foo: %S" nil
1145 (load "foo" nil t))))
1164 (unless (featurep 'foo)
1165 (load "foo" nil t)))))
11461166 (init)
11471167 (require 'foo nil nil)))))
11481168
11891209 (eval-and-compile
11901210 (eval-when-compile
11911211 (with-demoted-errors "Cannot load foo: %S" nil
1192 (load "foo" nil t))))
1212 (unless (featurep 'foo)
1213 (load "foo" nil t)))))
11931214 (eval-after-load 'bar
11941215 '(require 'foo nil nil))))))
11951216
13321353 (eval-and-compile
13331354 (eval-when-compile
13341355 (with-demoted-errors "Cannot load foo: %S" nil
1335 (load "foo" nil t))))
1356 (unless (featurep 'foo)
1357 (load "foo" nil t)))))
13361358 (require 'foo nil nil)))))
13371359
13381360 (ert-deftest use-package-test/:demand-3 ()
13511373 (eval-and-compile
13521374 (eval-when-compile
13531375 (with-demoted-errors "Cannot load foo: %S" nil
1354 (load "foo" nil t))))
1376 (unless (featurep 'foo)
1377 (load "foo" nil t)))))
13551378 (require 'foo nil nil)
13561379 (config)
13571380 t))))
13711394 (eval-and-compile
13721395 (eval-when-compile
13731396 (with-demoted-errors "Cannot load foo: %S" nil
1374 (load "foo" nil t))))
1397 (unless (featurep 'foo)
1398 (load "foo" nil t)))))
13751399 (eval-after-load 'bar
13761400 '(require 'foo nil nil))))))
13771401
14241448 (eval-and-compile
14251449 (eval-when-compile
14261450 (with-demoted-errors "Cannot load foo: %S" nil
1427 (load "foo" nil t))))
1451 (unless (featurep 'foo)
1452 (load "foo" nil t)))))
14281453 (require 'foo nil nil)
14291454 (config)
14301455 t))))
14451470 (eval-and-compile
14461471 (eval-when-compile
14471472 (with-demoted-errors "Cannot load foo: %S" nil
1448 (load "foo" nil t))))
1473 (unless (featurep 'foo)
1474 (load "foo" nil t)))))
14491475 (eval-after-load 'foo
14501476 '(progn
14511477 (config)
14521478 t))))))
1479
1480 (ert-deftest use-package-test/pre-post-hooks-with-:config ()
1481 (let ((use-package-inject-hooks t))
1482 (match-expansion
1483 (use-package foo :config (config))
1484 `(progn
1485 (when
1486 (run-hook-with-args-until-failure 'use-package--foo--pre-init-hook)
1487 (run-hooks 'use-package--foo--post-init-hook))
1488 (require 'foo nil nil)
1489 (when
1490 (run-hook-with-args-until-failure 'use-package--foo--pre-config-hook)
1491 (config)
1492 (run-hooks 'use-package--foo--post-config-hook))
1493 t))))
1494
1495 (ert-deftest use-package-test/pre-post-hooks-without-:config ()
1496 ;; https://github.com/jwiegley/use-package/issues/785
1497 (let ((use-package-inject-hooks t))
1498 (match-expansion
1499 (use-package foo)
1500 `(progn
1501 (when
1502 (run-hook-with-args-until-failure 'use-package--foo--pre-init-hook)
1503 (run-hooks 'use-package--foo--post-init-hook))
1504 (require 'foo nil nil)
1505 (when
1506 (run-hook-with-args-until-failure 'use-package--foo--pre-config-hook)
1507 t
1508 (run-hooks 'use-package--foo--post-config-hook))
1509 t))))
14531510
14541511 (ert-deftest use-package-test-normalize/:diminish ()
14551512 (should (equal (use-package-normalize-diminish 'foopkg :diminish nil)
18821939 (define-prefix-command 'my/map)
18831940 (bind-key "<f1>" 'my/map nil nil))))
18841941
1942
1943 (ert-deftest bind-key/845 ()
1944 (defvar test-map (make-keymap))
1945 (bind-key "<f1>" 'ignore 'test-map)
1946 (should (eq (lookup-key test-map (kbd "<f1>")) 'ignore))
1947 (let ((binding (cl-find "<f1>" personal-keybindings :test 'string= :key 'caar)))
1948 (message "test-map %s" test-map)
1949 (message "binding %s" binding)
1950 (should (eq (cdar binding) 'test-map))
1951 (should (eq (nth 1 binding) 'ignore))
1952 (should (eq (nth 2 binding) nil))))
1953
18851954 ;; Local Variables:
18861955 ;; indent-tabs-mode: nil
18871956 ;; no-byte-compile: t
55 ;; Maintainer: John Wiegley <johnw@newartisans.com>
66 ;; Created: 17 Jun 2012
77 ;; Modified: 29 Nov 2017
8 ;; Version: 2.4
8 ;; Version: 2.4.1
99 ;; Package-Requires: ((emacs "24.3") (bind-key "2.4"))
1010 ;; Keywords: dotemacs startup speed config package
1111 ;; URL: https://github.com/jwiegley/use-package
1010 #+TEXINFO_DIR_CATEGORY: Emacs
1111 #+TEXINFO_DIR_TITLE: use-package: (use-package).
1212 #+TEXINFO_DIR_DESC: Declarative package configuration for Emacs.
13 #+SUBTITLE: for version 2.4
13 #+SUBTITLE: for version 2.4.1
1414
1515 #+TEXINFO_DEFFN: t
1616 #+OPTIONS: H:4 num:3 toc:2 creator:t
170170 should display something like
171171
172172 #+BEGIN_EXAMPLE
173 use-package-version’s value is "2.4"
173 use-package-version’s value is "2.4.1"
174174 #+END_EXAMPLE
175175
176176 If you are completely new to use-package then see {{{link-jump(Getting
262262
263263 *NOTE*: Pay attention if you set ~use-package-always-defer~ to t, and also use
264264 the ~:after~ keyword, as you will need to specify how the declared package is
265 to be loaded: e.g., by some ~:bind~. If you're not using one of tho mechanisms
265 to be loaded: e.g., by some ~:bind~. If you're not using one of the mechanisms
266266 that registers autoloads, such as ~:bind~ or ~:hook~, and your package manager
267267 does not provide autoloads, it's possible that without adding ~:demand t~ to
268268 those declarations, your package will never be loaded.
821821 the somewhat simpler ~:requires~ keyword simply never loads the package if the
822822 dependencies are not available at the time the ~use-package~ declaration is
823823 encountered. By "available" in this context it means that ~foo~ is available
824 of ~(featurep 'foo)~ evaulates to a non-nil value. For example:
824 of ~(featurep 'foo)~ evaluates to a non-nil value. For example:
825825
826826 #+BEGIN_SRC emacs-lisp
827827 (use-package abbrev
2929 @finalout
3030 @titlepage
3131 @title use-package User Manual
32 @subtitle for version 2.4
32 @subtitle for version 2.4.1
3333 @author John Wiegley
3434 @page
3535 @vskip 0pt plus 1filll
261261 should display something like
262262
263263 @example
264 use-package-version’s value is "2.4"
264 use-package-version’s value is "2.4.1"
265265 @end example
266266
267267 If you are completely new to use-package then see @ref{Getting Started}.
918918 the somewhat simpler @code{:requires} keyword simply never loads the package if the
919919 dependencies are not available at the time the @code{use-package} declaration is
920920 encountered. By "available" in this context it means that @code{foo} is available
921 of @code{(featurep 'foo)} evaulates to a non-nil value. For example:
921 of @code{(featurep 'foo)} evaluates to a non-nil value. For example:
922922
923923 @lisp
924924 (use-package abbrev