]> git.eshelyaron.com Git - emacs.git/commitdiff
Enhance fix-expansion to take surrounding let bindings into account
authorJohn Wiegley <johnw@newartisans.com>
Tue, 5 Dec 2017 21:26:03 +0000 (13:26 -0800)
committerJohn Wiegley <johnw@newartisans.com>
Tue, 5 Dec 2017 21:26:03 +0000 (13:26 -0800)
test/lisp/use-package/use-package-tests.el

index 966c1221ba4306e302e6688f0f1413dbf4dd834c..7109d58ea1f7c3cc9173813eac805fb87a47171d 100644 (file)
       (goto-char (match-beginning 0))
       (let ((decl (read (current-buffer))))
         (kill-sexp)
-        (let ((use-package-verbose 'errors)
-              (use-package-expand-minimally t))
-          (insert ?\n ?\` (pp-to-string (macroexpand-1 decl))))))))
+        (let (vars)
+          (catch 'exit
+            (save-excursion
+              (while (ignore-errors (backward-up-list) t)
+                (when (looking-at "(let\\s-+")
+                  (goto-char (match-end 0))
+                  (setq vars (read (current-buffer)))
+                  (throw 'exit t)))))
+          (eval
+           `(let (,@ (append vars
+                             '((use-package-verbose 'errors)
+                               (use-package-expand-minimally t))))
+              (insert ?\n ?\` (pp-to-string (macroexpand-1 decl))))))))))
 
 (bind-key "C-c C-u" #'fix-expansion emacs-lisp-mode-map)