Skip to content

Instantly share code, notes, and snippets.

@ichiban
Created July 6, 2012 08:01
Show Gist options
  • Save ichiban/3058840 to your computer and use it in GitHub Desktop.
Save ichiban/3058840 to your computer and use it in GitHub Desktop.
TSV to S-exp
(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