Subject: [bug#30884] [PATCH 4/6] gnu: Add emacs-emacsql.

From: [email-masked] (Ludovic Courtès)
Date: Wed, 04 Apr 2018 14:37:24 +0200

Oleg Pykhalov <[email-masked]> skribis:

> * gnu/packages/emacs.scm (emacs-emacsql): New public variable.

[...]

> +         (add-after 'patch-elisp-shell-shebangs 'setenv-emacsloadpath
> +           (lambda* (#:key inputs #:allow-other-keys)
> +             (define (el-dir store-dir)
> +               (match (find-files store-dir "\\.el$")
> +                 ((f1 f2 ...) (dirname f1))
> +                 (_ "")))
> +             (define emacs-prefix? (cut string-prefix? "emacs-" <>))
> +             (let* ((emacs-load-paths
> +                     (map (match-lambda
> +                            (((? emacs-prefix? name) . dir)
> +                             (string-append (el-dir dir) ":"))
> +                            (_ ""))
> +                          inputs))
> +                    (emacs-load-path-value
> +                     (string-concatenate emacs-load-paths)))
> +               (format #t "environment variable `EMACSLOADPATH' set to ~a\n"
> +                       emacs-load-path-value)
> +               (setenv "EMACSLOADPATH" emacs-load-path-value))

Now that there’s a new ‘set-emacs-load-path’, I suspect this phase can
be removed.  Can you confirm, Maxim?

> +         (add-after 'build-emacsql-sqlite 'install-emacsql-sqlite
> +           (lambda* (#:key outputs #:allow-other-keys)
> +             (install-file "sqlite/emacsql-sqlite"
> +                           (string-append (assoc-ref outputs "out")
> +                                          "/bin"))
> +             #t))
> +         (add-after 'install-emacsql-sqlite 'patch-emacsql-sqlite.el
> +           (lambda* (#:key outputs #:allow-other-keys)
> +             (let ((file "emacsql-sqlite.el"))
> +               (chmod file #o644)
> +               (emacs-substitute-sexps file
> +                 ("(defvar emacsql-sqlite-user-prompted" 't)
> +                 ("(executable-find" (which "gcc"))
> +                 ("(defvar emacsql-sqlite-executable"
> +                  (string-append (assoc-ref outputs "out")
> +                                 "/bin/emacsql-sqlite"))))))

Please add short comments explaining what’s going on in these phases.

> +    (home-page "https://github.com/skeeto/emacsql")
> +    (synopsis "Emacs high-level SQL database front-end")
> +    (description "EmacSQL provides a high-level Emacs Lisp front-end for
> +SQLite (primarily), PostgreSQL, MySQL, and potentially other SQL databases.")

I would add this, taken from their README:

  Any readable Lisp value can be stored as a value in EmacSQL, including
  numbers, strings, symbols, lists, vectors, and closures.  EmacSQL has
  no concept of @code{TEXT} values; it's all just Lisp objects.  The Lisp
  object @code{nil} corresponds 1:1 with @code{NULL} in the database.

Otherwise LGTM, thanks!

Ludo’.