Subject: bug#48331: Emacs' describe-package doesn't work for packages managed by guix

From: Andrew Tropin <[email-masked]>
Date: Wed, 19 May 2021 20:58:38 +0300

From: Andrew Tropin <[email-masked]>
Date: Wed, 19 May 2021 20:44:22 +0300
Subject: [PATCH] guix: build: emacs-build-system: Make package.el aware of
 guix packages

After updating the package-directory-list variable, functions like
list-packages,
describe-package become aware of packages installed by guix.

---
This code is getting work done, but I'm not a very experienced elisp
developer, so
please review it thoroughly.

 gnu/packages/aux-files/emacs/guix-emacs.el | 10 ++++++++++
 guix/build/emacs-build-system.scm          |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/aux-files/emacs/guix-emacs.el
b/gnu/packages/aux-files/emacs/guix-emacs.el
index ca9146c535..4aa4220cda 100644
--- a/gnu/packages/aux-files/emacs/guix-emacs.el
+++ b/gnu/packages/aux-files/emacs/guix-emacs.el
@@ -58,6 +58,16 @@ The files in the list do not have extensions (.el, .elc)."
             (load f 'noerror))
           autoloads)))

+
+(require 'package)
+
+;; Set `package-directory-list' to the value without elpa/ suffix
+;; to match the structure of site-lisp directory of guix's emacs
+;; build system.
+;;;###autoload
+(setq package-directory-list
+      (list (string-remove-suffix "/elpa" (car package-directory-list))))
+
 (provide 'guix-emacs)

 ;;; guix-emacs.el ends here
diff --git a/guix/build/emacs-build-system.scm
b/guix/build/emacs-build-system.scm
index e41e9a6595..7565b9a422 100644
--- a/guix/build/emacs-build-system.scm
+++ b/guix/build/emacs-build-system.scm
@@ -53,7 +53,7 @@

 ;; These are the default inclusion/exclusion regexps for the install phase.
 (define %default-include '("^[^/]*\\.el$" "^[^/]*\\.info$" "^doc/.*\\.info$"))
-(define %default-exclude '("^\\.dir-locals\\.el$" "-pkg\\.el$"
+(define %default-exclude '("^\\.dir-locals\\.el$"
                            "^[^/]*tests?\\.el$"))

 (define gnu:unpack (assoc-ref gnu:%standard-phases 'unpack))
-- 
2.31.1