I’ve said before that clj-refactor is a magical package, and you wouldn’t catch
me bad-mouthing it in a million release cycles, but it’s impossible to please
everybody.
One consistent annoyance I have with it, is that I always have to type Tab
twice after invoking cljr-add-require-to-ns. That’s because I only ever use
requires of the form [x.y :as y], so I always have to skip the first two
“modes” offered by the snippet.
As I was teaching a friend about this command last week, he immediately asked me
if you couldn’t just write some Elisp to do that for you. Of course, the answer
is yes. And that’s exactly what I did — once I was done feeling embarrassed
that I hadn’t thought of that before.
Note that this uses the new advice interface, which relies on Emacs 24.5. While
this API in its entirety can be quite intimidating, you don’t need to learn it
all in one go. You can go a long way (and make your life a lot easier) by just
writing yourself a few :before and :after advices.
Just remember to be responsible. Advices let you run code in places where
packages don’t expect code to be run. So don’t be surprised if something else
breaks.
A small improvement to clj-refactor
15 Mar 2016, by Artur Malabarba.I’ve said before that clj-refactor is a magical package, and you wouldn’t catch me bad-mouthing it in a million release cycles, but it’s impossible to please everybody.
One consistent annoyance I have with it, is that I always have to type Tab twice after invoking
cljr-add-require-to-ns
. That’s because I only ever use requires of the form[x.y :as y]
, so I always have to skip the first two “modes” offered by the snippet.As I was teaching a friend about this command last week, he immediately asked me if you couldn’t just write some Elisp to do that for you. Of course, the answer is yes. And that’s exactly what I did — once I was done feeling embarrassed that I hadn’t thought of that before.
Note that this uses the new advice interface, which relies on Emacs 24.5. While this API in its entirety can be quite intimidating, you don’t need to learn it all in one go. You can go a long way (and make your life a lot easier) by just writing yourself a few
:before
and:after
advices.Just remember to be responsible. Advices let you run code in places where packages don’t expect code to be run. So don’t be surprised if something else breaks.
Tags: CIDER, clojure, programming, init.el, emacs,
Leave the cursor at start of match after isearch »
« Conditional breakpoints in the CIDER Debugger
Related Posts
Turbo up your Ruby console in Emacs in programming
A few paredit keys that take over the world in programming
Restarting the compilation buffer in comint-mode in programming
Content © 2019, All rights reserved. Icons under CC3.0.