Subject: bug#12634: Patch for pretty-printing in json.el

From: Stefan Monnier <[email-masked]>
Date: Tue, 30 Oct 2012 16:03:11 -0400

> 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