From: Noam Postavsky Date: Mon, 1 Aug 2016 00:46:37 +0000 (-0400) Subject: Fix byte-compile of interactive closures X-Git-Tag: emacs-26.0.90~1779 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=031af49e74195ed1645b53dca741fff8a8411a08;p=emacs.git Fix byte-compile of interactive closures * lisp/emacs-lisp/bytecomp.el (byte-compile--reify-function): Put bindings after docstring and `interactive' form, if any (Bug #24122). --- diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index dc7574e778d..175690af3e8 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -2582,7 +2582,13 @@ FUN should be either a `lambda' value or a `closure' value." (pcase-let* (((or (and `(lambda ,args . ,body) (let env nil)) `(closure ,env ,args . ,body)) fun) + (preamble nil) (renv ())) + ;; Split docstring and `interactive' form from body. + (when (stringp (car body)) + (push (pop body) preamble)) + (when (eq (car-safe (car body)) 'interactive) + (push (pop body) preamble)) ;; Turn the function's closed vars (if any) into local let bindings. (dolist (binding env) (cond @@ -2595,8 +2601,8 @@ FUN should be either a `lambda' value or a `closure' value." ((eq binding t)) (t (push `(defvar ,binding) body)))) (if (null renv) - `(lambda ,args ,@body) - `(lambda ,args (let ,(nreverse renv) ,@body))))) + `(lambda ,args ,@preamble ,@body) + `(lambda ,args ,@preamble (let ,(nreverse renv) ,@body))))) ;;;###autoload (defun byte-compile (form)