[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/04: gnu: emacs: Load package descriptors from packages referenced by
From: |
guix-commits |
Subject: |
04/04: gnu: emacs: Load package descriptors from packages referenced by subdirs.el |
Date: |
Fri, 3 Dec 2021 15:40:25 -0500 (EST) |
lilyp pushed a commit to branch master
in repository guix.
commit 15404ff19b304bc9efcdb9a326318fb9fa9716da
Author: Liliana Marie Prikler <liliana.prikler@gmail.com>
AuthorDate: Sat May 22 14:54:28 2021 +0200
gnu: emacs: Load package descriptors from packages referenced by subdirs.el
* 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 ca9146c..eff44bf 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 f534b1c..03f8c25 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -185,8 +185,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,