Commit graph

121 commits

Author SHA1 Message Date
John Wiegley
1c5f9247aa Merge pull request from npostavs/eval-after-name
use--package: eval-after-load name
GitHub-reference: https://github.com/jwiegley/use-package/issues/168
2015-03-15 20:07:16 -04:00
John Wiegley
98b642b794 Undo an erroneous change 2015-03-15 19:07:03 -05:00
John Wiegley
199399e552 Add -hook to the injected hooks
Fixes https://github.com/jwiegley/use-package/issues/161
2015-03-15 18:49:08 -05:00
John Wiegley
03ea5d6dbf Restore an earlier fix to
Fixes https://github.com/jwiegley/use-package/issues/167
GitHub-reference: https://github.com/jwiegley/use-package/issues/53
2015-03-15 18:45:41 -05:00
John Wiegley
9385ab417a BREAKING CHANGE: Remove :idle and :idle-priority
I am removing this feature for now because it can result in a nasty
inconsistency.  Consider the following definition:

  (use-package vkill
    :commands vkill
    :idle (some-important-configuration-here)
    :bind ("C-x L" . vkill-and-helm-occur)
    :init
    (defun vkill-and-helm-occur ()
      (interactive)
      (vkill)
      (call-interactively #'helm-occur))

    :config
    (setq vkill-show-all-processes t))

If I load my Emacs and wait until the idle timer fires, then this is the
sequence of events:

    :init :idle <load> :config

But if I load Emacs and immediately type C-x L without waiting for the
idle timer to fire, this is the sequence of events:

    :init <load> :config :idle

It's possible that the user could use `featurep` in their idle to test
for this case, but that's a subtlety I'd rather avoid.

What I would consider is this: `:idle [N]` is a keyword that simply
implies `:defer`, with an option number of N to specify a second count.
After that many seconds, if the package has not yet been loaded by
autoloading, it will be loaded via the idle timer.

This approach has the benefit of complete consistency for both the idle
and the autoloaded cases.  Although, the fact that it implies `:defer`
means we don't have to consider what it means to add `:idle` behavior to
a demand-loaded configuration.
2015-03-15 18:07:37 -05:00
Noam Postavsky
1f20acfd57 use--package: eval-after-load name
instead of name-string. This prevents triggering by config file names
that have the same name as the package.

Reprise of c6d79d2cb4
2015-03-15 15:14:04 -04:00
John Wiegley
81f5e48d32 Support optional injection of hooks, for Spacemacs 2015-03-15 03:49:16 -05:00
John Wiegley
f637380fed Add :preface, occurring before everything except :disabled
This can be used to establish function and variable definitions that
will 1) make the byte-compiler happy (it won't complain about functions
whose definitions are unknown because you have them within a guard
block), and 2) allow you to define code that can be used in an `:if`
test.
2015-03-15 02:22:17 -05:00
John Wiegley
b4a00d2eb5 Some minor code reformatting 2015-03-15 02:21:53 -05:00
John Wiegley
71f894fe78 Fix to :ensure normalization 2015-03-15 02:21:40 -05:00
John Wiegley
a6edb08122 Merge pull request from thomasf/master
Fix :ensure value interpretation
GitHub-reference: https://github.com/jwiegley/use-package/issues/163
2015-03-15 02:49:09 -04:00
Thomas Frössman
e68d00d525 Fix :ensure value interpretation 2015-03-15 02:18:59 +01:00
Noam Postavsky
27cba067ee use-package-expand: use display-warning
instead of with-demoted-errors. This prevents errors from getting lost
in the *Messages* buffer.
2015-03-14 11:33:12 -04:00
John Wiegley
4ae584f3ff Begin refactoring for 2.0; NOTE: BREAKING CHANGES
The major change is that :init is now always performed before loading a
file, whether loading is deferred or not.  This is a change from before,
where the semantics of :init varied between demand and defer.  The new
usage is now entirely consistent.

Also, because :init and :config now mean "before" and "after", the
:pre-* and :post-* keywords are gone, as they should no longer be
necessary.

Lastly, an effort has been made to make your Emacs start even in the
presence of use-package configuration failures.  So after this change,
be sure to check your *Messages* buffer.  Most likely, you will have
several instances where you are using :init, but should be using :config
(this was the case for me in a number of places).
2015-03-14 05:22:43 -05:00
John Wiegley
0f76d766d9 Many stylistics cleanups and simplifications 2015-03-13 04:47:07 -05:00
John Wiegley
a4a696572d Revert "Don't add autoload for existing commands"
This reverts commit a2b23f8326.
2015-03-13 03:26:09 -05:00
John Wiegley
30da0769bf Stylistic changes 2015-03-13 03:25:32 -05:00
John Wiegley
f8bf1b0986 Minor style edits 2015-03-13 03:13:31 -05:00
John Wiegley
f334f230eb Minor changes 2015-03-13 03:02:47 -05:00
John Wiegley
aa6e3f47c7 Show more informative errors when they occur 2015-03-13 02:58:37 -05:00
Jonas Bernoulli
719115cf47 Allow using expanded macro without loading feature
In the macro `use-package-with-elapased-timer' use `bound-and-true-p'
go get the values of the customizable options `use-package-verbose'
and `use-package-minimum-reported-time'.  This way the library only
has to be required at compile time, provided these options are not
actually customized.  If the user has changed the values, then she
also has to load the library at runtime or the macros fall back to
the default of doing their job silently.  See https://github.com/jwiegley/use-package/issues/149.
2015-01-18 11:41:13 +01:00
Russell Black
b8f0799ce8 Passing t into keymap function 2015-01-03 13:53:38 -07:00
Russell Black
1ae2236854 :bind-keymap - bind a key prefix to an autoloaded package keymap 2014-12-31 17:02:25 -07:00
Sean Allred
5a5aeca797 Do not quote lambda expressions
http://emacs.stackexchange.com/a/3596

Quoting lambda expressions is at best redundant and at worst
detrimental; this commit removes all use of the sharp-quote to reduce
confusion.
2014-12-19 23:12:47 -05:00
John Wiegley
f8db1f1740 Merge pull request from YoungFrog/fixautoloads
Don't add autoload for existing commands
GitHub-reference: https://github.com/jwiegley/use-package/issues/138
2014-12-17 15:53:42 -06:00
Peter Hoeg
b3bf1b2587 Check if package-archives are valid when pinning 2014-12-18 04:34:49 +08:00
Nicolas Richard
a2b23f8326 Don't add autoload for existing commands 2014-12-17 18:30:50 +01:00
Peter Hoeg
435d4b4078 pure cleanup 2014-12-17 05:45:53 +08:00
Peter Hoeg
fe7fe61528 support for pinning package to archive 2014-12-11 14:44:27 +08:00
John Wiegley
6570447a05 Merge pull request from Silex/master
Fix "compiling" typo
GitHub-reference: https://github.com/jwiegley/use-package/issues/125
2014-09-18 21:33:08 +01:00
Justin Talbott
e8ce1b20ca add :bind* keyword for bind-key* 2014-09-16 16:39:21 -04:00
Philippe Vaucher
f07ecde5a1 Fix "compiling" typo 2014-09-16 18:34:42 +02:00
Thomas Frössman
351c102010 Display which package that has compile errors 2014-09-14 12:57:44 +02:00
Jonas Bernoulli
31bb0cde56 assume the declare-function macro exists
Since `declare-function' was added in Emacs 23.1 (five years ago), we
don't need to assert that it is defined.  If the assertion was without
any problems there would be no harm in keeping it, but unfortunately it
causes a compile warning.  Because `declare-function' is a macro with
always expands to `nil' the value of (fboundp 'declare-function) ends
up being unused.
2014-09-07 14:43:56 +02:00
Thomas Frössman
1c82b2377f Don't abort compiling if package loading fails 2014-05-17 10:48:20 +02:00
John Wiegley
a4939e7ef3 Revert "Merge pull request from alexko/master"
This reverts commit 8c04377608, reversing
changes made to a9ba368fa7.
GitHub-reference: https://github.com/jwiegley/use-package/issues/104
2014-05-08 13:25:39 -05:00
John Wiegley
8c04377608 Merge pull request from alexko/master
if package can't be located, treat it the same way as disabled
GitHub-reference: https://github.com/jwiegley/use-package/issues/104
2014-05-07 12:24:10 -05:00
Alex Kosorukoff
6d02a320f6 if package can't be located, treat it the same way as disabled
There will be a message "Unable to locate <package-name>" in the log.
2014-05-06 20:38:14 -07:00
Nicolas Richard
4e80d29daf Eval backquote earlier and support non-`progn' lists
* use-package.el (use-package-plist-get): add optional args: `eval-backquote'
  and `no-progn' to control how arguments are retrieved.
  (use-package-plist-get-value): remove this function
  (use-package): replace calls to old function to modified function.

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

Rationale :
- use-package-plist-get-value was just another layer for no good reason,
  and IMO its name was totally unclear.
- we now eval-as-backquote earlier, allowing constructs like:
(let ((my-list-of-commands-in-foo '(foo1 foo2)))
  (use-package foo :commands ,@my-list-of-commands-in-foo))
2014-05-05 12:14:53 +02:00
Nicolas Richard
0ab0d77691 Add new option use-package-idle-interval
* use-package.el (use-package-idle-interval): new defcustom
(use-package-start-idle-timer): use it
(use-package-idle-eval): use it
* README.md: document it

This addresses bug https://github.com/jwiegley/use-package/issues/77
2014-03-17 16:22:43 +01:00
François Févotte
6b30c15823 :idle-priority keyword to change the running order of idle functions
Lower-priority idle functions are run first. Idle functions with no
specified priority default to 5 and all functions with the same priority
are run in the order in which they are evaluated, meaning the behaviour
is backwards compatible.

Updated documentation as well.
2014-03-17 10:03:06 +01:00
Jonas Bernoulli
f32d24350c use-package-font-lock-keywords: add use-package-with-elapsed-timer 2014-03-09 18:59:06 +01:00
Jonas Bernoulli
2d7ecd867a use-package-with-elapsed-timer: add declare indent rule 2014-03-09 18:55:54 +01:00
Jonas Bernoulli
ea3a475d0b use-package-with-elapsed-timer: respect option at runtime
Previously the option `use-package-verbose' was consulted at macro
expansion time, and as a result customizing the option did nothing,
without also recompiling `use-package.el'.
2014-03-09 18:53:05 +01:00
Nicolas Richard
dd937c4e36 Move tests to separate file 2014-02-12 22:30:12 +01:00
Nicolas Richard
2676ff5d95 Allow multiple forms after keywords
* use-package.el (use-package-mplist-get):
(use-package-plist-get):
(use-package-mplist-keys): new functions

(plist-get-value):
(use-package): use new functions

(plist-keys): remove function

The idea is to allow a modified kind of plist where keys are all
keywords that appear in the list, and values are the intermediary
elements. If a keyword is present but it's another keyword just after it
(like (use-package :defer :config (setq foo 'bar))), its associated
value will be t. If a keyword is not present, its value associated value
will be nil. Otherwise the value will be the list of elements between
the keyword and the next keyword.
2014-02-10 18:57:27 +01:00
Adam Spiers
8f7e878caf add 'use-package-' prefix to 'with-elapsed-timer'
Fixes https://github.com/jwiegley/use-package/issues/35.
2014-01-06 17:22:39 +00:00
Adam Spiers
2dbee4cd75 fix DRY violation by only having documentation in one place
The documentation in README.md was previously identical to that
in the Commentary section of use-package.el, modulo the following
differences:

  - No elisp comment ";; " prefix
  - Code blocks indented 4 columns not 2, as required by Markdown
  - Elisp symbols marked in backtick delimiters for monospace, not
    emacs backtick/forward tick pairs.

Unfortunately due to this duplication, sometimes only one of the
two files got updated, so they got out of sync.  With us all being
human, this is likely to continue to happen as long as the
duplication exists ;-)  Therefore since most users are likely to
encounter README.md before the elisp, and bearing in mind that
Markdown is a much more flexible format for documentation than
elisp comments (richer formatting, can be exported to numerous
other formats etc.), it is better to replace the docs in
use-package.el with a pointer to the README.md.
2014-01-06 13:57:55 +00:00
Adam Spiers
75206228dd allow :mode and :interpreter to accept a string
Fixes https://github.com/jwiegley/use-package/issues/72.
2013-12-16 13:57:32 +00:00
Jonas Bernoulli
d588d0b382 use-package: use defun as lisp-indent-function
When `use-package' is called with only one keyword it is useful to
write:

(use-package foo :init
  (progn
    ... long lines ...))

instead of

(use-package foo
  :init (progn
  	  ... *too* long lines ...))

or

(use-package foo
  :init
  (progn
    ... long lines ...))

Even when there are multiple keywords or when one never wants to format
the calls to `use-package' as in the first example the use of `defun'
does not really pose a problem.
2013-12-10 00:44:11 +01:00