How to Quickly Get evil-mc Working With Smartparens
A quick and dirty way of getting Emacs' evil-mc and smartparens packages to play nicely together, so you can use multiple cursors with s-expression editing.
evil-mc is great for working with multiple cursors and smartparens is great for working with lispy s-expressions. But can they work nicely together without putting in a lot of effort writing glue between the two?
It turns out that they can! By my estimate, this simple approach works for 90% of the use cases:
(after! (:and evil-mc smartparens) (dolist (sp-command '(sp-up-sexp sp-copy-sexp sp-down-sexp sp-join-sexp sp-kill-sexp sp-next-sexp sp-split-sexp sp-wrap-curly sp-wrap-round sp-raise-sexp sp-clone-sexp sp-wrap-square sp-splice-sexp sp-end-of-sexp sp-forward-sexp sp-backward-sexp sp-convolute-sexp sp-transpose-sexp sp-kill-whole-line sp-beginning-of-sexp sp-forward-barf-sexp sp-forward-slurp-sexp sp-backward-barf-sexp sp-backward-slurp-sexp sp-splice-sexp-killing-forward sp-splice-sexp-killing-backward)) (add-to-list 'evil-mc-custom-known-commands `(,sp-command (:default . evil-mc-execute-call)))))
Not every smartparens command will work seamlessly with the virtual cursors from evil-mc (the
sp-wrap family are particularly quirky) but they all do work to some degree, which means you can still get things done quicker — now with the power of both packages!