From: Leo Prikler <leo.prikler@student.tugraz.at>
To: 48331@debbugs.gnu.org
Cc: maxim.cournoyer@gmail.com, andrew@trop.in
Subject: bug#48331: [PATCH 2/2] gnu: emacs: Load package descriptors from packages referenced by subdirs.el
Date: Sat, 22 May 2021 14:54:28 +0200 [thread overview]
Message-ID: <20210522125428.12859-2-leo.prikler@student.tugraz.at> (raw)
In-Reply-To: <20210522125428.12859-1-leo.prikler@student.tugraz.at>
* gnu/packages/aux-files/emacs/guix-emacs.el
(guix-emacs--non-core-load-path): New procedure.
(guix-emacs-autoload-packages): Use it here.
(guix-emacs-load-package-descriptors): New procedure.
* gnu/packages/emacs.scm (emacs)[install-site-start]: Install advice to run
‘guix-emacs-load-package-descriptors’.
---
gnu/packages/aux-files/emacs/guix-emacs.el | 34 +++++++++++++++++-----
gnu/packages/emacs.scm | 7 +++--
2 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/gnu/packages/aux-files/emacs/guix-emacs.el b/gnu/packages/aux-files/emacs/guix-emacs.el
index ca9146c535..eff44bfe90 100644
--- a/gnu/packages/aux-files/emacs/guix-emacs.el
+++ b/gnu/packages/aux-files/emacs/guix-emacs.el
@@ -26,6 +26,7 @@
;;; Code:
(require 'seq)
+(declare-function package-load-descriptor "package" (pkg-dir))
(defvar guix-emacs-autoloads-regexp
(rx (* any) "-autoloads.el" (zero-or-one "c") string-end)
@@ -39,6 +40,12 @@ The files in the list do not have extensions (.el, .elc)."
(directory-files directory 'full-name
guix-emacs-autoloads-regexp))))
+(defun guix-emacs--non-core-load-path ()
+ ;; Filter out core Elisp directories, which are already handled by Emacs.
+ (seq-filter (lambda (dir)
+ (string-match-p "/share/emacs/site-lisp" dir))
+ load-path))
+
;;;###autoload
(defun guix-emacs-autoload-packages ()
"Autoload Emacs packages found in EMACSLOADPATH.
@@ -46,18 +53,29 @@ The files in the list do not have extensions (.el, .elc)."
'Autoload' means to load the 'autoloads' files matching
`guix-emacs-autoloads-regexp'."
(interactive)
- (let* ((emacs-non-core-load-path-directories
- ;; Filter out core Elisp directories, which are already autoloaded
- ;; by Emacs.
- (seq-filter (lambda (dir)
- (string-match-p "/share/emacs/site-lisp" dir))
- load-path))
- (autoloads (mapcan #'guix-emacs-find-autoloads
- emacs-non-core-load-path-directories)))
+ (let ((autoloads (mapcan #'guix-emacs-find-autoloads
+ (guix-emacs--non-core-load-path))))
(mapc (lambda (f)
(load f 'noerror))
autoloads)))
+;;;###autoload
+(defun guix-emacs-load-package-descriptors ()
+ "Load descriptors for packages found in EMACSLOADPATH via subdirs.el."
+ (dolist (dir (guix-emacs--non-core-load-path))
+ (let ((subdirs-file (expand-file-name "subdirs.el" dir)))
+ (when (file-exists-p subdirs-file)
+ (with-temp-buffer
+ (insert-file-contents subdirs-file)
+ (goto-char (point-min))
+ (let ((subdirs (read (current-buffer))))
+ (and (equal (car-safe subdirs) 'normal-top-level-add-to-load-path)
+ (equal (car-safe (cadr subdirs)) 'list)
+ (dolist (subdir (cdadr subdirs))
+ (let ((pkg-dir (expand-file-name subdir dir)))
+ (when (file-directory-p pkg-dir)
+ (package-load-descriptor pkg-dir)))))))))))
+
(provide 'guix-emacs)
;;; guix-emacs.el ends here
diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 5316d25151..e4af6ea6a9 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -166,8 +166,11 @@
(with-output-to-file (string-append lisp-dir "/site-start.el")
(lambda ()
(display
- (string-append "(when (require 'guix-emacs nil t)\n"
- " (guix-emacs-autoload-packages))\n"))))
+ (string-append
+ "(when (require 'guix-emacs nil t)\n"
+ " (guix-emacs-autoload-packages)\n"
+ " (advice-add 'package-load-all-descriptors"
+ " :after #'guix-emacs-load-package-descriptors))"))))
;; Remove the extraneous subdirs.el file, as it causes Emacs to
;; add recursively all the the sub-directories of a profile's
;; share/emacs/site-lisp union when added to EMACSLOADPATH,
--
2.31.1
next prev parent reply other threads:[~2021-05-22 12:56 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-10 7:51 bug#48331: Emacs' describe-package doesn't work for packages managed by guix Andrew Tropin
2021-05-11 10:05 ` Leo Prikler
2021-05-11 15:57 ` Andrew Tropin
2021-05-11 16:33 ` Leo Prikler
2021-05-11 18:55 ` Andrew Tropin
2021-05-11 19:57 ` Leo Prikler
2021-05-19 14:32 ` Andrew Tropin
2021-05-19 15:08 ` Leo Prikler
2021-05-19 17:58 ` Andrew Tropin
2021-05-19 18:42 ` Leo Prikler
2021-05-20 10:01 ` Andrew Tropin
2021-05-20 10:20 ` Leo Prikler
2021-05-20 10:32 ` Arun Isaac
2021-05-20 10:39 ` Arun Isaac
2021-05-20 11:13 ` Leo Prikler
2021-05-20 12:24 ` Andrew Tropin
2021-05-20 15:57 ` Leo Prikler
2021-05-22 3:09 ` Maxim Cournoyer
2021-12-03 20:46 ` Liliana Marie Prikler
2021-12-06 4:52 ` Andrew Tropin
2021-12-30 8:12 ` Andrew Tropin
2021-05-11 21:17 ` Ludovic Courtès
2021-05-19 14:41 ` Andrew Tropin
2021-05-22 12:54 ` bug#48331: [PATCH 1/2] build-system: emacs: Keep -pkg.el files Leo Prikler
2021-05-22 12:54 ` Leo Prikler [this message]
2021-05-25 13:40 ` bug#48331: [PATCH draft] build-system: emacs: Generate -pkg.el file in case it is missing Andrew Tropin
2021-05-25 15:07 ` Leo Prikler
2021-05-26 8:15 ` bug#48331: [PATCH] guix: build: emacs-build-system: Make package.el aware of guix packages Ivan Sokolov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210522125428.12859-2-leo.prikler@student.tugraz.at \
--to=leo.prikler@student.tugraz.at \
--cc=48331@debbugs.gnu.org \
--cc=andrew@trop.in \
--cc=maxim.cournoyer@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).