Emacs configuration and use-package

Posted: - Modified: | emacs

Watching 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!

You can view 7 comments or e-mail me at sacha@sachachua.com.

7 comments

Another 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!

I 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

Tip: You can simply write ":ensure t" instead of spelling out the package name each and every time.

John Kitchin

2015-03-01T23:35:18Z

Have you used cask? Are there different use cases for these?

I 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:54Z

Thanks. 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.