四月 27, 2008

Pretty print macro expansion

*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)

0 条评论:

发表评论

指向此帖子的链接:

创建链接

<< 主页