aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-07-09 21:23:18 +0200
committerLars Ingebrigtsen2019-07-09 21:23:18 +0200
commit864ab2c150583d01e2dbdebde6a024e923512d94 (patch)
tree6e52b937c2720c161af446990583d27fed6d7f4a
parent48daf77a9d963c05ee198b3ab108c7f0b3686da6 (diff)
downloademacs-864ab2c150583d01e2dbdebde6a024e923512d94.tar.gz
emacs-864ab2c150583d01e2dbdebde6a024e923512d94.zip
Revert "Fix pretty-printing of multiple JSON objects"
This reverts commit 48daf77a9d963c05ee198b3ab108c7f0b3686da6. This apparently led to build errors.
-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."
758 (json-pretty-print (point-min) (point-max) minimize)) 758 (json-pretty-print (point-min) (point-max) minimize))
759 759
760(defvar json-pretty-print-max-secs 2.0 760(defvar json-pretty-print-max-secs 2.0
761 "Maximum time for `json-pretty-print's comparison.") 761 "Maximum time for `json-pretty-print's comparison.
762(make-obsolete-variable json-pretty-print-max-secs nil "27.1") 762The function `json-pretty-print' uses `replace-region-contents'
763(which see) passing the value of this variable as argument
764MAX-SECS.")
763 765
764(defun json-pretty-print (begin end &optional minimize) 766(defun json-pretty-print (begin end &optional minimize)
765 "Pretty-print selected region. 767 "Pretty-print selected region.
@@ -769,17 +771,14 @@ With prefix argument MINIMIZE, minimize it instead."
769 ;; Distinguish an empty objects from 'null' 771 ;; Distinguish an empty objects from 'null'
770 (json-null :json-null) 772 (json-null :json-null)
771 ;; Ensure that ordering is maintained 773 ;; Ensure that ordering is maintained
772 (json-object-type 'alist) 774 (json-object-type 'alist))
773 json) 775 (replace-region-contents
774 (save-restriction 776 begin end
775 (narrow-to-region begin end) 777 (lambda () (json-encode (json-read)))
776 (goto-char begin) 778 json-pretty-print-max-secs
777 (while (setq json (condition-case _ 779 ;; FIXME: What's a good value here? Can we use something better,
778 (json-read) 780 ;; e.g., by deriving a value from the size of the region?
779 (json-error nil))) 781 64)))
780 (delete-region begin (point))
781 (insert (json-encode json))
782 (setq begin (point))))))
783 782
784(defun json-pretty-print-buffer-ordered (&optional minimize) 783(defun json-pretty-print-buffer-ordered (&optional minimize)
785 "Pretty-print current buffer with object keys ordered. 784 "Pretty-print current buffer with object keys ordered.