What does HackerNews think of use-package?

A use-package declaration for simplifying your .emacs

Language: Emacs Lisp

#3 in Emacs
> Deps is well documented.

> The issue I personally found is that I needed to look at a bunch of OS project's deps.edn to see how people commonly structure things. Other than that it is a simple tool.

This seems like a contradiction, because if it was well documented you wouldn’t need to look at other people’s configs to see how to use it.

My experience with deps.edn is that every time I start a project and make a deps.edn file, I immediately draw a blank and don’t know how to structure it, so I open ones from other projects to start lifting stuff out of them.

I still don’t know how to reliably configure a project to use nrepl or socket repl without just using an editor plugin. I definitely have no idea how to use those in conjunction with a tool like reveal.

To me, none of that is simple. Simple would be like Emacs’ use-package. With that I know how to add dependencies, specify keybinds, and do initialization and configuration off the top of my head knowing only the name of a package I want to use. And it has really nice documentation with tons of examples.

https://github.com/jwiegley/use-package

Agreed, on approachable defaults for VSCode.

I found use-package, try elisp packages make it easy to try new packages in emacs.

https://github.com/jwiegley/use-package

https://github.com/larstvei/Try

On Windows, probably the easiest way is to use Scoop [0]. You can then install org-mode with `M-x package-install org-plus-contrib`

If you want to set it up in your `~/.emacs.d/init.el` config, you can use something like `use-package` [1] to make the installation easier :

```elisp (add-to-list 'package-archives '("Org" . "https://orgmode.org/elpa/")) (use-package org :ensure org-plus-contrib :mode ("\\.org\\'" . org-mode) ) ```

[0]: https://jrhawley.ca/2020/03/08/emacs [1]: https://github.com/jwiegley/use-package

I tried Rudel a little while ago, and I just had some troubles. Probably my fault. I wasn't nearly as well-versed with Emacs back then.

I just tried crdt.el[^1] and holy crap that's cool. I love that it's all built in Emacs, like, there's no special server I have to run to get this to work. I'm blown away.

I use straight.el[^2] and use-package[^3] for package management; if you want to give crdt.el a whirl, just use this:

    (use-package crdt
      :straight (crdt :type git :repo "https://code.librehq.com/qhong/crdt.el"))
A fun alternative if you're in the terminal is tmate[^4], which is a fork of tmux. That one uses a central server to negotiate the connection though, I believe.

[^1]: https://code.librehq.com/qhong/crdt.el

[^2]: https://github.com/raxod502/straight.el

[^3]: https://github.com/jwiegley/use-package

[^4]: https://tmate.io/

I would suggest a step further: start with Spacemacs/Doom, but if you decide to stick around, try to build your own Emacs configuration based on the part of Spacemacs/Doom that you like.

Thanks to the amazing use-package[1] macro (which Spacemacs/Doom also uses) most configurations are self-contained to a certain extent. Searching for use-package in GitHub[2] will yields plenty of results which can be mostly be taken as a reference for your own liking. It should be relatively easy to port part of Spacemacs/Doom to vanilla use-package, e.g. starting with this (which sets up use-package alongside with evil):

    (require 'package)
    (setq package-enable-at-startup nil)
    (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))

    (package-initialize)
    (unless (package-installed-p 'use-package)
      (package-refresh-contents)
      (package-install 'use-package))

    (eval-when-compile
      (require 'use-package))

    (use-package evil
      :ensure t
      :config
      (evil-mode t) 

    (use-package evil-leader
      :after evil
      :ensure t
      :config
      (evil-leader/set-leader "")
      (global-evil-leader-mode t))
To add Magit, one could take a look at Spacemacs's git/packages.el[2], search documentation on what each package does, and proceed on porting configuration, only the part that you actually uses, e.g.:

    (use-package evil-magit
      :ensure t
      :after (magit evil))

    (use-package magit
      :ensure t
      :config
      (evil-leader/set-key ("gs" #'magit-status))
Since most configurations based on use-package are self-contained, when stuck I also like to use GitHub search to look on how other people configure a certain package[3]. In most cases the configuration should be reusable as-is.

Finally, use-package is highly extensible. There is straight.el[4] which adds extension to use-package to fetch from Git and pin a version in a lockfile, which adds reproducibility to Emacs configuration. There's also el-patch[5] from the same author that allows patching package on the fly without the need to maintain separate forks.

[1]: https://github.com/jwiegley/use-package

[2]: https://github.com/syl20bnr/spacemacs/blob/d46eacd83842815b2...

[3]: https://github.com/search?l=Emacs+Lisp&p=4&q=use-package&typ...

[4]: https://github.com/raxod502/straight.el

[5]: https://github.com/raxod502/el-patch

I'm a moderately experienced Emacser - been using it heavily since 2009 (first encountered it in 2003). I have written a few small extensions and contributed features and bug fixes to bigger ones.

Credentials established, I cannot recommend this tutorial enough:

https://david.rothlis.net/emacs/tutorial.html

He walks you through most of the core of what makes Emacs great by showing you how to make a change to a project in the idiomatic Emacs way.

I would have learned it years faster had I started there.

Beyond that, learn basic Emacs keybindings via the tutorial, as others have suggested.

I started in Emacs but installed evil-mode a few years ago and have never looked back.

I do not recommend Spacemacs. Install the tools you want as you find you want them, so that you know what's doing what, and so you have a decent chance of knowing what broke things when something stops working.

Keep your packages in version control as part of your .emacs.d repository. That keeps updates and deleted packages from screwing you.

Use "use-package" (https://github.com/jwiegley/use-package) for configuring what you install. It's written by one of the Emacs maintainers and will help you do things right by default.

I'm not the best Emacser out there, but if you're curious, my config is on my GitHub account: https://github.com/NateEag/.emacs.d

Happy hacking.

Spacemacs does indeed use evil.

I found Spacemacs to be great starting point for someone new to Emacs, but after a while I highly recommend extracting your workflow from Spacemacs to vanilla Emacs.

Thanks to use-package[1] (that Spacemacs also uses), most of the extracting would be just copy and pasting things from Spacemacs repo. The hardest part would be figuring out which package is responsible for which functionality. A starting point would be just put this in ~/.emacs.d/init.el:

    (require 'package)
    (setq package-enable-at-startup nil)
    (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))

    (package-initialize)
    (unless (package-installed-p 'use-package)
      (package-refresh-contents)
      (package-install 'use-package))

    (eval-when-compile
      (require 'use-package))

    (use-package evil
      :ensure t
      :config
      (evil-mode t)
And now you got a working vanilla Emacs with evil auto-installed, ready to be put in VCS. After extracting work is done, it will open up a new world of customization (even a low-level things such as replacing package.el with straight.el[2] to enjoy configuration reproducibility) as you now know exactly how every piece fits together. :-)

[1]: https://github.com/jwiegley/use-package

[2]: https://github.com/raxod502/straight.el

i wouldn't recommend keeping your elpa packages in dropbox if you sync between different operating systems. i've run into issues where auxiliary binaries were giving me trouble.

instead, you can use use-package [0] and keep your configuration files in dropbox/syncthing.

[0] one of emacs's killer libraries, imo. a brilliant package configuration system that i don't believe vimL could ever support: https://github.com/jwiegley/use-package

Actually, Spacemacs layer configuration uses the use-package add-on ( https://github.com/jwiegley/use-package ) , which helps greatly simplifies and organizes large .emacs config files (and also greatly improves emacs' startup time). use-package was written by John Wiegley, created of the Ledger CLI accounting software, and current maintainer of Emacs. Emacs integration of packages with Melpa gets only a small part of the way towards where Wiegley goes with use-package. . . .
I only have two emacs installs, home and work. But I keep them in sync, kinda, using:

https://github.com/jwiegley/use-package

So my .emacs/init.el looks like

  (use-package helm-projectile
    :ensure t
    :config (helm-projectile-on)
  )
That makes sense. I actually never use daemon mode because I don't want to share buffers. If want a faster start up time but don't want to share buffers you may want to look at use-package[1] which will lazy load plugins. Also, if you want a easy way to cycle through buffers that also works in the terminal I recommend iflipb[2]. When you start cycling, it shows a list of buffers in the mini-buffer. Both of those are available as packages in Melpa.

[1] - https://github.com/jwiegley/use-package [2] - https://github.com/jrosdahl/iflipb

John Wiegley is the author of (completely awesome in my opinion) use-package for emacs https://github.com/jwiegley/use-package
That is one part of it, but it has a lot of other benefits too. I recently switched to using use-package to do all my package installation and configuration, and my emacs-init-time improved dramatically because use-package can set up smart deferring of loading based on commands or bindings. It's worth having a read through the repo readme: https://github.com/jwiegley/use-package

As an example here's my package init using use-package: https://github.com/stafu/.emacs.d/blob/master/init/init-pack...