Created
January 24, 2014 08:41
-
-
Save vbsteven/8594030 to your computer and use it in GitHub Desktop.
This file contains 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
;; json formatting functions | |
;; replace region with json formatted version | |
(defun json-format () | |
(interactive) | |
(save-excursion | |
(shell-command-on-region (mark) (point) "python -m json.tool" (buffer-name) t) | |
) | |
) | |
;; format json and output result in new new buffer | |
(defun json-format-other-buffer () | |
(interactive) | |
(shell-command-on-region (mark) (point) "python -m json.tool" (get-buffer-create "*json*")) | |
(view-buffer-other-window "*json*") | |
(javascript-mode) | |
(view-mode) | |
) | |
(global-set-key "\C-cfj" 'json-format) | |
(global-set-key "\C-cvj" 'json-format-other-buffer) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment