summaryrefslogtreecommitdiff
path: root/lisp/json.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2019-07-09 21:23:18 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2019-07-09 21:23:18 +0200
commit864ab2c150583d01e2dbdebde6a024e923512d94 (patch)
tree6e52b937c2720c161af446990583d27fed6d7f4a /lisp/json.el
parent48daf77a9d963c05ee198b3ab108c7f0b3686da6 (diff)
downloademacs-864ab2c150583d01e2dbdebde6a024e923512d94.tar.gz
emacs-864ab2c150583d01e2dbdebde6a024e923512d94.tar.bz2
emacs-864ab2c150583d01e2dbdebde6a024e923512d94.zip
Revert "Fix pretty-printing of multiple JSON objects"
This reverts commit 48daf77a9d963c05ee198b3ab108c7f0b3686da6. This apparently led to build errors.
Diffstat (limited to 'lisp/json.el')
-rw-r--r--lisp/json.el25
1 files changed, 12 insertions, 13 deletions
diff --git a/lisp/json.el b/lisp/json.el
index 8dd96b08640..a36cff7c67b 100644
--- a/lisp/json.el
+++ b/lisp/json.el
@@ -758,8 +758,10 @@ With prefix argument MINIMIZE, minimize it instead."
(json-pretty-print (point-min) (point-max) minimize))
(defvar json-pretty-print-max-secs 2.0
- "Maximum time for `json-pretty-print's comparison.")
-(make-obsolete-variable json-pretty-print-max-secs nil "27.1")
+ "Maximum time for `json-pretty-print's comparison.
+The function `json-pretty-print' uses `replace-region-contents'
+(which see) passing the value of this variable as argument
+MAX-SECS.")
(defun json-pretty-print (begin end &optional minimize)
"Pretty-print selected region.
@@ -769,17 +771,14 @@ With prefix argument MINIMIZE, minimize it instead."
;; Distinguish an empty objects from 'null'
(json-null :json-null)
;; Ensure that ordering is maintained
- (json-object-type 'alist)
- json)
- (save-restriction
- (narrow-to-region begin end)
- (goto-char begin)
- (while (setq json (condition-case _
- (json-read)
- (json-error nil)))
- (delete-region begin (point))
- (insert (json-encode json))
- (setq begin (point))))))
+ (json-object-type 'alist))
+ (replace-region-contents
+ begin end
+ (lambda () (json-encode (json-read)))
+ json-pretty-print-max-secs
+ ;; FIXME: What's a good value here? Can we use something better,
+ ;; e.g., by deriving a value from the size of the region?
+ 64)))
(defun json-pretty-print-buffer-ordered (&optional minimize)
"Pretty-print current buffer with object keys ordered.