From d9857e534be786674818645a1c51410b4ca68cf8 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 8 Jun 2012 22:26:47 -0400 Subject: Don't autoload functions too eagerly during macroexpansion. * lisp/emacs-lisp/macroexp.el (macroexp--expand-all): Only autoload a function if there's a clear indication that it has a compiler-macro. * lisp/emacs-lisp/byte-run.el (defun-declarations-alist, defmacro, defun) (macro-declarations-alist): Add arglist to declaration functions. (defun-declarations-alist): Add `obsolete' and `compiler-macro'. * lisp/emacs-lisp/cl-seq.el (cl-member, cl-assoc): * lisp/emacs-lisp/cl-lib.el (cl-list*, cl-adjoin): * lisp/emacs-lisp/cl-extra.el (cl-get): Use the new `declare' statement. Also add autoload to find the compiler macro. * lisp/emacs-lisp/cl-macs.el (eql) [compiler-macro]: Remove. (cl--compiler-macro-member, cl--compiler-macro-assoc) (cl--compiler-macro-adjoin, cl--compiler-macro-list*) (cl--compiler-macro-get): New functions, replacing calls to cl-define-compiler-macro. (cl-typep) [compiler-macro]: Use macroexp-let². MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lisp/emacs-lisp/macroexp.el | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'lisp/emacs-lisp/macroexp.el') diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el index 5ca028c4ba4..8effb3c8e31 100644 --- a/lisp/emacs-lisp/macroexp.el +++ b/lisp/emacs-lisp/macroexp.el @@ -182,12 +182,7 @@ Assumes the caller has bound `macroexpand-all-environment'." (let ((handler nil)) (while (and (symbolp func) (not (setq handler (get func 'compiler-macro))) - (fboundp func) - (or (not (eq (car-safe (symbol-function func)) - 'autoload)) - (ignore-errors - (load (nth 1 (symbol-function func)) - 'noerror 'nomsg)))) + (fboundp func)) ;; Follow the sequence of aliases. (setq func (symbol-function func))) (if (null handler) @@ -195,6 +190,14 @@ Assumes the caller has bound `macroexpand-all-environment'." ;; setq/setq-default this works alright because the variable names ;; are symbols). (macroexp--all-forms form 1) + ;; If the handler is not loaded yet, try (auto)loading the + ;; function itself, which may in turn load the handler. + (when (and (not (functionp handler)) + (fboundp func) (eq (car-safe (symbol-function func)) + 'autoload)) + (ignore-errors + (load (nth 1 (symbol-function func)) + 'noerror 'nomsg))) (let ((newform (condition-case err (apply handler form (cdr form)) (error (message "Compiler-macro error: %S" err) -- cgit v1.2.3