Code Monkey home page Code Monkey logo

specter-edn's Introduction

specter-edn

https://github.com/maitria/specter-edn/

Format-preserving Specter path for EDN and Cloure code.

There is one specter path: SEXPRS. This navigates to a sequence of s-expressions parsed from a string.

For the transform case, specter-edn preserves whitespace and comments using a sort of diffing algorithm to match new S-expression parts to original parts of the parse tree.

Usage

(use 'com.rpl.specter)
(use 'com.rpl.specter.macros)
(use 'specter-edn.core)

(select [SEXPRS FIRST LAST] "[42 26 77]")
;=> 77

(setval [SEXPRS FIRST FIRST] 99 "[42 ; Hi mom!\n6]")
;=> "[99 ; Hi mom!\n6]"

TODO

  • Use clj-format to format new code which isn't matched up with old code.

Contributors

  • Jason Felice
  • Marcelo Nomoto

License

Copyright © 2016, 2017 Jason M. Felice

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

specter-edn's People

Contributors

eraserhd avatar mynomoto avatar maurolopes avatar

Stargazers

Erich Ocean avatar  avatar  avatar Boris Kourtoukov avatar Matthias Nehlsen avatar  avatar hamlet avatar yāλu avatar Joel Boehland avatar  avatar Andrea Richiardi avatar  avatar  avatar  avatar  avatar Josh Tilles avatar

Watchers

Tracy Harms avatar  avatar  avatar James Cloos avatar  avatar

specter-edn's Issues

zprint will directly format rewrite-clj zippers

This isn't a "issue", just an FYI. I'm not quite sure what specter-edn is used for, but I see that you are using rewrite-clj, and in the readme you are talking about formatting things. I expect that some of the contributors know about zprint since I recognize their names, but they (and you) might not know that the zprint library will directly format the zippers that rewrite-clj outputs. That is how it formats Clojure(script) code -- it uses rewrite-clj to parse the source, and then runs the formatting engine on the resulting zipper structure. There is a (currently hidden) option which will allow you to access this capability directly. I would be more than happy to make it a visible part of the zprint API if you wanted to use it. I didn't bother (so far) because I didn't think anyone would care. Which may well still be the case, but I thought I'd at least let you all know about it.

The option is {:zipper? true}. So, if you have something that is a rewrite-clj zipper which is the value of x, then this will format it to a string:

(zprint-str x {:zipper? true}

The entire zprint API will accept the :zipper? true key-value pair in the options map.

One possible problem is that zprint is using an old-ish version of rewrite-clj, and so there might be some incompatibility with the parsing output (or even the zipper implementation). If you are interested in using zprint, and you encounter problems because of the rewrite-clj version mismatch, I would be willing to move zprint to a more recent rewrite-clj (which is on my list of things to do anyway, but I would work on it sooner rather than later if it mattered to you).

Anyway, I thought that this might possibly be interesting to you, but if not, no problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.