unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Sebastien Vauban <sva-news-D0wtAvR13HarG/iDocfnWg@public.gmane.org>
To: help-gnu-emacs-mXXj517/zsQ@public.gmane.org
Subject: Re: using use-package
Date: Tue, 11 Aug 2015 11:20:11 +0200	[thread overview]
Message-ID: <86h9o6kwqc.fsf@example.com> (raw)
In-Reply-To: mailman.8067.1439200345.904.help-gnu-emacs@gnu.org

phillip.lord-WS8JpuUeUJXe9xe1eoZjHA@public.gmane.org (Phillip Lord) writes:
> Stefan Monnier <monnier-CRDzTM1onBSWkKpYnGOUKg@public.gmane.org> 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


  parent reply	other threads:[~2015-08-11  9:20 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.7817.1438700509.904.help-gnu-emacs@gnu.org>
2015-08-05  5:35 ` using use-package Rusi
2015-08-05  5:57   ` Ian Zimmerman
     [not found]   ` <mailman.7832.1438754275.904.help-gnu-emacs@gnu.org>
2015-08-05 16:34     ` Rusi
2015-08-05 17:24       ` Ian Zimmerman
     [not found]       ` <mailman.7851.1438795470.904.help-gnu-emacs@gnu.org>
2015-08-06  1:34         ` Rusi
2015-08-06  1:54           ` Ian Zimmerman
     [not found]           ` <mailman.7873.1438826104.904.help-gnu-emacs@gnu.org>
2015-08-06  5:06             ` Rusi
2015-08-07 20:11               ` Grant Rettke
     [not found]               ` <mailman.7956.1438978281.904.help-gnu-emacs@gnu.org>
2015-08-08  2:36                 ` Rusi
2015-08-08 23:24                   ` Stefan Monnier
2015-08-10  2:25                     ` Grant Rettke
2015-08-10  9:52                     ` Phillip Lord
2015-08-10 21:25                       ` Stefan Monnier
2015-08-10 22:32                         ` Phillip Lord
     [not found]                       ` <mailman.8096.1439241947.904.help-gnu-emacs@gnu.org>
2016-06-28 13:02                         ` Rusi
2016-06-28 13:10                           ` Phillip Lord
     [not found]                           ` <mailman.235.1467119445.26859.help-gnu-emacs@gnu.org>
2016-06-28 13:14                             ` Rusi
2016-06-28 13:30                               ` Phillip Lord
2016-06-28 22:05                                 ` Stefan Monnier
2016-06-28 22:34                                   ` Phillip Lord
2016-06-29  7:38                                     ` Stefan Monnier
2016-06-29 17:02                                       ` Phillip Lord
2016-06-29 17:15                                         ` Drew Adams
2016-06-29 17:20                                           ` Phillip Lord
2016-06-30  7:25                                         ` Stefan Monnier
2016-06-30  9:04                                           ` Stefan Monnier
2016-06-30 14:03                                           ` Phillip Lord
2016-06-30 18:32                                             ` Stefan Monnier
2016-06-29  7:28                                   ` Andreas Röhler
2015-08-11  5:44                     ` John Wiegley
2015-08-11 15:22                       ` Stefan Monnier
2015-08-11 20:36                         ` Phillip Lord
2015-08-12 16:09                         ` John Wiegley
     [not found]                     ` <mailman.8067.1439200345.904.help-gnu-emacs@gnu.org>
2015-08-10 12:14                       ` Rusi
2015-08-11  9:20                       ` Sebastien Vauban [this message]
2015-08-11 10:04                         ` Nicolas Richard
2015-08-11 11:05                           ` Alexis
2015-08-11 11:16                             ` Nicolas Richard
2015-08-11 11:25                               ` Alexis
2015-08-11 20:42                         ` Phillip Lord
     [not found]                     ` <mailman.8114.1439272212.904.help-gnu-emacs@gnu.org>
2015-08-12 17:52                       ` Rusi
2015-08-12 18:20                         ` Ian Zimmerman
2015-08-13  1:13                           ` Stefan Monnier
2015-08-13  7:25                             ` tomas
2015-08-13 15:08                               ` Stefan Monnier
2015-08-13 20:14                                 ` tomas
     [not found]                                 ` <mailman.8280.1439496850.904.help-gnu-emacs@gnu.org>
2015-08-13 20:31                                   ` Stefan Monnier
2015-08-13 21:11                                     ` tomas
2015-08-13 21:52                                     ` Michael Heerdegen
2015-08-13 22:10                                       ` Stefan Monnier
2015-08-13 22:12                                       ` John Mastro
2015-08-13 22:25                                         ` Rasmus
2015-08-13 22:50                                           ` Stefan Monnier
2015-08-15 13:56                                             ` Rasmus
     [not found]                                             ` <mailman.8383.1439647006.904.help-gnu-emacs@gnu.org>
2015-08-15 15:46                                               ` Stefan Monnier
2015-08-14  4:09                                       ` Thierry Volpiatto
2015-08-13  9:07                             ` John Wiegley
2015-08-13 12:40                             ` Phillip Lord
2015-08-13 15:24                               ` Stefan Monnier
2015-08-13 16:02                                 ` Phillip Lord
2015-08-13 21:19                                   ` Stefan Monnier
2015-08-14  9:16                                     ` Phillip Lord
     [not found]                                     ` <mailman.8319.1439543792.904.help-gnu-emacs@gnu.org>
2015-08-14 13:59                                       ` Stefan Monnier
2015-08-14 14:41                                         ` Phillip Lord
     [not found]                                         ` <mailman.8328.1439563291.904.help-gnu-emacs@gnu.org>
2015-08-14 16:54                                           ` Stefan Monnier
     [not found]                                 ` <mailman.8263.1439481769.904.help-gnu-emacs@gnu.org>
2015-08-13 16:15                                   ` Stefan Monnier
2015-08-13 18:40                                     ` John Wiegley
2015-08-14  2:21                                     ` John Yates
2015-08-14  9:35                                     ` Phillip Lord
     [not found]                                     ` <mailman.8304.1439518900.904.help-gnu-emacs@gnu.org>
2015-08-14 13:51                                       ` Stefan Monnier
2015-08-14 16:10                                         ` John Yates
     [not found]                                     ` <mailman.8321.1439544925.904.help-gnu-emacs@gnu.org>
2015-08-14 14:04                                       ` Stefan Monnier
2015-08-14 14:49                                         ` Drew Adams
2015-08-14 16:06                                           ` Phillip Lord
2015-08-14 17:41                                             ` Drew Adams
     [not found]                           ` <mailman.8226.1439428438.904.help-gnu-emacs@gnu.org>
2015-08-13  2:07                             ` Rusi
     [not found]                   ` <mailman.7988.1439076276.904.help-gnu-emacs@gnu.org>
2015-08-09  2:43                     ` Rusi
2015-08-09 13:17                       ` Stefan Monnier
2015-08-09 16:14                         ` Rusi
2015-08-09 16:25                           ` Emanuel Berg
2015-08-09 16:45                           ` Stefan Monnier
2015-08-09 17:03                             ` Rusi
2015-08-09 17:17                               ` Stefan Monnier
2015-08-09 17:30                                 ` Rusi
2015-08-09 17:45                                   ` Stefan Monnier
2015-08-11  1:23                                   ` Robert Thorpe
2015-08-11  2:05                                     ` Emanuel Berg
2015-08-11 20:49                                     ` Phillip Lord
2015-08-13 15:27                                       ` Stefan Monnier
2015-08-14  5:12                                         ` Nikolay Kudryavtsev
2015-08-14  5:23                                           ` Edward Knyshov
2015-08-14  6:28                                             ` Nikolay Kudryavtsev
2015-08-14  6:44                                               ` Edward Knyshov
2015-08-14  6:46                                                 ` Edward Knyshov
2015-08-14  6:47                                                   ` Edward Knyshov
2015-08-14  9:29                                             ` Phillip Lord
     [not found]                                   ` <mailman.8104.1439256204.904.help-gnu-emacs@gnu.org>
2015-08-12 17:46                                     ` Rusi
2015-08-10  2:19                   ` Grant Rettke
     [not found]                   ` <mailman.8054.1439173196.904.help-gnu-emacs@gnu.org>
2015-08-10  3:41                     ` Rusi
2015-08-04 15:01 Sharon Kimble
2015-08-04 15:46 ` Chunyang Xu
2015-08-04 16:35 ` Phillip Lord
2015-08-04 18:24   ` Sharon Kimble
2015-08-04 19:18     ` Grant Rettke
2015-08-04 21:24     ` Phillip Lord
2015-08-05  1:20       ` Grant Rettke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86h9o6kwqc.fsf@example.com \
    --to=sva-news-d0wtavr13harg/idocfnwg@public.gmane.org \
    --cc=help-gnu-emacs-mXXj517/zsQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).