Commit graph

428 commits

Author SHA1 Message Date
John Wiegley
9b523d7c4e Upgrade license to GPL 3
Fixes https://github.com/jwiegley/use-package/issues/499
2017-11-28 11:22:53 -08:00
John Wiegley
18b9bf18ad Don't allow :commands, :bind, etc., to be given an empty list
This makes the following an error:

    :commands
    :commands nil
    :commands ()

Fixes https://github.com/jwiegley/use-package/issues/512
2017-11-28 11:17:05 -08:00
John Wiegley
4ddf42185a Explicit :defer t should override use-package-always-demand
Fixes https://github.com/jwiegley/use-package/issues/514
2017-11-28 11:14:30 -08:00
John Wiegley
5ac5f8bc63 Merge pull request from drrlvn/patch-1
Remove duplicate documentation of :mode
GitHub-reference: https://github.com/jwiegley/use-package/issues/489
2017-11-28 11:08:08 -08:00
John Wiegley
c72d8567d2 Corrections to the normalization of :custom 2017-11-28 11:07:36 -08:00
John Wiegley
903ff82219 Merge pull request from joewreschnig/implicit-diminish
Allow `:diminish` with no arguments.
GitHub-reference: https://github.com/jwiegley/use-package/issues/472
2017-11-28 11:07:03 -08:00
Justin Talbott
57ec21a013 allow customized values to be nil 2017-11-20 23:33:34 -05:00
John Wiegley
9bf8264523 Merge pull request from canatella/add-customization-keywords
Add customization keywords
GitHub-reference: https://github.com/jwiegley/use-package/issues/508
2017-11-20 15:42:19 -08:00
Damien Merenne
d8bbc3a95d Add support for face customization
Allows customization of faces using customize-set-faces. This makes it
easier to manage customization in version control. Instead of having all the
faces written in a custom.el, the faces can be customized where the rest
of the package is configured.
2017-11-10 09:17:46 +01:00
Damien Merenne
fcf219701b Add support for variable customization
Allows customization of variable using customize-set-variables. This makes it
easier to manage customization in version control. Instead of having all the
variables written in a custom.el, the variable can be customized where the rest
of the package is configured.
2017-11-10 09:14:38 +01:00
Carl Lieberman
5396491aec Fix typos in docstring 2017-10-30 16:03:35 -04:00
Jonas Bernoulli
85643eaf18 Cosmetic changes to use-package-ensure-elpa 2017-10-13 14:09:13 +02:00
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
Dror Levin
c3455b2a67 Remove duplicate documentation of :mode 2017-07-31 00:11:13 +03:00
Joe Wreschnig
d0dcd95d80 Document :delight in the doc string and README 2017-07-10 09:17:23 +02:00
Joe Wreschnig
ca83649a32 Allow :diminish with no arguments
When given no arguments, have :diminish assume it should diminish a
mode named after the current package (the package’s name, with “-mode”
appended, if it’s not already) to an empty string.

When given only a string to diminish an implicit package name to, do
not append “-mode” to the package name if it already ends with
it.  (This is a backwards-incompatible change if someone was
diminishing a package named “foo-mode” implementing `foo-mode-mode`.)

Add test cases for `use-package-normalize-diminish`.

This addresses some of the redundancy mentioned in issue https://github.com/jwiegley/use-package/issues/288.
2017-07-08 15:32:46 +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