Wilfred/emacs-refactor

emr-el-extract-to-let can't handle top-level expressions in a defun

Opened this issue · 1 comments

Given the code, where | is point:

(defun foobar (x)
  |(+ x 1))

emr-show-refactor-menu does not offer extract to let. If I explicitly run M-x emr-el-extract-to-let, I get:

(let ()
  (defun foobar (let ((y (x))) y)
    (+ x 1)))

Point needs to be inside the form apparently:

(defun foobar (x)
  (|+ x 1))

This works. This is a gotcha.