Use jq to pretty print json only if available
This commit is contained in:
parent
4a4975d5fa
commit
03dd2cbb1f
@ -1469,13 +1469,15 @@ Some aliases:
|
||||
json-navigator-navigate-after-point
|
||||
json-navigator-navigate-region))
|
||||
|
||||
(defun jq-pretty-print ()
|
||||
(defun json-pprint ()
|
||||
(interactive)
|
||||
(let ((begin (if (region-active-p) (region-beginning) (point-min)))
|
||||
(end (if (region-active-p) (region-end) (point-max))))
|
||||
(shell-command-on-region begin end "jq ." nil t)))
|
||||
(if (executable-find "jq")
|
||||
(shell-command-on-region begin end "jq ." nil t)
|
||||
(json-pretty-print begin end))))
|
||||
|
||||
(general-def json-mode-map "C-M-\\" 'jq-pretty-print)
|
||||
(general-def json-mode-map "C-M-\\" 'json-pprint)
|
||||
#+END_SRC
|
||||
|
||||
* JavaScript
|
||||
|
Loading…
Reference in New Issue
Block a user