Emacsist RSS --- If never, make it ever: C-h C-h

A small improvement to clj-refactor

7335

这里 查看更多 Emacs 相关推荐文章最新 Emacs 圈的动态. 欢迎关注微信公众账号: Emacsist

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 typeTab 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.

(advice-add 'cljr-add-require-to-ns :after
            (lambda (&rest _)
              (yas-next-field)
              (yas-next-field)))

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.

原文出处: EndlessParenthese
原文地址: http://endlessparentheses.com/a-small-improvement-to-clj-refactor.html?source=rss
原文时间: 2016-03-15 08:00
本文地址: http://emacsist.com/10804
整理时间: 2016-03-19 23:22

本文由 Hick 整理,转载请保留以上信息;
COPYLEFTThe articles on this site come from Internet, thanks to all the original authors.
      If anything about COPYRIGHT, or LEFT, please contact Emacsist at gmail dot com .