Damien Merenne [Tue, 17 Oct 2017 17:40:38 +0000 (19:40 +0200)]
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.
Damien Merenne [Tue, 17 Oct 2017 17:35:19 +0000 (19:35 +0200)]
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.
Joe Wreschnig [Wed, 14 Jun 2017 18:24:01 +0000 (20:24 +0200)]
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.
Radon Rosborough [Fri, 30 Jun 2017 19:26:26 +0000 (12:26 -0700)]
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.
Joe Wreschnig [Thu, 15 Jun 2017 18:44:11 +0000 (20:44 +0200)]
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
David Leatherman [Tue, 23 May 2017 01:23:26 +0000 (18:23 -0700)]
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.
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.
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)))
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.
* 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.
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'.
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.
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.
John Wiegley [Thu, 16 Feb 2017 21:48:05 +0000 (13:48 -0800)]
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)
Radon Rosborough [Mon, 13 Feb 2017 20:48:48 +0000 (12:48 -0800)]
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.
Radon Rosborough [Mon, 16 Jan 2017 21:47:31 +0000 (13:47 -0800)]
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.
John Wiegley [Thu, 22 Dec 2016 17:02:52 +0000 (09:02 -0800)]
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).
Jonas Bernoulli [Sun, 18 Dec 2016 14:47:36 +0000 (15:47 +0100)]
Delay decision whether to use eval-after-load until run-time
Just because a keymap variable is bound at macro-expansion-time
doesn't mean that it must be bound at run-time too.
Change `bind-keys-form', which is used by `bind-keys' and other
macros, to return a form which delays the decision on whether to
wrap the binding forms with `eval-after-load' until run-time.
Jonas Bernoulli [Sat, 17 Dec 2016 14:26:15 +0000 (15:26 +0100)]
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.
Noam Postavsky [Thu, 26 May 2016 19:09:46 +0000 (15:09 -0400)]
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")).
Noam Postavsky [Thu, 26 May 2016 19:08:32 +0000 (15:08 -0400)]
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.
Mike Appleby [Mon, 15 Aug 2016 03:43:36 +0000 (22:43 -0500)]
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
Matthew Feinberg [Thu, 21 Jul 2016 12:38:30 +0000 (08:38 -0400)]
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.
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).
Justin Burkett [Thu, 23 Jun 2016 14:01:33 +0000 (10:01 -0400)]
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.
Justin Burkett [Thu, 23 Jun 2016 02:46:32 +0000 (22:46 -0400)]
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.