What does HackerNews think of use-package?
A use-package declaration for simplifying your .emacs
> 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.
I found use-package, try elisp packages make it easy to try new packages in emacs.
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 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/
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...
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.
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. :-)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
https://github.com/jwiegley/use-package
So my .emacs/init.el looks like
(use-package helm-projectile
:ensure t
:config (helm-projectile-on)
)
[1] - https://github.com/jwiegley/use-package [2] - https://github.com/jrosdahl/iflipb
As an example here's my package init using use-package: https://github.com/stafu/.emacs.d/blob/master/init/init-pack...