Emacs configuration and use-package
Posted: - Modified: | emacsWatching the second Experimental Emacs Hangout nudged me to improve how I use use-package in my Emacs configuration.
I had been using use-package
‘s :init
and :config
keywords as a more readable and less-error-prone versions of eval-after-load
. (Well, technically, :init
happens before it's loaded, and :config
is evaluated after it fully loads.) I also used :bind
for global keybindings.
I didn't know about :ensure
and :diminish
. Adding :ensure
let me get rid of my custom sacha/package-install
function, and :diminish
let me remove a few lines related to my modeline.
One of the benefits of sharing my configuration is that other people pick up ideas, and then I pick up more ideas from their ideas. I get an excuse to revisit packages that may have added features since the last time I checked them out. I learn from other people's combinations and customizations.
There's so much to learn about Emacs, even just in terms of the packages that I've already configured. Sometimes I start with just the basics and settle into a routine, forgetting that there are even more things I can do. Sometimes people make incompatible changes, and I have to figure out how to adapt. Sometimes packages become unmaintained, and eventually replacements emerge. Always, always, people write more code, add more features, extend Emacs to do more things. It's never just about what new things I can do. It's also about this community of people who tickle their brains by building cool stuff, who follow “What if?” to interesting places.
Anyway. :ensure
and :diminish
, and a few improvements to my config. (Also because I just switched to the 64-bit binary for Emacs 24.4, how exciting…)
Hat-tip to @gozes for nudging me to write about this – back in April!
7 comments
mwfogleman
2014-12-08T15:30:10ZAnother feature of use-package that I didn't know about for a while was the ins and outs of the bind-key package.
It looks like you mostly use bind-key. You can also do bind-keys, which, like setq, can take multiple pairs. It can also take a keymap with the :map keyword.
You can search for "bind-keys" in my configuration for some examples.
https://github.com/mwfoglem...
Also, check out the documentation in bind-key.el:
https://github.com/jwiegley...
One gem in there is the describe-personal-keybindings function.
Fuco of Smartparens fame is responsible for the bind-keys macro- thanks Fuco!
D. Elroy
2014-12-09T10:25:24ZI really like your config... I've read through all of it, and as soon as I get home I start copying some of it in mine! It also motivated me to migrate to package-use.
Thanks
pb
2014-12-11T07:54:47ZTip: You can simply write ":ensure t" instead of spelling out the package name each and every time.
John Kitchin
2015-03-01T23:35:18ZHave you used cask? Are there different use cases for these?
sachac
2015-03-02T02:22:24ZI use use-package and package.el because I think the process for adding, using, and configuring packages on the fly is easier with them than with Cask, but I've seen Cask used for, say, ensuring development dependencies while creating Emacs packages. I think that's the difference between the two use cases, but I could be mistaken. =)
JohnKitchin
2015-03-02T12:35:54ZThanks. That matches my current understanding too. It seems like use-package pretty conveniently installs and configures packages. I have seen cask for creating and installing packages, but not for configuring them yet.