Subject: bug#55278: 29.0.50; OSM package

From: Richard Stallman <[email-masked]>
Date: Sat, 07 May 2022 19:08:41 -0400

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > Because the actual implementation is in the libjansson library; the
  > Emacs sources only wrap that by a glue to allow use to use JSON with
  > Emacs Lisp objects.

That makes sense, by itself.  But the end result is that the proper
functioning of a user-level feature depends on compiling Emacs with a
special library that most users have never heard of.

If Emacs is compiled without libpng and therefore can't display png
files, that will make sense to the user, because the user can see the
relationship between one and the other.  Users will accept that.

But users won't see any relationship between Open Street Map and
libjansson.  They will say, "How was I supposed to know that???"

I think we had better fix this somehow.

Po Lu wrote:

  > Jansson is a library for parsing JSON.  Emacs provides two mechanisms
  > for parsing JSON into Lisp data, one of which is based on the Jansson
  > library, and the other is implemented in Lisp inside json.el.

  > OSM uses the former, but it can trivially be made to use the latter:

  > --- a/osm.el
  > +++ b/osm.el
  > @@ -39,6 +39,7 @@
 
  >  (require 'bookmark)
  >  (require 'dom)
  > +(require 'json)
  >  (eval-when-compile
  >    (require 'cl-lib)
  >    (require 'subr-x))
  > @@ -1376,14 +1377,12 @@
 
  >  (defun osm--fetch-json (url)
  >    "Get json from URL."
  > -  (json-parse-string
  > +  (json-read-from-string
  >     (let ((default-process-coding-system '(utf-8-unix . utf-8-unix)))
  >       (shell-command-to-string
  >        (concat
  >         "curl " osm-curl-options " "
  > -       (shell-quote-argument url))))
  > -   :array-type 'list
  > -   :object-type 'alist))
  > +       (shell-quote-argument url))))))

How about making osm.el determine whether the C-level one is available,
and use the fastest available one?

Or perhaps define a common interface for the two, so we only need to
document that interface.  That would simplify Emacs overall.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)