From mboxrd@z Thu Jan 1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Philipp Stephani
Newsgroups: gmane.emacs.help
Subject: Re: How to test for native JSON support?
Date: Tue, 4 May 2021 16:32:52 +0200
Message-ID:
References: <87k0ohuybx.fsf@fastmail.fm>
<785b4132-da32-0da8-519d-b39a58270f32@gmail.com>
<87y2cuybeu.fsf@passepartout.tim-landscheidt.de> <838s4u66f0.fsf@gnu.org>
<87fsz2n075.fsf@fastmail.fm> <834kfi64ts.fsf@gnu.org>
<8a5699f0-5532-2f6f-f2dd-4f804f02468f@yandex.ru>
<83v97y4my9.fsf@gnu.org> <2510de19-5b28-06d3-9a7b-631c9e506578@yandex.ru>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
logging-data="17768"; mail-complaints-to="usenet@ciao.gmane.io"
Cc: help-gnu-emacs
To: Dmitry Gutov
Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 04 16:36:06 2021
Return-path:
Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org
Original-Received: from lists.gnu.org ([209.51.188.17])
by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.92)
(envelope-from )
id 1ldw9d-0004T5-TA
for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 04 May 2021 16:36:05 +0200
Original-Received: from localhost ([::1]:59082 helo=lists1p.gnu.org)
by lists.gnu.org with esmtp (Exim 4.90_1)
(envelope-from )
id 1ldw9d-0002am-0u
for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 04 May 2021 10:36:05 -0400
Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58736)
by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from )
id 1ldw6p-0000FR-5K
for help-gnu-emacs@gnu.org; Tue, 04 May 2021 10:33:11 -0400
Original-Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]:42689)
by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
(Exim 4.90_1) (envelope-from )
id 1ldw6k-0003To-1A; Tue, 04 May 2021 10:33:10 -0400
Original-Received: by mail-ot1-x335.google.com with SMTP id
g15-20020a9d128f0000b02902a7d7a7bb6eso1644585otg.9;
Tue, 04 May 2021 07:33:04 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:cc; bh=fTmSy+SkQVffYVNDktic7HzOKhDZblZomsT64uPGQiM=;
b=njtRiQOOhR80bK9r6OYtFFyuZSoTGuA2VzYZFzC0JSvQr6ao6FUq61n66nRMDSxITb
wYMTtopSJDnGTYUqbuXcxY1m4UIWRd3Eq+ju+bPk2X//vegDxgUnzLFhjI+4wPjS98R9
RwI+R04CgT54PIEXkLM9M+T+Yi74sH1GasPtAO4VNtzsMYlCTDMKk/QlwkZV/jkKNsxH
Wsy4E1FcIpbp4Ts/xfcKvCEL1+3xrq7A6aCA9D4BPDXp+CNJJGXvyQ7LgmJ3BZNsPiU0
nSSTqOyXkp7Koeas9oiF3foEujxrXG7cdgM/3EtukJlqS/wYxo9zN2pETcm3eMZoyeqB
BqIQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:cc;
bh=fTmSy+SkQVffYVNDktic7HzOKhDZblZomsT64uPGQiM=;
b=KC1CbYm4eKvqOLuvGI73iodmmD4SUVUNQdKpXRDY4PpHdYyZGRwBXGsCBPWyvahHdI
MVMfRE044rs/GjPcgf+jD9v03qU/6+JZymYv9uiPcIdqhrPDtC2kC77F05IYEu7IUmJ4
j+cQtnEhbrHE5spvEH2g5J6o4Shk5pNTuOkH2AmOtvjwE5mpSY2NNYged9QJHAf+FitW
IQZoGbQr4UxFUO2MqwMqlD/9AwW6z3+Y5zJCIW/GzBZrzCqvLcM9ztNxgvdpIbMvj5jO
idnvoTuGtn+p12AQhRzYDrN8SZZvLzVOQujWxXLv4wAyW0Zew/Ge2XzYaNcccR7/626x
gqFA==
X-Gm-Message-State: AOAM530BRJn7jv+HB6K2ErSkcVDE8P1MwVbyIgXeBrUe4x9FQ3fZKERH
BqEhyBk+D6aLQjUmkm7YMdnMeAD6pjQn4BJ7Mt0=
X-Google-Smtp-Source: ABdhPJyTPqfsSEHRSEonICfJVzHZfwB1wRO6oIzAFNkGISodvv8Ltj6hG/SdWvH46M2PukdoSupyE7LLsMIpFdpmayU=
X-Received: by 2002:a9d:4e19:: with SMTP id p25mr19379267otf.156.1620138783699;
Tue, 04 May 2021 07:33:03 -0700 (PDT)
In-Reply-To: <2510de19-5b28-06d3-9a7b-631c9e506578@yandex.ru>
Received-SPF: pass client-ip=2607:f8b0:4864:20::335;
envelope-from=p.stephani2@gmail.com; helo=mail-ot1-x335.google.com
X-Spam_score_int: -17
X-Spam_score: -1.8
X-Spam_bar: -
X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001,
RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-BeenThere: help-gnu-emacs@gnu.org
X-Mailman-Version: 2.1.23
Precedence: list
List-Id: Users list for the GNU Emacs text editor
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org
Original-Sender: "help-gnu-emacs"
Xref: news.gmane.io gmane.emacs.help:129430
Archived-At:
Am Di., 4. Mai 2021 um 16:31 Uhr schrieb Dmitry Gutov :
>
> On 04.05.2021 17:01, Eli Zaretskii wrote:
>
> > Feel free to suggest a patch,
>
> Like this?
>
> diff --git a/src/json.c b/src/json.c
> index 3f1d27ad7f..ece057ae41 100644
> --- a/src/json.c
> +++ b/src/json.c
> @@ -596,8 +596,7 @@ DEFUN ("json-serialize", Fjson_serialize,
> Sjson_serialize, 1, MANY,
> }
> if (!json_initialized)
> {
> - message1 ("jansson library not found");
> - return Qnil;
> + Fsignal (Qerror, list1 (build_unibyte_string ("jansson library
> not found")));
> }
> #endif
>
> @@ -707,8 +706,7 @@ DEFUN ("json-insert", Fjson_insert, Sjson_insert, 1,
> MANY,
> }
> if (!json_initialized)
> {
> - message1 ("jansson library not found");
> - return Qnil;
> + Fsignal (Qerror, list1 (build_unibyte_string ("jansson library
> not found")));
> }
> #endif
>
> @@ -966,8 +964,7 @@ DEFUN ("json-parse-string", Fjson_parse_string,
> Sjson_parse_string, 1, MANY,
> }
> if (!json_initialized)
> {
> - message1 ("jansson library not found");
> - return Qnil;
> + Fsignal (Qerror, list1 (build_unibyte_string ("jansson library
> not found")));
> }
> #endif
>
> @@ -1065,8 +1062,7 @@ DEFUN ("json-parse-buffer", Fjson_parse_buffer,
> Sjson_parse_buffer,
> }
> if (!json_initialized)
> {
> - message1 ("jansson library not found");
> - return Qnil;
> + Fsignal (Qerror, list1 (build_unibyte_string ("jansson library
> not found")));
> }
> #endif
>
Can you make this signal a specific error symbol so that callers can
catch the error and react accordingly, e.g. by falling back to
json.el?