;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; script add to lisp-inteactive-mode ;;; by T.Shido; July 18, 2004 ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; show macro expansion, Print Macor Expansion (defmacro pme (mac) `(pprint-1 (macroexpand-1 ',mac))) (defun pprint-1 (s0) (pp-loop (format nil "~S" s0))) (defun pp-loop (str0 &optional then) (if (and then (eql 0 (string-match " *[^ (]+" str0))) (let ((pe (match-end 0))) (insert (substring str0 0 pe)) (lisp-newline-and-indent) (pp-loop (substring str0 pe) nil)) (progn (string-match ")+\\|( *cond +\\|case +[^ (]+" str0) (let* ((px (match-end 0)) (str1 (substring str0 0 px)) (pif0 (string-match "\\( *( *if +\\)\\|\\( *( *if +[^ (]+\\)" str1)) (pif1 (match-end 2)) (p1 (or pif1 px))) (if (and pif0 (< 0 pif0)) (progn (insert (substring str0 0 pif0)) (lisp-newline-and-indent) (insert (substring str0 pif0 p1))) (insert (substring str0 0 p1))) (lisp-newline-and-indent) (if (< p1 (length str0)) (pp-loop (substring str0 p1) pif0))))))