all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: [Emacs-diffs] master bff6411: Fix pretty-printing of multiple JSON objects
       [not found] ` <20190709193604.A3D5E20BD5@vcs0.savannah.gnu.org>
@ 2019-07-09 22:01   ` Basil L. Contovounesios
  2019-07-09 22:10     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Basil L. Contovounesios @ 2019-07-09 22:01 UTC (permalink / raw)
  To: emacs-devel; +Cc: Lars Ingebrigtsen, Tassilo Horn

larsi@gnus.org (Lars Ingebrigtsen) writes:

> branch: master
> commit bff64115a0ad081282e0f99305f41c8dd1917d67
> Author: Lars Ingebrigtsen <larsi@gnus.org>
> Commit: Lars Ingebrigtsen <larsi@gnus.org>
>
>     Fix pretty-printing of multiple JSON objects
>     
>     * lisp/json.el (json-pretty-print-max-secs): Make obsolete.

I don't think this is necessary, as the variable is new[1].

[1: e96923c188]: Improve replace-buffer-contents/replace-region-contents
  2019-02-23 21:31:15 +0100
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=e96923c188a2a38d09917c5b7f606187a1413a96

OTOH, both mentions of replace-region-contents in json.el are now
inaccurate.

>     (json-pretty-print): Pretty-print all JSON objects in the region
>     instead of just the first one (and then deleting all other
>     objects) (bug#34160).
> ---
>  lisp/json.el | 24 ++++++++++++++----------
>  1 file changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/lisp/json.el b/lisp/json.el
> index a36cff7..460fdec 100644
> --- a/lisp/json.el
> +++ b/lisp/json.el
> @@ -734,8 +734,8 @@ you will get the following structure returned:
>    "Return a JSON representation of OBJECT as a string.
>  
>  OBJECT should have a structure like one returned by `json-read'.
> -If an error is detected during encoding, this function signals
> -an error based on `json-error'."
> +If an error is detected during encoding, an error based on
> +`json-error' is signalled."
>    (cond ((memq object (list t json-null json-false))
>           (json-encode-keyword object))
>          ((stringp object)      (json-encode-string object))
> @@ -762,6 +762,7 @@ With prefix argument MINIMIZE, minimize it instead."
>  The function `json-pretty-print' uses `replace-region-contents'
>  (which see) passing the value of this variable as argument
>  MAX-SECS.")
> +(make-obsolete-variable 'json-pretty-print-max-secs nil "27.1")
>  
>  (defun json-pretty-print (begin end &optional minimize)
>    "Pretty-print selected region.
> @@ -771,14 +772,17 @@ 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))
> -    (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)))
> +        (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))))))
>  
>  (defun json-pretty-print-buffer-ordered (&optional minimize)
>    "Pretty-print current buffer with object keys ordered.

Thanks,

-- 
Basil



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Emacs-diffs] master bff6411: Fix pretty-printing of multiple JSON objects
  2019-07-09 22:01   ` [Emacs-diffs] master bff6411: Fix pretty-printing of multiple JSON objects Basil L. Contovounesios
@ 2019-07-09 22:10     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2019-07-09 22:10 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: Tassilo Horn, emacs-devel

"Basil L. Contovounesios" <contovob@tcd.ie> writes:

> I don't think this is necessary, as the variable is new[1].
>
> [1: e96923c188]: Improve replace-buffer-contents/replace-region-contents
>   2019-02-23 21:31:15 +0100
>   https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=e96923c188a2a38d09917c5b7f606187a1413a96

Ah, OK.

> OTOH, both mentions of replace-region-contents in json.el are now
> inaccurate.

I've now removed it and those mentions.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-09 22:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20190709193603.2656.9451@vcs0.savannah.gnu.org>
     [not found] ` <20190709193604.A3D5E20BD5@vcs0.savannah.gnu.org>
2019-07-09 22:01   ` [Emacs-diffs] master bff6411: Fix pretty-printing of multiple JSON objects Basil L. Contovounesios
2019-07-09 22:10     ` Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.