Skip to content

Commit e9c90eb

Browse files
committed
Use built-in json-pretty-print instead of defunct json-reformat package
See gongo/json-reformat#46
1 parent 0e819e5 commit e9c90eb

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

json-mode.el

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
;; Author: Josh Johnston
66
;; URL: https://github.com/joshwnj/json-mode
77
;; Version: 1.6.0
8-
;; Package-Requires: ((json-reformat "0.0.5") (json-snatcher "1.0.0"))
8+
;; Package-Requires: ((json-snatcher "1.0.0") (emacs "24.4"))
99

1010
;; This program is free software; you can redistribute it and/or modify
1111
;; it under the terms of the GNU General Public License as published by
@@ -29,7 +29,6 @@
2929
(require 'js)
3030
(require 'rx)
3131
(require 'json-snatcher)
32-
(require 'json-reformat)
3332

3433
(defgroup json-mode '()
3534
"Major mode for editing JSON files."
@@ -140,14 +139,13 @@ This function calls `json-mode--update-auto-mode' to change the
140139
(define-key json-mode-map (kbd "C-c P") 'json-mode-kill-path)
141140

142141
;;;###autoload
143-
(defun json-mode-beautify ()
142+
(defun json-mode-beautify (begin end)
144143
"Beautify / pretty-print the active region (or the entire buffer if no active region)."
145-
(interactive)
146-
(let ((json-reformat:indent-width js-indent-level)
147-
(json-reformat:pretty-string? t))
148-
(if (use-region-p)
149-
(json-reformat-region (region-beginning) (region-end))
150-
(json-reformat-region (buffer-end -1) (buffer-end 1)))))
144+
(interactive "r")
145+
(unless (use-region-p)
146+
(setq begin (point-min)
147+
end (point-max)))
148+
(json-pretty-print begin end))
151149

152150
(define-key json-mode-map (kbd "C-c C-f") 'json-mode-beautify)
153151

0 commit comments

Comments
 (0)