build-system: emacs: Search all inputs for Emacs Lisp directories.

* guix/build/emacs-build-system.scm (set-emacs-load-path): Include Emacs Lisp
directories from all inputs. Also, add the unpacked source directory to
EMACSLOADPATH.
(emacs-inputs, emacs-inputs-directories, emacs-input->el-directory,
emacs-inputs-el-directories): Remove.
(%standard-phases): Move set-emacs-load-path phase to after unpack phase.

Signed-off-by: Arun Isaac <arunisaac@systemreboot.net>
This commit is contained in:
Maxim Cournoyer 2018-03-29 20:52:41 -04:00 committed by Arun Isaac
parent 2bb915e679
commit b5904fcc34
No known key found for this signature in database
GPG Key ID: 2E25EE8B61802BB3
1 changed files with 31 additions and 40 deletions

View File

@ -74,12 +74,37 @@ archive, a directory, or an Emacs Lisp file."
#t) #t)
(gnu:unpack #:source source))) (gnu:unpack #:source source)))
(define* (set-emacs-load-path #:key inputs #:allow-other-keys) (define* (set-emacs-load-path #:key source inputs #:allow-other-keys)
(define (inputs->directories inputs)
"Extract the directory part from INPUTS."
(match inputs
(((names . directories) ...) directories)))
(define (input-directory->el-directory input-directory)
"Return the correct Emacs Lisp directory in INPUT-DIRECTORY or #f, if there
is no Emacs Lisp directory."
(let ((legacy-elisp-directory (string-append input-directory %legacy-install-suffix))
(guix-elisp-directory
(string-append
input-directory %install-suffix "/"
(store-directory->elpa-name-version input-directory))))
(cond
((file-exists? guix-elisp-directory) guix-elisp-directory)
((file-exists? legacy-elisp-directory) legacy-elisp-directory)
(else #f))))
(define (input-directories->el-directories input-directories)
"Return the list of Emacs Lisp directories in INPUT-DIRECTORIES."
(filter-map input-directory->el-directory input-directories))
"Set the EMACSLOADPATH environment variable so that dependencies are found." "Set the EMACSLOADPATH environment variable so that dependencies are found."
(let* ((input-elisp-dirs (emacs-inputs-el-directories (let* ((source-directory (getcwd))
(emacs-inputs-directories inputs))) (input-elisp-directories (input-directories->el-directories
(emacs-load-path-value (string-join (inputs->directories inputs)))
input-elisp-dirs ":" 'suffix))) (emacs-load-path-value
(string-join
(append input-elisp-directories (list source-directory))
":" 'suffix)))
(setenv "EMACSLOADPATH" emacs-load-path-value) (setenv "EMACSLOADPATH" emacs-load-path-value)
(format #t "environment variable `EMACSLOADPATH' set to ~a\n" (format #t "environment variable `EMACSLOADPATH' set to ~a\n"
emacs-load-path-value))) emacs-load-path-value)))
@ -210,40 +235,6 @@ store in '.el' files."
"Check if NAME correspond to the name of an Emacs package." "Check if NAME correspond to the name of an Emacs package."
(string-prefix? "emacs-" name)) (string-prefix? "emacs-" name))
(define (emacs-inputs inputs)
"Retrieve the list of Emacs packages from INPUTS."
(filter (match-lambda
((label . directory)
(emacs-package? ((compose package-name->name+version
strip-store-file-name)
directory)))
(_ #f))
inputs))
(define (emacs-inputs-directories inputs)
"Extract the list of Emacs package directories from INPUTS."
(let ((inputs (emacs-inputs inputs)))
(match inputs
(((names . directories) ...) directories))))
(define (emacs-input->el-directory emacs-input)
"Return the correct Elisp directory location of EMACS-INPUT or #f if none."
(let ((legacy-elisp-dir (string-append emacs-input %legacy-install-suffix))
(guix-elisp-dir (string-append
emacs-input %install-suffix "/"
(store-directory->elpa-name-version emacs-input))))
(cond
((file-exists? guix-elisp-dir) guix-elisp-dir)
((file-exists? legacy-elisp-dir) legacy-elisp-dir)
(else (format #t "warning: could not locate elisp directory under `~a'\n"
emacs-input)
#f))))
(define (emacs-inputs-el-directories dirs)
"Build the list of Emacs Lisp directories from the Emacs package directory
DIRS."
(filter-map emacs-input->el-directory dirs))
(define (package-name-version->elpa-name-version name-ver) (define (package-name-version->elpa-name-version name-ver)
"Convert the Guix package NAME-VER to the corresponding ELPA name-version "Convert the Guix package NAME-VER to the corresponding ELPA name-version
format. Essentially drop the prefix used in Guix." format. Essentially drop the prefix used in Guix."
@ -260,8 +251,8 @@ second hyphen. This corresponds to 'name-version' as used in ELPA packages."
(define %standard-phases (define %standard-phases
(modify-phases gnu:%standard-phases (modify-phases gnu:%standard-phases
(add-after 'set-paths 'set-emacs-load-path set-emacs-load-path)
(replace 'unpack unpack) (replace 'unpack unpack)
(add-after 'unpack 'set-emacs-load-path set-emacs-load-path)
(delete 'configure) (delete 'configure)
;; Move the build phase after install: the .el files are byte compiled ;; Move the build phase after install: the .el files are byte compiled
;; directly in the store. ;; directly in the store.