aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJohn Wiegley2017-12-03 10:33:12 -0800
committerJohn Wiegley2017-12-03 10:33:12 -0800
commit4c1b82aed582271d2159a3ae280ff79c272f6a46 (patch)
treed18c6e9c30e4d1a57caa6241838dfeeb9777203c /test
parent9ab797cccdcb8bd583c0e3148e1aeb251bf05fec (diff)
downloademacs-4c1b82aed582271d2159a3ae280ff79c272f6a46.tar.gz
emacs-4c1b82aed582271d2159a3ae280ff79c272f6a46.zip
Define macroexpand-1 for older Emacsen
Diffstat (limited to 'test')
-rw-r--r--test/lisp/use-package/use-package-tests.el25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/lisp/use-package/use-package-tests.el b/test/lisp/use-package/use-package-tests.el
index 5cf7a342b36..fc9c0f184b6 100644
--- a/test/lisp/use-package/use-package-tests.el
+++ b/test/lisp/use-package/use-package-tests.el
@@ -31,6 +31,31 @@
31 max-lisp-eval-depth 8000 31 max-lisp-eval-depth 8000
32 max-specpdl-size 8000) 32 max-specpdl-size 8000)
33 33
34(unless (fboundp 'macroexpand-1)
35 (defun macroexpand-1 (form &optional environment)
36 "Perform (at most) one step of macroexpansion."
37 (cond
38 ((consp form)
39 (let* ((head (car form))
40 (env-expander (assq head environment)))
41 (if env-expander
42 (if (cdr env-expander)
43 (apply (cdr env-expander) (cdr form))
44 form)
45 (if (not (and (symbolp head) (fboundp head)))
46 form
47 (let ((def (autoload-do-load (symbol-function head) head 'macro)))
48 (cond
49 ;; Follow alias, but only for macros, otherwise we may end up
50 ;; skipping an important compiler-macro (e.g. cl--block-wrapper).
51 ((and (symbolp def) (macrop def)) (cons def (cdr form)))
52 ((not (consp def)) form)
53 (t
54 (if (eq 'macro (car def))
55 (apply (cdr def) (cdr form))
56 form))))))))
57 (t form))))
58
34(defmacro expand-minimally (form) 59(defmacro expand-minimally (form)
35 `(let ((use-package-verbose 'errors) 60 `(let ((use-package-verbose 'errors)
36 (use-package-expand-minimally t)) 61 (use-package-expand-minimally t))