GNU bug report logs - #60311
json-available-p: make dynamically correct for Windows

Previous Next

Package: emacs;

Reported by: Mattias Engdegård <mattias.engdegard <at> gmail.com>

Date: Sun, 25 Dec 2022 14:33:01 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Mattias Engdegård <mattias.engdegard <at> gmail.com>
Cc: 60311 <at> debbugs.gnu.org
Subject: bug#60311: json-available-p: make dynamically correct for Windows
Date: Sun, 25 Dec 2022 20:43:11 +0200
> From: Mattias Engdegård <mattias.engdegard <at> gmail.com>
> Date: Sun, 25 Dec 2022 15:32:06 +0100
> 
> --- a/lisp/subr.el
> +++ b/lisp/subr.el
> @@ -6905,11 +6905,11 @@ internal--format-docstring-line
>  
>  (defun json-available-p ()
>    "Return non-nil if Emacs has libjansson support."
> -  (and (fboundp 'json-serialize)
> -       (condition-case nil
> -           (json-serialize t)
> -         (:success t)
> -         (json-unavailable nil))))
> +  (declare (side-effect-free error-free))
> +  (and (eval-when-compile (fboundp 'json-serialize))
> +       ;; If `json--available-p' is present, we need to call it at run-time.
> +       (or (not (eval-when-compile (fboundp 'json--available-p)))
> +           (json--available-p))))

Btw, I don't understand this use of eval-when-compile here.  Can you
explain why should we care at compile time whether these functions are
fboundp?

IOW, why not just

  (and (fboundp 'json--available-p)
       (json--available-p))

?




This bug report was last modified 2 years and 201 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.