Created
July 6, 2012 08:01
-
-
Save ichiban/3058840 to your computer and use it in GitHub Desktop.
TSV to S-exp
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 'cl) | |
(defun tsv-to-sexp (&optional b e) | |
"TSV to S-exp" | |
(interactive "r") | |
(lexical-let ((str (buffer-substring b e))) | |
(delete-region b e) | |
(insert (pprint (mapcar (lambda (line) (split-string line "\t")) | |
(split-string str "\n")))))) | |
(defun pprint (form &optional output-stream) | |
"pretty print S-exp found at http://stackoverflow.com/a/3552347" | |
(princ (with-temp-buffer | |
(cl-prettyprint form) | |
(buffer-string)) | |
output-stream)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment