Search code examples
elispparedit

what's the use for paredit-convolute-sexp in paredit mode


It changes

(a b c d (1 2 |3 4) ha ha ha)

into

|(1 2 (a b c d 3 4 ha ha ha))

What is the use for that transformation?


Solution

  • Strictly speaking, it's used for reversing the nesting of an inner expression.

    As an example:

    (let [foo bar] (if a b| c))
    

    becomes

    (if a b (let [foo bar]| c))
    

    As for use case, I've never had a practical use for it specifically, but it's a nice building block for a larger macro