Created
May 10, 2021 06:30
-
-
Save zk-phi/a90af91109bf95754ccb1684db7e7cf4 to your computer and use it in GitHub Desktop.
macroexpand-file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'macroexp) | |
(defun read-and-macroexpand-all (stream) | |
(ignore-errors | |
(cons (macroexpand-all (read stream)) | |
(read-and-macroexpand-all stream)))) | |
(defun macroexpand-file (src dest) | |
"ファイル SRC 内のすべてのフォームをマクロ展開して、ファイル DEST に保存する" | |
(let ((forms (with-temp-buffer | |
(insert-file-contents src) | |
(read-and-macroexpand-all (current-buffer))))) | |
(with-temp-buffer | |
(dolist (form forms) | |
(prin1 form (current-buffer)) | |
(insert "\n\n")) | |
(write-file dest)))) | |
;; (macroexpand-file "~/.emacs.d/init.el" "~/.emacs.d/init-expanded.el") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment