[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: using use-package
From: |
Sebastien Vauban |
Subject: |
Re: using use-package |
Date: |
Tue, 11 Aug 2015 11:20:11 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (windows-nt) |
phillip.lord@russet.org.uk (Phillip Lord) writes:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> Or to take another example from https://github.com/jwiegley/use-package:
>>
>> (use-package foo
>> :init
>> (setq foo-variable t)
>> :config
>> (foo-mode 1))
>>
>> For any properly written foo-mode, the above can be replaced with
>>
>> (setq foo-variable t)
>> (foo-mode 1)
>>
>> and it should work just as well.
>
> No, you are missing (several) points of use-package. First (and
> trivially) the use-package statement groups everything syntactically.
> So, it's more like:
>
> (progn
> (setq foo-variable t)
> (foo-mode 1))
>
> This is nicer because it groups all the configuration together, so you
> can move, comment, delete or eval it all together. Of course, `progn'
> achieves the same thing.
>
> However, `use-package' also gives you configurable feedback on load
> times. So if (require 'foo) takes a long time, use-package tells you,
> and tells you how long it takes.
>
> In your example,
>
> (foo-mode 1)
>
> will force an autoload. With use-package, also I can do
>
> (use-package foo
> :defer t
> ;;;etc
> )
>
> which will achieve the same.
Just wanted to share how I do *some* of the above points in my config
file. Here an example for `diff-hl', which indicates changes in the
fringe:
--8<---------------cut here---------------start------------->8---
(with-eval-after-load "diff-hl-autoloads"
(idle-require 'diff-hl))
(with-eval-after-load "diff-hl"
(global-diff-hl-mode)
(define-key diff-hl-mode-map (kbd "C-x v >") 'diff-hl-next-hunk)
(define-key diff-hl-mode-map (kbd "C-x v <") 'diff-hl-previous-hunk))
--8<---------------cut here---------------end--------------->8---
This is somehow trying to achieve (part of) the same goals as
`use-package', but with standard Emacs (more or less, as `idle-require'
is not in core).
You see:
- Differed load via the idle-require' package (otherwise, I just write
"require")
- Nice grouping of all customizations at the same place,
To disable it, I'll edit the code and add "-XXX" in the first
`with-eval-after-load':
--8<---------------cut here---------------start------------->8---
(with-eval-after-load "diff-hl-autoloads-XXX" ; Diff-hl won't be req'ed
(idle-require 'diff-hl))
--8<---------------cut here---------------end--------------->8---
Of course, I miss, for example, the real execution time of that block,
once executed/loaded (and you can't advice a macro such as
`with-eval-after-load', right, to add timings?).
And I do have all ELPA paths in `load-path' unlike John (IIUC), though
I don't understand yet how it works (differently) with `use-package'.
Interested by comments...
Best regards,
Seb
--
Sebastien Vauban
- Re: using use-package, (continued)
- Re: using use-package, Stefan Monnier, 2015/08/08
- Re: using use-package, Grant Rettke, 2015/08/09
- Re: using use-package, Phillip Lord, 2015/08/10
- Re: using use-package, Stefan Monnier, 2015/08/10
- Re: using use-package, Phillip Lord, 2015/08/10
- Message not available
- Re: using use-package, Rusi, 2015/08/10
- Re: using use-package, John Wiegley, 2015/08/11
- Re: using use-package, Stefan Monnier, 2015/08/11
- Re: using use-package, Phillip Lord, 2015/08/11
- Re: using use-package, John Wiegley, 2015/08/12
- Message not available
- Re: using use-package,
Sebastien Vauban <=
- Re: using use-package, Nicolas Richard, 2015/08/11
- Re: using use-package, Alexis, 2015/08/11
- Re: using use-package, Nicolas Richard, 2015/08/11
- Re: using use-package, Alexis, 2015/08/11
- Re: using use-package, Phillip Lord, 2015/08/11
- Message not available
- Re: using use-package, Rusi, 2015/08/12
- Re: using use-package, Ian Zimmerman, 2015/08/12
- Re: using use-package, Stefan Monnier, 2015/08/12
- Re: using use-package, tomas, 2015/08/13
- Re: using use-package, Stefan Monnier, 2015/08/13