From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#12634: Patch for pretty-printing in json.el Date: Tue, 30 Oct 2012 16:03:11 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1351627427 13367 80.91.229.3 (30 Oct 2012 20:03:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 30 Oct 2012 20:03:47 +0000 (UTC) Cc: 12634@debbugs.gnu.org To: Ryan Crum Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Oct 30 21:03:54 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TTI2R-00089q-Sq for geb-bug-gnu-emacs@m.gmane.org; Tue, 30 Oct 2012 21:03:52 +0100 Original-Received: from localhost ([::1]:46582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTI2J-0006G3-JI for geb-bug-gnu-emacs@m.gmane.org; Tue, 30 Oct 2012 16:03:43 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTI28-0006Ff-2G for bug-gnu-emacs@gnu.org; Tue, 30 Oct 2012 16:03:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TTI26-0002F3-8N for bug-gnu-emacs@gnu.org; Tue, 30 Oct 2012 16:03:31 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:58100) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTI26-0002Ev-54 for bug-gnu-emacs@gnu.org; Tue, 30 Oct 2012 16:03:30 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TTI4Y-0000di-FM for bug-gnu-emacs@gnu.org; Tue, 30 Oct 2012 16:06:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 30 Oct 2012 20:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12634 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 12634-submit@debbugs.gnu.org id=B12634.13516275502440 (code B ref 12634); Tue, 30 Oct 2012 20:06:02 +0000 Original-Received: (at 12634) by debbugs.gnu.org; 30 Oct 2012 20:05:50 +0000 Original-Received: from localhost ([127.0.0.1]:40118 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TTI4M-0000dJ-0f for submit@debbugs.gnu.org; Tue, 30 Oct 2012 16:05:50 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:45098) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TTI4K-0000dC-6g for 12634@debbugs.gnu.org; Tue, 30 Oct 2012 16:05:49 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAG6Zu0/O+LET/2dsb2JhbABEtBGBCIIVAQEEAVYjBQsLNBIUGA0kiBwFugmQRAOjM4FYgwU X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="203178009" Original-Received: from 206-248-177-19.dsl.teksavvy.com (HELO pastel.home) ([206.248.177.19]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 30 Oct 2012 16:03:12 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 9E0C259419; Tue, 30 Oct 2012 16:03:11 -0400 (EDT) In-Reply-To: (Ryan Crum's message of "Sat, 27 Oct 2012 15:31:46 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:66246 Archived-At: > Cool, new patch attached. I've consolidated current-separator into > current-indentation and created a little private helper function > `json--current-whitespace' for the newline/indentation. Thanks. More questions/remarks: - Your patch does not apply to the trunk version of json.el where alist/plist keys are encoded with a new json-encode-key. - I don't understand this helper function. Why not store the leading "\n" directly in json-encoding-current-indentation so that we can use json-encoding-current-indentation directly instead of calling json--current-whitespace? - BTW your patch calls json-encoding-current-indentation as a function in json-encode-plist. - OTOH, I wouldn't mind a helper function/macro to consolidate all the (let ((json-encoding-current-indentation (if json-encoding-pretty-print (concat json-encoding-current-indentation json-encoding-default-indentation) ""))) in a single spot. - Why use ", " rather than "," for json-encoding-default-separator? - json-encoding-default-separator is a bad name since it holds the *current* separator, rather than the default. - Why (format "%s" (json--current-whitespace)) rather than (json--current-whitespace)? > I've also created a var called `json-encoding-lisp-style-closings' per your > request. :-) Thanks. > Just let me know if there's anything else. I think that's enough nitpicking for now. Stefan