Fork me on GitHub
#emacs
<
2019-06-24
>
skuro09:06:45

I've the weirdest issue with indentation. Here's what happens when I'm setting an alias to a multiline :keys destructuring (I'm using clojure-align-forms-automatically): https://asciinema.org/a/gsudrvzoiwlZu8em2KjDIRrW7

skuro09:06:01

same happens in every binding form (`let`, defn, etc.)

skuro09:06:13

could not figure out what the hell is happening there, any clue?

vemv10:06:03

I think you are experiencing a variation of https://github.com/clojure-emacs/clojure-mode/issues/525 I'd avoid the newline after three. Instead, I'd place it before :as See how with one option you are placing a newline in an 'arbitrary' place, and with the other not? Same for https://github.com/clojure-emacs/clojure-mode/issues/525 , there should be a newline after 789] From what I know, clojure-mode delegates alignment to Emacs so there's a chance that there will be no other solution

skuro11:06:47

thing is, that screencast is more of an example, I have a fairly big map destructuring in my real code that involves about 25 names, meaning the line would become unbearably long without newlines

vemv11:06:11

From my side, I haven't experienced this issue unless intentionally trying to reproduce it. And I do align all my hashmaps automatically I think that by following a strict/homogeneous recipe (newlines after k-v pairs, and optionally use homegeneous newlines in values) you'd avoid the issue. If my wording isn't clear I'd be happy to try correcting a big map example 🙂

skuro11:06:50

please please share a snippet please 😋

vemv11:06:58

;; homogeneous newlines across k-v pairs: 1 newline after each k-v value (as opposed to having multiple k-v's in the same line)
{:aaa [1 ;; homogeneous newlines in values: 1 newline after each value (as opposed to just 1 newline in an arbitrary position)
       2
       3]
 :b   [1]}

skuro11:06:31

alright, that might be a viable workaround, although it would be much, much preferable to cluster names arbitrarily (YMMV of course)

👍 4
skuro11:06:52

just a note: trying out your solution, I've found another workaround

skuro11:06:18

breaking the blob of named keys with a newline at any point stops that behavior

skuro11:06:11

e.g.:

(let [{:keys [one two three
              
              four five six
              seven eight nine] :as woot} big-stuff])

skuro11:06:57

that blank newline can also be put after the six

vemv11:06:03

yes, but the blankline precludes alignment

vemv11:06:11

(it's intentional behavior)

skuro12:06:15

I figured, yes. but intentional for whom? emacs or clojure-mode?

skuro12:06:50

still fiddling with this 😛

skuro12:06:11

I redefined clojure-align to use (separate . group) instead of the default one

skuro12:06:20

which seems to behave the way I want

skuro12:06:06

but since my brain seems to not be permeable to most of the concepts around align-region, would you think of any downside of such a change @U45T93RA6?

vemv12:06:16

not super sure myself either there are a few defcustoms regarding alignment; none of those would suffice?

skuro12:06:18

let me try

skuro12:06:00

yep, customizing clojure-align-separator to be 'group works as expected