在*scratch*
buffer里面运行macroexpand
展开宏后的程序全在一行,不好读,使用pp
可以获得更好的效果。
(defun wl-pp-macroexpand-at-point () (interactive) (pp-eval-expression '(macroexpand (read (thing-at-point 'sexp))))) (define-key emacs-lisp-mode-map (kbd "C-c C-c") 'wl-pp-macroexpand-at-point)
将光标放在想要展开的宏调用的左括号前,调用该程序,宏展开的结果显示在*Pp Eval Output*
buffer里。
如果想看宏调用执行后的结果,可以使用下面的函数。
(defun wl-pp-evaluate-at-point () (interactive) (pp-eval-expression (macroexpand (read (thing-at-point 'sexp))))) (define-key emacs-lisp-mode-map (kbd "C-c C-e") 'wl-pp-evaluate-at-point)