Commit graph

301 commits

Author SHA1 Message Date
Radon Rosborough
249de4b44d Merge remote-tracking branch 'origin/master' into defer-install
Resolve merge conflicts.
2017-03-18 20:43:40 -07:00
Radon Rosborough
b2e674de0a Update docstring, installation prompt message 2017-03-18 20:01:07 -07:00
Radon Rosborough
ecc5fddda4 Various improvements for deferred installation 2017-03-18 19:34:28 -07:00
Radon Rosborough
57e38152e1 Get :defer-install completely working, in theory
* A quoting error has been fixed in `use-package-handler/:defer'.
* `use-package-install-deferred-package' has been updated to return t
  if the package was actually installed, and nil otherwise.
* The fake autoloads generated during deferred installation are
  doctored so Emacs does not think they were defined in the user's
  init-file.
* The docstrings of the fake autoloads have been improved.
* Arguments and interactivity are now correctly passed to the
  autoloaded function.
* The autoload now skips requiring the feature and calling the
  original function if the user declines to install the package. This
  prevents unprofessional errors.
2017-03-08 20:05:15 -08:00
Radon Rosborough
855a2afbe3 Improve deferred installation mechanism
This time around, I've gotten rid of the advice on `require' (that was
never going to work) and instead made `use-package' try to handle
loading the package at the appropriate time. In particular, when
deferred installation is active, all the autoloads generated by
`use-package' are not regular autoloads, but regular functions that
will install the relevant package, require the relevant feature, and
only then call the newly defined (autoloaded) function.

Some smarter logic has been added to make sure things like `:demand'
play nicely with the autoloading system; see the extensive comment in
`use-package-handler/:defer-install' for more information on how that
works.

There was a section in `use-package-install-deferred-package' which
referred to a nonexistent variable `use-package--deferred-features';
that has been removed.

There is now, in addition to `use-package-ensure-function', a new
variable called `use-package-pre-ensure-function'. This is intended
for use by package managers which, unlike package.el, activate
autoloads package-by-package instead of all at once. Even if a package
is marked for deferred installation, the user would likely want its
autoloads activated immediately *if* it was already installed. The
logic for doing that can now be put in
`use-package-pre-ensure-function'.
2017-03-08 19:03:34 -08:00
Radon Rosborough
89a8f94672 Merge branch 'generalized-ensure' into defer-install 2017-03-08 18:19:15 -08:00
Radon Rosborough
a233f01ff6 Update docstring for use-package-ensure-function
Now it properly reflects the API changes recently made.
2017-03-08 18:17:49 -08:00
Radon Rosborough
f6224b2956 First cut at :defer-install keyword
This new keyword, if provided along with a non-nil value, causes the
action of :ensure to be deferred until "necessary". Package
installation can be triggered by the user calling the new interactive
function `use-package-install-deferred-package', or by the feature
declared by the `use-package' form being required. This latter
behavior seems to be the simplest way to make sure that package
installation actually takes place when it needs to, but it requires
that an advice be added to `require', which may be considered overly
intrusive. (Also, it's generally considered bad practice for functions
in Emacs to put advice on other functions in Emacs.) Thus it may make
sense to add an option or function to explicitly enable this behavior,
if there does not turn out to be a better way to accomplish deferred
installation.

Documentation has not been updated to reflect :defer-install yet.
2017-03-08 12:59:54 -08:00
Radon Rosborough
4e6115214b Extend capabilities of use-package-ensure-function
Modify the expected API of `use-package-ensure-function' so that it is
passed three 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. (Previously, it was only
given a single argument, which was the argument passed to `:ensure',
or the name of the package declared in the `use-package' form, if the
former was `t'.

This allows for more flexibility in the capabilities of the
`use-package-ensure-function' implementation. For example, its
behavior can change depending on the values of other keywords, if
those keywords modify the `state' plist appropriately.
2017-03-08 11:17:33 -08:00
John Wiegley
45442561d3 Revert "Return t' after calling eval-after-load'"
This reverts commit 87a8ff6d69.
2017-02-18 01:32:34 -08:00
John Wiegley
0517689cf3 Support multiple symbols passed to :after
The following expressions are now permitted:

    foo                         ; load after foo is loaded
    foo bar                     ; load after both foo and bar are loaded
    :all foo bar                ; same as previous
    :any foo bar                ; load after either foo or bar is loaded
    :any (:all foo bar) baz     ; more complex combinations...
    :any (:all foo bar) (:all baz wow)
    :all (:any foo bar) (:any baz wow)

Fixes https://github.com/jwiegley/use-package/issues/283
2017-02-16 13:51:22 -08:00
John Wiegley
f1fa65d773 :mode and :interpreter can now accept (rx ...) forms
Fixes https://github.com/jwiegley/use-package/issues/204
2017-02-16 12:03:59 -08:00
John Wiegley
87a8ff6d69 Return t' after calling eval-after-load'
Fixes https://github.com/jwiegley/use-package/issues/174
2017-02-16 11:44:41 -08:00
John Wiegley
61d6a8e449 Add autoload cookie for use-package-autoload-keymap
Fixes https://github.com/jwiegley/use-package/issues/337
2017-02-16 11:33:29 -08:00
John Wiegley
a4c3244f30 Merge remote-tracking branch 'origin/pr/349' 2017-02-16 11:14:25 -08:00
John Wiegley
0905a7b1c7 Merge pull request from justbur/find-form
Add function use-package-jump-to-package-form
GitHub-reference: https://github.com/jwiegley/use-package/issues/359
2017-02-13 16:53:56 -05:00
John Wiegley
c287aa3085 Merge pull request from justbur/imenu3
Improve imenu support
GitHub-reference: https://github.com/jwiegley/use-package/issues/356
2017-02-13 16:44:04 -05:00
Radon Rosborough
482c8e5728 Fix use-package-defaults
This patch should address issues https://github.com/jwiegley/use-package/issues/428 and https://github.com/jwiegley/use-package/issues/429. See https://github.com/jwiegley/use-package/issues/426 for
discussion. In brief, the issue was that use-package-sort-keywords was
not applied when the predicates in use-package-defaults did not return
true, when it should have been applied unconditionally.
2017-02-13 12:48:48 -08:00
Radon Rosborough
8fa6e8823b Unrevert "Add use-package-defaults"
This reverts commit 013425edeb.
2017-02-13 12:48:24 -08:00
John Wiegley
013425edeb Revert "Add use-package-defaults"
This reverts commit 3dec23c086.
2017-02-13 10:33:11 -08:00
Radon Rosborough
3dec23c086 Add use-package-defaults
Previously, the :config, :ensure, and :pin keywords had default
values (dependent on the values of the use-package-always-ensure and
use-package-always-pin). This change allows the user to customize the
default values used for those keywords, and add default values for
their own keywords in a non-hacky way.

This functionality would be useful for (as an example) the
quelpa-use-package package, which needs to use an advice to override
the functionality of :ensure. The same problem prevents adding a
use-package-always-quelpa variable in any reasonable way, without a
way to customize the default values of keywords.
2017-01-16 13:47:31 -08:00
Radon Rosborough
e853355714 Add use-package-ensure-function
This allows the user to customize the :ensure keyword by using a
different package manager than package.el.
2017-01-15 09:03:05 -07:00
John Wiegley
ad8094c22d Add new customization option use-package-always-demand
This is equivalent to adding `:demand t` to all `use-package` declarations,
and has the same semantics as doing so (meaning it can be overridden locally
using `:defer t` in a declaration).

Fixes https://github.com/jwiegley/use-package/issues/423
2016-12-22 09:03:47 -08:00
John Wiegley
dbf46d97be Merge pull request from basil-conto/preface
Increase :preface priority
GitHub-reference: https://github.com/jwiegley/use-package/issues/418
2016-12-18 15:21:10 -08:00
Jonas Bernoulli
134ecb3c88 Support outline-minor-mode
In "use-package.el" prefix headings with ";;;" instead of just
";;".  In "bind-key.el" add the missing ";;; Code:" heading.
In both libraries set `outline-regexp' to an appropriate value.
2016-12-17 15:26:15 +01:00
Basil L. Contovounesios
aad07daa8d Increase :preface priority
Reconcile order of `use-package-keywords' with the README
description of `:preface' as occurring before everything but
`:disabled'.
2016-12-16 08:50:05 +00:00
Philipp Stephani
baa9e25a6b Declare package-read-all-archive-contents
Fixes https://github.com/jwiegley/use-package/issues/398
2016-10-31 18:22:03 +01:00
Noam Postavsky
9688d2f64b Don't allow implicit package name arg for binders
It's unlikely that

    (use-package foopkg :bind "<some-key>")

intendes to bind <some-key> to 'foopkg command.
2016-10-31 08:49:21 -04:00
Noam Postavsky
65c7b42a14 Don't allow nil as a mode function
This means (use-package foopkg :mode (".foo")) will add (".foo"
. foopkg) into auto-mode-alist instead of the broken (".foo" . nil),
this is more consistent with the behaviour of (use-package foopkg
:mode (".foo" ".bar")).
2016-10-31 08:49:21 -04:00
Noam Postavsky
fc57b34299 Refactor pair normalizers; add tests for them
This is not a pure refactoring, it also fixes a bug where
:bind ([keysym] . "string") would actually bind keysym to nil (i.e.,
unbind it).  It now binds to "string" as expected.
2016-10-31 08:49:21 -04:00
John Wiegley
fc7fc42f13 Bump version to 2.3 2016-10-17 16:40:29 -07:00
Mike Appleby
ef0cbfdc73 Ensure package-pinned-packages is bound before referencing it
Add a bound-and-true-p guard to package-pinned-packages before
referencing it in use-package-ensure-elpa.

Package pinning was introduced in Emacs 24.4, and hence
package-pinned-packages in unbound by default in earlier versions.

Relevant commits:
	 72452b5 Merge pull request https://github.com/jwiegley/use-package/issues/367 from ketbra/master
	 5053f75 Make pin and ensure compatible

Fixes https://github.com/jwiegley/use-package/issues/375

Copyright-paperwork-exempt: yes
2016-08-15 11:48:33 -05:00
John Wiegley
4629e86240 Remove the use of a tab 2016-07-22 11:23:10 -07:00
Matthew Feinberg
5053f75e00 Make pin and ensure compatible
`:pin` does not work with `:ensure`, because it doesn't add the package to package-pinned-packages until after reading the package archive contents.  This change causes the package archive contents to be reread if the package is pinned and `:ensure` is being used.

Copyright-paperwork-exempt: yes
2016-07-21 08:38:30 -04:00
Noam Postavsky
79c38c5184 Fix declare-function call: FILE must be a string 2016-07-17 22:28:25 -04:00
Noam Postavsky
71057bc20f use-package-as-string: use noerror parameter 2016-07-17 22:27:13 -04:00
Noam Postavsky
be7a0e4649 Don't pass a constant as the state
for use-package-process-keywords, because the function may modify the
list object.  Modifying a quoted constant can lead to unexpected side
effects (e.g. values from previous use-package forms end up in
subsequent ones).
2016-07-17 22:26:40 -04:00
John Wiegley
758739e6db Version 2.2 2016-07-06 15:20:41 -07:00
Justin Burkett
59d34cf9ce Move :init forms before :after and :demand
The docstring of use-package says that :init should run before the
package is loaded but using :after moves the require statement ahead of
:init when any package specified in :after is already loaded. In the
following example, in the first case bar-x might get set before or after
bar is loaded depending on if foo is already loaded at the time, while
the second case always sets bar-x first.

(use-package bar
  :after (foo)
  :init (setq bar-x 2)
  :config (bar-mode))

(use-package bar
  :init (setq bar-x 2)
  :config (bar-mode))

This commit fixes the issue and makes sure that bar-x is set before bar
is loaded by use-package. Fixes https://github.com/jwiegley/use-package/issues/352.
2016-06-23 10:01:33 -04:00
Justin Burkett
c13ca927c2 Add function use-package-jump-to-package-form
This is an attempt at resolving https://github.com/jwiegley/use-package/issues/329. The new interactive function
use-package-jump-to-package-form will prompt with a completing read of
all known packages. After selecting a package, use-package-find-require
searches load-history to see where the package was required and then I
attempt to find the correct use-package form using
use-package-form-regexp.

It will fail if the use-package form you are looking for did not
actually load the package. For example it could be something that is a
dependency of a library that was already loaded. In some sense this is a
feature because it is helpful to know that the library was already
loaded when your use-package form was encountered. It will also fail if
your use-package declaration doesn't match the regexp used, but this is
easily adjusted.
2016-06-22 23:18:14 -04:00
Justin Burkett
75bdb87833 Improve imenu support
Instead of using defvar for lisp-mode-symbol-regexp, wait until
lisp-mode is loaded and check for its existence to avoid making
use-package the place where this variable is declared.
2016-06-15 22:54:15 -04:00
Justin Burkett
da08a04652 Fix imenu support for older versions
lisp-mode-symbol-regexp was not defined in Emacs 24.5.
2016-06-13 21:02:14 -04:00
John Wiegley
1d6b3174f5 Merge pull request from justbur/imenu
Add imenu support for use-package forms
GitHub-reference: https://github.com/jwiegley/use-package/issues/354
2016-06-13 09:57:20 -07:00
Justin Burkett
d34fb2bdc9 Add imenu support for use-package forms
Also add require forms and group both under menu "Package".
2016-06-13 09:45:27 -04:00
robario
858a7f9b7c Fix to ignore load error caused via :after
Copyright-paperwork-exempt: yes
2016-06-05 14:58:40 +09:00
Chunyang Xu
3aa6aecb7f Mark package as selected with package-install
Fixes https://github.com/jwiegley/use-package/issues/327
2016-03-31 19:33:55 +08:00
John Wiegley
a1c4e6d0ab Normalize some error text 2016-02-26 16:18:21 -08:00
John Wiegley
f150691c78 Only printing debug messages if use-package-verbose is `debug'
Fixes https://github.com/jwiegley/use-package/issues/271
2016-02-26 16:16:49 -08:00
John Wiegley
6a90a9f16d Add configuration variable `use-package-check-before-init'
Fixes https://github.com/jwiegley/use-package/issues/306
2016-02-25 17:24:59 -08:00
John Wiegley
ce51ea2055 Use add-to-list' defensively instead of push'
GitHub-reference: fixes https://github.com/jwiegley/use-package/issues/293
2016-02-25 17:13:02 -08:00