This is an interesting proposal, and I like it in general. Everything in Cursive is based on extensions identified by the head form, like this:
(style/register-formatting :clojure.core/def :only-indent) (style/register-formatting :clojure.core/defn- :only-indent) (style/register-formatting resolve/fn-forms :only-indent) (style/register-formatting resolve/local-binding-forms 1) I think it's important that the declaration of the formatting be separated from the declaration of the macro itself. This allows forms which the editor developer doesn't control to be annotated, e.g. core. Perhaps library owners could produce an EDN doc containing these specs? Or perhaps we could obey annotations in the functions themselves, but I think that some way to additionally annotate external things is essential. I also think that Mr Dynamics is correct, we should not go down the path of special casing anything, even defn - this is a hard rule that I have in Cursive that I only break very occasionally :-). The spec should support everything we need to do. It will be difficult, though - in Cursive I actually support programmatically organising the blocks that make up the source, and I'm not sure how to handle many cases without this. I like the hierarchical nature of this spec, though, I suspect that many of the cases I currently solve programmatically could be solved using something like this. There are also many more aspects to formatting that this does not address that I think we should think about - line indentation is only one part of it. What about breaking lines when they're too long? Aligning subforms like let-binding values? Do we want to do anything about those? Cursive can handle all of that but doesn't expose the knobs right now. clj-fmt does, I believe - I think it can take a single line of pr-str output and produce nicely formatted code. There are also lots of edge cases that need to be thought through. Multi-arity function declarations for letfn, proxy etc come to mind. extend-type also supports multiple arity declarations. condp is another example of a form with variable numbers of elements per "block" (the :>> keyword). for-blocks have internal let blocks, etc etc. It's hard to tell how far to go with this. One thing that I'm planning in Cursive that I'm not doing currently is also to identify forms which are part of a do-body-like-thing. This is very useful for refactoring. This might not have a place in a spec that is purely for indentation, but definitely would in a more general form structure spec. I also think it would be very useful to express implicit grouping of elements, e.g. let binding keys/values, cond forms etc. On 16 September 2015 at 07:08, Josh Tilles <merelyapseudo...@gmail.com> wrote: > > > On Sunday, September 13, 2015 at 8:25:42 AM UTC-4, Artur Malabarba wrote: >> >> >> On 13 Sep 2015 12:33 pm, "Matching Socks" <phill...@gmail.com> wrote: >> > >> > Unless clojure.core itself will carry these annotations, could the >> keyword be namespaced? >> >> Or do you mean it should be ::indent? (i.e., carry the namespace of the >> var that they're applied on) >> > I suspect that “Matching Socks” meant that there should be a standard > namespace, similar to how the recent Socket Server REPL design > <http://dev.clojure.org/pages/viewpage.action?pageId=11305253#SocketServerREPL-REPLControl> > uses > a “repl” namespace for its magic keywords. > It seems natural to me to pick a namespace like “editors” or “editing”, > but alternatives like :display/indentation or :visual/structure also look > good. > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.