[Top][All Lists]

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

Re: use-package

From: Kaushal Modi
Subject: Re: use-package
Date: Wed, 04 May 2016 03:33:45 +0000

> In my point of view, the job that use-package does is only useful when
> the corresponding package is poorly setup to start with.

> IOW, if use-package is helpful, usually it indicates a shortcoming in
> the package or in the way the package is installed.

That, or the user installing the package is just not completely aware of
implications of during (require 'PKG-NAME) for all the installed packages.

I can talk of myself that when I began using emacs, I simply did (require
'PKG-NAME) for any new package I installed, because sometimes I got errors
like undefined variable blah at emacs startup. And using the require
magically solved the problem.

For instance, we cannot do (add-to-list 'package-archives '("org" . "";) t) before doing (require 'package). Well, this
is a valid case where we need to do require first as package-archives does
not autoload package.

At one point, it became a "style" to require all the installed packages. I
had never head of eval-after-load at that time. Even if I had heard, I
would have thought that that's probably for "advanced" emacs user and I as
a newbie probably doesn't need to learn or use that.

use-package adds a simply syntactic sugar that does that "advanced stuff"
under the hood.

Another useful function that use-package uses is run-with-idle-timer using
which you can lazy load a package which you typically don't care about
loading immediately at startup.. like yasnippet; by using the :defer
keyword in use-package.

I am not qualified enough to judge if yasnippet could have been coded
better so that I didn't need to lazy load it. But delaying loading this
package made a significant difference to my emacs startup, especially
because I save and load desktop with about 50-60 files open. I do not need
yasnippet to load the snippets for all the major modes in those 50-60 files
immediately at startup.

That's right.  But that's already the case without doing any config at
> all (because org-mode is setup properly to start with), so you shouldn't
> need use-package for that.

That's correct. The syntactic sugar for eval-after-load applies here too.

(Also, it's easy to simply prevent loading of a package you suspect to be
misbehaving by adding :disabled keyword for that package's use-package
form. With that you prevent loading that package and also evaluating your
config for that package like keybindings, advices, overrides, wrapper
defuns, etc).

> I see use-package as having 2 benefits:
> - work around package shortcomings as described above.
> - help the user structure his .emacs configuration.

And also, get a new user acquaint themself to different ways by which a
package loading can be delayed using various use-package keywords like
:commands, :bind, :defer, :mode.

> I'd like to see those two parts separated, FWIW.

I don't understand why that is important.

Kaushal Modi

reply via email to

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