[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#40693: 28.0.50; json-encode-alist changes alist
From: |
João Távora |
Subject: |
bug#40693: 28.0.50; json-encode-alist changes alist |
Date: |
Tue, 19 May 2020 00:50:33 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.91 (gnu/linux) |
Hi Basil,
"Basil L. Contovounesios" <contovob@tcd.ie> writes:
> * lisp/jsonrpc.el (jsonrpc--json-read, jsonrpc--json-encode): Check
> whether native JSON functions are fboundp only once, at load time.
I welcome this small improvement: in fact I had a TODO there to make
something similar. In the TODO i suggested the jsonrpc--json-read could
be a macro. You used `defalias` instead and that's fine. However, I
don't understand the need for the ugly (require 'json), defvar and
declare-function there. Can't we just use sth like `eval-and-compile`
at the top of the file?
> -(defun jsonrpc--json-read ()
> - "Read JSON object in buffer, move point to end of buffer."
> - ;; TODO: I guess we can make these macros if/when jsonrpc.el
> - ;; goes into Emacs core.
> - (cond ((fboundp 'json-parse-buffer) (json-parse-buffer
> - :object-type 'plist
> - :null-object nil
> - :false-object :json-false))
> - (t (let ((json-object-type 'plist))
> - (json-read)))))
> +(defalias 'jsonrpc--json-read
> + (if (fboundp 'json-parse-buffer)
> + (lambda ()
> + (json-parse-buffer :object-type 'plist
> + :null-object nil
> + :false-object :json-false))
> + (require 'json)
> + (defvar json-object-type)
> + (declare-function json-read "json" ())
> + (lambda ()
> + (let ((json-object-type 'plist))
> + (json-read))))
> + "Read JSON object in buffer, move point to end of buffer.")
Thanks,
João
- bug#40693: 28.0.50; json-encode-alist changes alist, Basil L. Contovounesios, 2020/05/17
- bug#40693: 28.0.50; json-encode-alist changes alist, Eli Zaretskii, 2020/05/18
- bug#40693: 28.0.50; json-encode-alist changes alist, Dmitry Gutov, 2020/05/18
- bug#40693: 28.0.50; json-encode-alist changes alist,
João Távora <=
- bug#40693: 28.0.50; json-encode-alist changes alist, Basil L. Contovounesios, 2020/05/21
- bug#40693: 28.0.50; json-encode-alist changes alist, João Távora, 2020/05/21
- bug#40693: 28.0.50; json-encode-alist changes alist, Basil L. Contovounesios, 2020/05/22
- bug#40693: 28.0.50; json-encode-alist changes alist, João Távora, 2020/05/22
- bug#40693: 28.0.50; json-encode-alist changes alist, Basil L. Contovounesios, 2020/05/23
- bug#40693: 28.0.50; json-encode-alist changes alist, João Távora, 2020/05/23
- bug#40693: 28.0.50; json-encode-alist changes alist, Basil L. Contovounesios, 2020/05/23
- bug#40693: 28.0.50; json-encode-alist changes alist, João Távora, 2020/05/23