-
-
Save danlentz/5062621 to your computer and use it in GitHub Desktop.
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
| (defun lisp-reinsert-as-pp () | |
| "Read sexp at point, delete it and pretty print it back in." | |
| (interactive) | |
| (let* ((buf (current-buffer)) | |
| (pp-sexp | |
| (replace-regexp-in-string | |
| "\\(\n\\)$" | |
| "" | |
| (with-temp-buffer | |
| (let ((bufname (buffer-name))) | |
| (pp-display-expression | |
| (with-current-buffer buf | |
| (car | |
| (read-from-string | |
| (replace-regexp-in-string | |
| "\\*\\(.*?\\)\\*\\(<[0-9]+>\\)* <[0-9:.]+>" | |
| "\"\\&\"" | |
| (save-excursion | |
| (buffer-substring-no-properties | |
| (point) | |
| (progn | |
| (forward-sexp) | |
| (point)))))))) | |
| bufname) | |
| (buffer-substring (point-min) (point-max))))))) | |
| (kill-sexp) | |
| (insert pp-sexp))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment