Skip to content

Commit

Permalink
Added a function to pretty-print json.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Jan 19, 2009
1 parent 476c8a8 commit 342edb8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions elpa-to-submit/haml-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ The first time this command is used, the line will be indented to the
maximum sensible indentation. Each immediately subsequent usage will
back-dent the line by `haml-indent-offset' spaces. On reaching column
0, it will cycle back to the maximum sensible indentation."
;; TODO: pressing tab to bring the point to the first non-whitespace
;; char marks the buffer as modified even though it doesn't change anything
(interactive "*")
(let ((ci (current-indentation))
(cc (current-column))
Expand Down
10 changes: 10 additions & 0 deletions starter-kit-js.el
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,15 @@
(setq js2-bounce-indent-flag nil
js2-indent-on-enter-key t)))

(defun esk-pp-json ()
"Pretty-print the json object following point."
(interactive)
(require 'json)
(let ((json-object (save-excursion (json-read))))
(switch-to-buffer "*json*")
(delete-region (point-min) (point-max))
(insert (pp json-object))
(goto-char (point-min))))

(provide 'starter-kit-js)
;;; starter-kit-js.el ends here

0 comments on commit 342edb8

Please sign in to comment.