From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOz5U-0007CY-3d for guix-patches@gnu.org; Tue, 12 Dec 2017 23:56:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eOz5O-0001ZM-7H for guix-patches@gnu.org; Tue, 12 Dec 2017 23:56:08 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:50597) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eOz5O-0001ZD-2P for guix-patches@gnu.org; Tue, 12 Dec 2017 23:56:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eOz5N-0008Vk-Lx for guix-patches@gnu.org; Tue, 12 Dec 2017 23:56:01 -0500 Subject: [bug#28832] [PATCH 1/3] gnu: Add emacs-json-reformat. Resent-Message-ID: From: Oleg Pykhalov References: <87lgke3vlz.fsf@gmail.com> <20171014102915.11778-1-go.wigust@gmail.com> <87y3o6uheo.fsf@gnu.org> <87d13yiw6w.fsf@gnu.org> <87609cluzf.fsf@gmail.com> <87zi6os3u3.fsf@gnu.org> <87fu8famhm.fsf@gmail.com> Date: Wed, 13 Dec 2017 07:55:22 +0300 In-Reply-To: <87fu8famhm.fsf@gmail.com> (Alex Kost's message of "Tue, 12 Dec 2017 20:23:49 +0300") Message-ID: <87r2rzi5vp.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Alex Kost Cc: 28832@debbugs.gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello Alex and Ludovic, Alex Kost writes: [...] >> If =E2=80=98emacs-build-system=E2=80=99 sets =E2=80=98EMACSLOADPATH=E2= =80=99 automatically, then >> individual package definitions won=E2=80=99t need those -L flags. Dunno= if >> there are good reasons not to do so. Maybe Alex has an opinion? > > I would rather ask Federico who wrote =E2=80=98emacs-build-system=E2=80= =99 :) Do you mean Federico Beffa ? He is quite in Guix git repository for 9 months as I see. Is it a good idea to CC him? > Yeah, maybe =E2=80=98emacs-build-system=E2=80=99 could benefit from using= EMACSLOADPATH, > I don't know, someone should probably give it a try ;-) I succeeded to implement this, but the patch needs some more love. The biggest issue is how to get an Emacs version in setup-environment. You could test it on emacs-git-messenger or emacs-json-reformat. --=-=-= Content-Type: text/x-patch Content-Disposition: inline Content-Description: EMACSLOADPATH diff --git a/guix/build/emacs-build-system.scm b/guix/build/emacs-build-system.scm index bd0d2e026..269038744 100644 --- a/guix/build/emacs-build-system.scm +++ b/guix/build/emacs-build-system.scm @@ -183,6 +183,10 @@ store in '.el' files." "Check if NAME correspond to the name of an Emacs package." (string-prefix? "emacs-" name)) +(define (string-drop-emacs x) + "Drops `emacs-' from a string." + (string-drop x 6)) + (define (emacs-inputs inputs) "Retrieve the list of Emacs packages from INPUTS." (filter (match-lambda @@ -222,6 +226,38 @@ second hyphen. This corresponds to 'name-version' as used in ELPA packages." strip-store-file-name) store-dir)) +;; Copied from haskell-build-system.scm +(define (package-name-version store-dir) + "Given a store directory STORE-DIR return 'name-version' of the package." + (let* ((base (basename store-dir))) + (string-drop base (+ 1 (string-index base #\-))))) + +(define* (setup-environment #:key inputs outputs #:allow-other-keys) + "Export the variable EMACSLOADPATH, which are based on INPUTS and OUTPUTS, +respectively." + (let ((out (assoc-ref outputs "out"))) + ;; EMACSLOADPATH is where Emacs looks for the source code of the build's + ;; dependencies. + (set-path-environment-variable + "EMACSLOADPATH" + ;; XXX Matching "." hints that we could do + ;; something simpler here... + (list ".") + (cons (let ((store-item (cdr (assoc "emacs" (emacs-inputs inputs))))) + ;; TODO: Get a version from inputs + (string-append store-item "/share/emacs/25.3/lisp")) + (map + (lambda (foobar) + (let ((store-item (cdr foobar))) + (string-append store-item + %install-suffix "/" + (string-drop-emacs + (package-name-version store-item))))) + (alist-delete "emacs" + (alist-delete "source" + (emacs-inputs inputs)))))) + #t)) + (define %standard-phases (modify-phases gnu:%standard-phases (replace 'unpack unpack) @@ -229,6 +265,7 @@ second hyphen. This corresponds to 'name-version' as used in ELPA packages." (delete 'check) (delete 'install) (replace 'build build) + (add-before 'build 'setup-environment setup-environment) (add-before 'build 'install install) (add-after 'install 'make-autoloads make-autoloads) (add-after 'make-autoloads 'patch-el-files patch-el-files) --=-=-= Content-Type: text/plain > BTW, Oleg, did you try to use 'ert-runner' instead of running emacs for > tests manually? Perhaps, it will work; look at commit > 8505d34829b99744a36d72dd583768f1e49210a6 for example. Nope, but I will. Thank you for notice this! Thanks, Oleg. --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEc+OyAXw1EaDPCmAPckbhHGm3lWkFAlowsroACgkQckbhHGm3 lWkavRAAgBL33pB4bdv+sWGKvHB7coEznQ7CnjrXzB6bkJ9xePWfnfeiOIkr2Sbf 3RtsKLB7PmNpdZe/J5ps98iNSURXOjZvswhwL13bJP53EZr9+/cBTBXZwRZfuGjv q8lv1U93MSKh5l3loGtcVri6M3s7ACnrebv74kvNwN3c/pXHU5WpKh/qhd8ni5XO WDLKaJq2iz2nlvvnwJCJlmJ1w8bv+12MITtL1K4oViRm6+UL7t+5ccKuR0J7d/6b yE73LodudKE9+JrtKaMyfjMD+hGvQyOL5FmcoAT1nJEHzy4I+Wx/dLmmvPf/BTpa g1TelDLOOWsnszgM8eutkDUiDBlQ/1IADAbuk7ypon22pqFURVKVUXoCrhLlTtvq E/XPpmlRRdw9UaEui4Htv5TCYp0L5sGgLtBulN31Di9FH/xQi6gRO0wunR3Aamat 1g+O17Gwg7bTrc5lIvbW17WzQ/HWsd6MyIqSotfwpF69CEAQdWAXRVgKICuZdw4X YVyYsVzcuv0ny/ebY0v/0ZTnZ8V4gJQr8dtRsv4QSnnpx18wjz1HFLfKomlyBzjP wQfGPsuIuJpxn3ZRYyUg5jJJEZWkhqwE5GSYWZDN7kkhtzaMptPjLCAqePxzOjwt RaPv8h+YZvSpSXW6hIO7aysaIF26IGwAoSPaGwCLhXALcaWVp8U= =zHnc -----END PGP SIGNATURE----- --==-=-=--