]> git.bundesbrandschatzamt.de Git - emacsconfig.git/commitdiff
adding beautify-json
authorAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Fri, 26 Feb 2016 13:06:38 +0000 (14:06 +0100)
committerAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Fri, 26 Feb 2016 13:08:59 +0000 (14:08 +0100)
bba.org

diff --git a/bba.org b/bba.org
index 744e5f533cbd5be3721d51928346d2c798bbf05f..989fb692254cbd3b761a74b47b2eb5d84d4e1b88 100644 (file)
--- a/bba.org
+++ b/bba.org
@@ -2307,6 +2307,18 @@ we use that as default:
   (global-set-key (kbd "C-M-r") 'isearch-backward)
 #+END_SRC
 
+* Beautifying JSON
+
+#+BEGIN_SRC emacs-lisp
+  (defun beautify-json ()
+  "Use python to prettyprint JSON."
+    (interactive)
+    (let ((b (if mark-active (min (point) (mark)) (point-min)))
+          (e (if mark-active (max (point) (mark)) (point-max))))
+      (shell-command-on-region b e
+       "python -mjson.tool" (current-buffer) t)))
+#+END_SRC
+
 * configure some default values
     [2014-10-02 Thu 00:27]