Commit graph

266 commits

Author SHA1 Message Date
Jonas Bernoulli
68c9ee4bff Don't use with-demoted-errors in use-package-ensure-elpa
It expects a literal string as argument at macro-expansion
time, but we need to construct the message.
2017-10-13 14:08:06 +02:00
John Wiegley
3f58555ed8 Merge pull request from raxod502/feat/fix-install-deferred
Fix bug in use-package-install-deferred-package
GitHub-reference: https://github.com/jwiegley/use-package/issues/479
2017-08-12 22:56:38 -07:00
Joe Wreschnig
d0dcd95d80 Document :delight in the doc string and README 2017-07-10 09:17:23 +02:00
Joe Wreschnig
7eec86f5cd Allow :major as the third argument in :delight calls 2017-07-02 17:45:26 +02:00
Joe Wreschnig
4b8b850cf0 Allow multiple :delight arguments, or omitting the mode. ()
This allows using forms such as

    (use-package foo :delight)
        ;; => (delight 'foo-mode)
    (use-package foo :delight " f")
        ;; => (delight 'foo-mode " f")
    (use-package foo :delight (a-mode) (b-mode " b")
        ;; => (delight 'a-mode) (delight 'b-mode " b")

This brings support for `:delight` in line with `:diminish`.
GitHub-reference: https://github.com/jwiegley/use-package/issues/477
2017-07-02 16:32:38 +02:00
Radon Rosborough
6e6b533aaf Fix bug in use-package-install-deferred-package
Previously, deferred installation didn't work because I didn't convert
the result of a `completing-read' back from a string to a symbol,
which meant the hash-table lookup failed.
2017-06-30 12:26:26 -07:00
Joe Wreschnig
ac4a3a4aa8 Add :magic and :magic-fallback keywords (issue)
These keywords work equivalently to `:mode` or `:interpreter`, but for
`magic-mode-alist` and `magic-fallback-mode-alist`.

The handler function implementation is now passed a list to add to,
and shared by all four of them.
GitHub-reference: https://github.com/jwiegley/use-package/issues/469
2017-06-15 20:56:53 +02:00
David Leatherman
ec088b747a Protect against errors during package install
If the network is missing and there is a new use-package with :ensure,
startup would fail part of the way through due package.el being unable
to reach the package repo.  This will catch that error and report it
while allowing startup to continue.

Copyright-paperwork-exempt: yes
2017-05-22 18:23:26 -07:00
Radon Rosborough
3823a9059e Fix quoting error in failed autoload message 2017-05-07 15:23:50 -07:00
Radon Rosborough
a9ffffcee5 Make use-package-normalize-value handle nil better
The previous version of `use-package-normalize-value', when passed
nil, would return the list (symbol-value (quote nil)). This meant that
keywords which used `use-package-normalize-value' or the higher-level
normalizer `use-package-normalize-test' would get a non-nil
argument (i.e. the above list) even when the user specified nil to the
package.

This had the concrete impact of making it so that :defer-install nil
was treated as :defer-install t.
2017-04-04 21:16:06 -07:00
Radon Rosborough
e5e335424c Add comment explaining keyword-argument patch 2017-04-03 10:40:46 -07:00
Radon Rosborough
d5d320e607 Don't mutilate keyword arguments in :bind
The parsing logic in `use-package-normalize-pairs' is not designed to
deal with keyword arguments. However, `use-package-normalize-pairs' is
used to process the arguments to :bind, which can include keyword
arguments. These keyword arguments are supposed to be passed untouched
to the underlying `bind-keys' function, but there is a clause in
`use-package-normalize-pairs' that replaces lists with their first
element. Thus an invocation like:

(use-package company
  :bind (:map company-active-map
         :filter (company-explicit-action-p)
         ("RET" . company-complete-selection)))

Generates code like this:

(bind-keys
  :map company-active-map
  :filter company-explicit-action-p
  ("RET" . company-complete-selection))

Which generates an error since `company-explicit-action-p' is now
being referenced as a variable rather than a function.

The proper solution is to refactor the logic that goes into parsing
uses of :bind, but this commit adds a temporary patch to eliminate the
above problem, while trying to be as reverse-compatible as possible.
In particular it just inhibits the list-to-first-element
transformation when the previous element processed was a keyword.
2017-04-02 21:03:47 -07:00
John Wiegley
9f90129b95 Merge pull request from raxod502/fix-after
Fix :after keyword
GitHub-reference: https://github.com/jwiegley/use-package/issues/439
2017-03-27 14:49:43 -07:00
Radon Rosborough
bca84ee71a Add use-package-always-defer-install
See https://github.com/jwiegley/use-package/pull/433#issuecomment-289317875
2017-03-26 14:40:17 -07:00
Radon Rosborough
9ad6f2ef1a Fix :after keyword
Commit [1] broke the functionality of :after (see [2]) due to an
extraneous quote being added.

[1]: bd2afa53c7
[2]: https://github.com/jwiegley/use-package/pull/433#issuecomment-287606553
2017-03-19 08:33:30 -07:00
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