mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-31 04:41:23 -08:00
Define macroexpand-1 for older Emacsen
This commit is contained in:
parent
9ab797cccd
commit
4c1b82aed5
1 changed files with 25 additions and 0 deletions
|
|
@ -31,6 +31,31 @@
|
|||
max-lisp-eval-depth 8000
|
||||
max-specpdl-size 8000)
|
||||
|
||||
(unless (fboundp 'macroexpand-1)
|
||||
(defun macroexpand-1 (form &optional environment)
|
||||
"Perform (at most) one step of macroexpansion."
|
||||
(cond
|
||||
((consp form)
|
||||
(let* ((head (car form))
|
||||
(env-expander (assq head environment)))
|
||||
(if env-expander
|
||||
(if (cdr env-expander)
|
||||
(apply (cdr env-expander) (cdr form))
|
||||
form)
|
||||
(if (not (and (symbolp head) (fboundp head)))
|
||||
form
|
||||
(let ((def (autoload-do-load (symbol-function head) head 'macro)))
|
||||
(cond
|
||||
;; Follow alias, but only for macros, otherwise we may end up
|
||||
;; skipping an important compiler-macro (e.g. cl--block-wrapper).
|
||||
((and (symbolp def) (macrop def)) (cons def (cdr form)))
|
||||
((not (consp def)) form)
|
||||
(t
|
||||
(if (eq 'macro (car def))
|
||||
(apply (cdr def) (cdr form))
|
||||
form))))))))
|
||||
(t form))))
|
||||
|
||||
(defmacro expand-minimally (form)
|
||||
`(let ((use-package-verbose 'errors)
|
||||
(use-package-expand-minimally t))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue