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.
* 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))
* 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
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.
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'.
* 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.
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.
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.
This allows use of variables or even arbitrary expressions to construct
use-package arguments:
(use-package some-package
:mode ,mode-spec
:bind (,binding
,@more-bindings
,@(cl-loop for i from ?a to ?z
collect `(,(string i) . nifty-function))))
This function was not working as advertised.
Then `funcall` was evaluated too early and all the benefits of late evaluation for autoloads was lost.
Furthermore, this function was not really needed in the first place:
```
(use-package foo
:config my-foo-function)
```
can easily be replaced by the following:
```
(use-package foo
:config (my-foo-function))
```
This change an extra level on indirection for two cases:
+ when an association or an alist is required, it is possible to pass a
variable containing an association or an alist
+ when a sexp to be evaluated is required, it is possible to pass a
function instead
Fixes https://github.com/jwiegley/use-package/issues/52: the :config block would be triggered when loading a config
file with the same name as the package and again when loading the
package itself.
The commit 57f80d4 fixed the highlight by following the regexp as for
require. However in Emacs truck, it only highlights first part of the
package name.
This change follows the regexp for require on emacs truck. See line
2327 on font-lock.el in the following patch.
http://bzr.savannah.gnu.org/lh/emacs/trunk/revision/111821