abo-abo / lispy

Short and sweet LISP editing
http://oremacs.com/lispy/
1.21k stars 132 forks source link

lispy-tab corrupts <? macro #373

Open ponimas opened 7 years ago

ponimas commented 7 years ago

I have <? macro in my clojure code.

(<? c)|

if I press i i got

(<\? c)|

expected result

(<? c)|
abo-abo commented 7 years ago

It's your own macro defined with defmacro?

ponimas commented 7 years ago

@abo-abo yup

(defmacro <? [ch]
  `(throw-err (<! ~ch)))

that's pretty common pattern while working with core.async http://martintrojer.github.io/clojure/2014/03/09/working-with-coreasync-exceptions-in-go-blocks https://swannodette.github.io/2013/08/31/asynchronous-error-handling

ponimas commented 7 years ago

@abo-abo any workaround?

abo-abo commented 7 years ago

The only way to fix it right now is to amend lispy--read and lispy--insert with one more case. They are already quite heavy, since in the end lispy--read relies on the Elisp reader, so all the code has to be translated into a form that Elisp can understand. I don't want to add a custom Clojure macro to lispy--read.

The way to proceed is to either refactor lispy--read to be customizable with a list of patterns, or implement a custom Lisp reader and not rely on the Elisp one. I can do the first thing if I get a large chunk of free time, and I'm not tied up with other projects. PRs welcome, of course.