From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master bff6411: Fix pretty-printing of multiple JSON objects Date: Tue, 09 Jul 2019 23:01:06 +0100 Message-ID: <8736jezx3x.fsf@tcd.ie> References: <20190709193603.2656.9451@vcs0.savannah.gnu.org> <20190709193604.A3D5E20BD5@vcs0.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="92937"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Lars Ingebrigtsen , Tassilo Horn To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jul 10 00:08:56 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hkyIA-000Nlc-Er for ged-emacs-devel@m.gmane.org; Wed, 10 Jul 2019 00:08:54 +0200 Original-Received: from localhost ([::1]:56440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkyB1-00052l-Qk for ged-emacs-devel@m.gmane.org; Tue, 09 Jul 2019 18:01:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37423) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkyAs-00052R-VV for emacs-devel@gnu.org; Tue, 09 Jul 2019 18:01:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkyAq-0007nj-Sd for emacs-devel@gnu.org; Tue, 09 Jul 2019 18:01:22 -0400 Original-Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:33681) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkyAo-0007bh-NT for emacs-devel@gnu.org; Tue, 09 Jul 2019 18:01:19 -0400 Original-Received: by mail-wm1-x343.google.com with SMTP id h19so3344336wme.0 for ; Tue, 09 Jul 2019 15:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=IqF+HE3jX5z5xzbDUf9YstDdXzPw2sVa/xeoKWzJlAM=; b=nvUyiRihTWJmbHoQKsZN09++qD1elhY9JNJ44emG+KEG4IwJnVhtNetoeKWIp3NAXJ GBu3et+P9x1rKuLog80XK+gFSAcINUtuUuJetn4wai0JfY80AAQinOXfcwwpODQEPcLC eoSljmvGh3q7htc7FghZn2qCivBa8798BMN/CCBs1v7oLMbrpxGL0F1U/0B5GZMifISq 4592mczMNLzxtKQG60+CUFQ4EqKV4jEUQKGNu2dlNIUzRzIy2NFkYhoFFRTV01MXXWWu R/qC5N4TaeWB3aCMosg81aFiw7FCoZtV0qSGltqiGq6mL3ordZlF/oNybjqi9dwx6qoo adjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=IqF+HE3jX5z5xzbDUf9YstDdXzPw2sVa/xeoKWzJlAM=; b=PPUDbsRzLQIiGVwsCwCYCh9DZ7a4JLIpPcr5TnEv8VXfqujMFeQz7i3bMu9/PeYtRP opOoi08VYK8LJQyuVabmOZqesUSxv6UZ9WwZoOG2Ekdr/YnR7soK2o/JAZbQvlojgmrz 4YfVsls6EE51GI7pnooC7Zzz6L6p/IUUF5T91Z6ZwApXrKDJo0IY29EiZk2fk9kzNHDl IKD3tyMNScsAFSXTN5kn/beAi2vfQD3n11CWS+NHoEoTGa6tkrS1idhi43zMRNnNvXWY vTXLe3fk5Av0NTBGgrwbaiBmIwH3MXgOn1YZxAFflCg+Ie2aYBN+BmV7i6SfexhbhUUR LB8A== X-Gm-Message-State: APjAAAUxaoJ6VrBMgyOwt0VKWnXBKlFjfY/tQQa3sn9Ae6ENIBjZmVTZ NaL416l+BkdKpv++w/+x/yS4IQl5X/HIIw== X-Google-Smtp-Source: APXvYqwSwCVWJB7NL8U4vgOboY0RYnnNfO2YweMYuoeJcu+mrMkqj6oeHztPzstYKOaHLFqnqjrwrQ== X-Received: by 2002:a05:600c:23cd:: with SMTP id p13mr1415630wmb.86.1562709668084; Tue, 09 Jul 2019 15:01:08 -0700 (PDT) Original-Received: from localhost ([2a02:8084:20e2:c380:1f68:7ff5:120d:64e]) by smtp.gmail.com with ESMTPSA id r12sm70682wrt.95.2019.07.09.15.01.07 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 09 Jul 2019 15:01:07 -0700 (PDT) In-Reply-To: <20190709193604.A3D5E20BD5@vcs0.savannah.gnu.org> (Lars Ingebrigtsen's message of "Tue, 9 Jul 2019 15:36:04 -0400 (EDT)") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:238486 Archived-At: larsi@gnus.org (Lars Ingebrigtsen) writes: > branch: master > commit bff64115a0ad081282e0f99305f41c8dd1917d67 > Author: Lars Ingebrigtsen > Commit: Lars Ingebrigtsen > > 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