parinfer / parinfer.js

Let's simplify the way we write Lisp
https://shaunlebron.github.io/parinfer
MIT License
1.75k stars 40 forks source link

cold formatting problem #178

Closed timothyarmes closed 1 year ago

timothyarmes commented 6 years ago

Hi,

I love parinfer, but I've just found an interesting case where I need to force it to misbehave:

This is what I would like:

    (cond
      (and (sequential? t1) (sequential? t2))
        (and (= (first t1) (first t2))
             (is-sym (second t1) (last t2))
             (is-sym (last t1) (second t2)))
      :else false)))

Note that I wish to indent the condition's then clause so that it doesn't look like a condition. I can't.

I have to do this instead:

(cond
      (and (nil? t1) (nil? t2))
      true
      (and (sequential? t1) (sequential? t2)) (and (= (first t1) (first t2))
                                               (is-sym (second t1) (last t2))
                                               (is-sym (last t1) (second t2)))
     :else false)))

Which is much wider.

I doubt there's might that can be done given how parinfer works though...

shaunlebron commented 6 years ago

thanks for reporting. a common problem resulting from indentation communicating dominant siblings rather than formal parents. same problem happened when trying to indent multi-arity function bodies past the parameter vectors.

it doesnt seem feasible to allow both. open to ideas though

On Sep 29, 2017 11:35 AM, "Timothy Armes" notifications@github.com wrote:

Hi,

I love parinfer, but I've just found an interesting case where I need to force it to misbehave:

This is why I want:

(cond
  (and (sequential? t1) (sequential? t2))
    (and (= (first t1) (first t2))
         (is-sym (second t1) (last t2))
         (is-sym (last t1) (second t2)))
  :else false)))

Note that I wish to indent the condition's then clause so that it doesn't look like a condition. I can't.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/shaunlebron/parinfer/issues/178, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHIZjbOO4on1t2kvGqN0SMtXThK7zGlks5snRxsgaJpZM4Po6vI .

shaunlebron commented 6 years ago

I personally use an empty line to separate cond pairs:

(cond
  (and (nil? t1) (nil? t2))
  true

  (and (sequential? t1) (sequential? t2))
  (and (= (first t1) (first t2))
    (is-sym (second t1) (last t2))
    (is-sym (last t1) (second t2)))

 :else false)))
shaunlebron commented 1 year ago

Closing. I think we cannot allow forms to be indented into their siblings.