[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: use-package.el -> Emacs core

From: Phillip Lord
Subject: Re: use-package.el -> Emacs core
Date: Tue, 10 Nov 2015 12:01:32 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

João Távora <address@hidden> writes:

> Pedro Silva <address@hidden> writes:
>> :ensure (automatic ELPA installation), :defer (lazy loading) and
>> :commands (autoloading) are the things I most use in `use-package'
>> that are not as easy to achieve with `with-eval-after-load'.
> Not as easy? Sure, more characters, but basically the same complexity. I
> don't think it's worth a whole new language to be able to replace:
>   (package-install 'foo)

> Especially given that the use-package versions force the reader (or the
> grepper) to look around for context, while the regular versions don't.

use-package introduces a single (documented) form. So, it's easy to
re-eval everything, and keeps all your code in one place. Trivial as
this sounds, this is actually pretty useful.

In your examples, you need to "progn" everything to achieve the same.

> But perhaps I'm misinterpreting what these directives actually do, or
> perhaps you can illustrate with some snippets of your own.

What use-package does is syntactic sugar for sure, but it also does add
some nice functionality. So, for example, this

(use-package foo
  :load-path "~/foo"
  :commands foo-a foo-b foo-c
  :defer 5

actually does this...

    (push "~/foo" load-path))
  (run-with-idle-timer 5 nil #'require 'foo nil t)
      (fboundp 'foo-a)
    (autoload #'foo-a "foo" nil t))
      (fboundp 'foo-b)
    (autoload #'foo-b "foo" nil t))
      (fboundp 'foo-c)
    (autoload #'foo-c "foo" nil t)))

while the apparently much simpler:

(use-package foo
  :load-path "~/foo"

actually does this:

    (push "~/foo" load-path))
    (message "%s..." "Loading package foo")
             (require 'foo nil 'noerror))
              (format "Could not load %s" 'foo))))
            (> elapsed 0.1)
            (message "%s...done (%.3fs)" "Loading package foo" elapsed)
          (message "%s...done" "Loading package foo"))))))

A useful system for working out why your .emacs is so slow to load.

*shrugs*. I really like it, and it's made my .emacs cleaner.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]