reddit / emacs

Alternatives to `map!` macro for non-doom users?

stuudente · 2022-01-24 02:58
Doom has been nice! Thanks for all the contributors! But I decide to live independent to it. One immediate obstacle is the loss of the mighty `map!` macro. What are some alternatives for undoomed+evil users? I've heard that `general.el` is quite good, but is it as powerful as `map!`? And if so, are there some role-model configs to learn from? --- **EDIT** While `map!` is a macro built on top of general, it doesn't seem to be thin.. [source](https://github.com/hlissner/doom-emacs/blob/master/core/core-keybinds.el).
todo-anonymize-self · 2022-01-24 03:05
`map!` is just a thin wrapper on top of `general.el`, so go with that.
stuudente · 2022-01-24 03:33
Doesn't seem to be thin.. [source](https://github.com/hlissner/doom-emacs/blob/master/core/core-keybinds.el).
todo-anonymize-self · 2022-01-24 03:36
Yeah, it's a lot of shenanigans but it is technically thin as it ends up just generating `general.el` sexprs and then evaluating them when it's done. Source: I wrote a thin wrapper on top of `map!`, then decided I should make something useful for any Emacs, not just tied to Doom.
7890yuiop · 2022-01-24 06:16
> I've heard that general.el is quite good, but is it as powerful as map! It's all `define-key` eventually, no?
stuudente · 2022-01-24 14:07
Eventually it's all about byte codes too! Abstraction matters.
stuudente · 2022-01-24 14:08
Cool. Do you know if one can easily use `map!` without doom?
todo-anonymize-self · 2022-01-24 16:24
Mh. Good question; not sure; think so. Probably just try copying `core-keybinds.el` and evaluating in vanilla Emacs. You'll need: * `IS_MAC` and `IS_WINDOWS` \- tiny macros. * ~~general.el~~ \- `core-keybinds.el` has the `use-package` for it actually. * `which-key`, maybe? * `doom-lookup-key` * Probably some more funcs/vars to track down but I don't think many. Or you could look [here](https://github.com/hlissner/doom-emacs/blob/c7753adbb301dcb647dc96d182c28b228551890e/core/core-keybinds.el#L341) and macro expand pretty print (forget func name) instead of macro expand eval the final `general.el` sexprs: `(nreverse (delq nil doom--map-forms))`. And just take those with you to normal `general.el`.
7890yuiop · 2022-01-24 17:50
I just meant that the potential for "power" seems kinda limited, if binding keys is the scope.