[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat c240ac56ad: Only advise json.c functions from Em
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat c240ac56ad: Only advise json.c functions from Emacs 28 if they exist |
Date: |
Thu, 3 Feb 2022 16:57:21 -0500 (EST) |
branch: externals/compat
commit c240ac56ad83b3800f092d53dc520df3cfd60afb
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
Only advise json.c functions from Emacs 28 if they exist
---
compat-28.1.el | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/compat-28.1.el b/compat-28.1.el
index cf9245731e..df6c8e276b 100644
--- a/compat-28.1.el
+++ b/compat-28.1.el
@@ -152,13 +152,20 @@ If COUNT is non-nil and a natural number, the function
will
;;;; Defined in json.c
+(declare-function json-serialize nil (object &rest args))
+(declare-function json-parse-string nil (string &rest args))
+
(compat-advise json-serialize (object &rest args)
"Handle top-level JSON values."
:cond (condition-case err
;; Use `random' to prevent byte compiler from optimising
;; the "pure" `json-serialize' call.
(ignore (json-serialize (if (random) 0 0)))
- (wrong-type-argument (eq (cadr err) 'json-value-p)))
+ (wrong-type-argument (eq (cadr err) 'json-value-p))
+ ;; `json-serialize' might be disabled at compile time, so we
+ ;; have to check if an error was raised that the function
+ ;; was not defined.
+ (void-function (eq (cadr err) 'json-serialize)))
:realname compat--json-serialize-handle-tlo
:min-version "27"
(if (or (listp object) (vectorp object))
@@ -171,7 +178,11 @@ If COUNT is non-nil and a natural number, the function will
;; Use `random' to prevent byte compiler from optimising
;; the "pure" `json-serialize' call.
(ignore (json-serialize (if (random) 0 0)))
- (wrong-type-argument (eq (cadr err) 'json-value-p)))
+ (wrong-type-argument (eq (cadr err) 'json-value-p))
+ ;; `json-serialize' might be disabled at compile time, so we
+ ;; have to check if an error was raised that the function
+ ;; was not defined.
+ (void-function (eq (cadr err) 'json-serialize)))
:realname compat--json-insert-handle-tlo
:min-version "27"
(if (or (listp object) (vectorp object))
@@ -180,11 +191,15 @@ If COUNT is non-nil and a natural number, the function
will
(compat-advise json-parse-string (string &rest args)
"Handle top-level JSON values."
- :cond (condition-case nil
+ :cond (condition-case err
;; Use `random' to prevent byte compiler from optimising
;; the "pure" `json-serialize' call.
(ignore (json-parse-string (if (random) "0" "0")))
- (json-parse-error t))
+ (json-parse-error t)
+ ;; `json-parse-string' might be disabled at compile time, so
+ ;; we have to check if an error was raised that the function
+ ;; was not defined.
+ (void-function (eq (cadr err) 'json-parse-error)))
:realname compat--json-parse-string-handle-tlo
:min-version "27"
(if (string-match-p "\\`[[:space:]]*[[{]" string)
@@ -196,11 +211,15 @@ If COUNT is non-nil and a natural number, the function
will
(compat-advise json-parse-buffer (&rest args)
"Handle top-level JSON values."
- :cond (condition-case nil
+ :cond (condition-case err
;; Use `random' to prevent byte compiler from optimising
;; the "pure" `json-serialize' call.
(ignore (json-parse-string (if (random) "0" "0")))
- (json-parse-error t))
+ (json-parse-error t)
+ ;; `json-parse-string' might be disabled at compile time, so
+ ;; we have to check if an error was raised that the function
+ ;; was not defined.
+ (void-function (eq (cadr err) 'json-parse-error)))
:realname compat--json-parse-buffer-handle-tlo
:min-version "27"
(if (looking-at-p "[[:space:]]*[[{]")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/compat c240ac56ad: Only advise json.c functions from Emacs 28 if they exist,
ELPA Syncer <=