Wilfred / emacs-refactor

language-specific refactoring in Emacs
GNU General Public License v3.0
348 stars 27 forks source link

Unexpected newline in `emr-el-extract-to-let` #52

Closed symbiont-matthew-piziak closed 5 years ago

symbiont-matthew-piziak commented 5 years ago

To reproduce, insert (+ 1 (* 2 3)), select (* 2 3), and run emr-el-extract-to-let. This results in the following:

(let (
      (x (* 2 3)))
  (+ 1 x))

I would expect this instead:

(let ((x (* 2 3)))
  (+ 1 x))

This is only unsatisfying on the first variable extraction. Added variables work fine, since they are added to the body. If I start with this…

(let ((x (* 2 3)))
  (+ 1 x))

…and I extract y = 1, I get this…

(let ((x (* 2 3))
      (y 1))
  (+ y x))

…which looks good to me.

Is this behavior expected, can I fix it? Or is this something I should be customizing somewhere else?

matthew-piziak commented 5 years ago

Possible fix here? https://github.com/Wilfred/emacs-refactor/pull/53