gnu: emacs: Factorize a ‘guix-emacs--subdirs-files’ procedure.
* gnu/packages/aux-files/emacs/guix-emacs.el (guix-emacs--subdirs-files): New procedure. (guix-emacs-load-package-descriptors): Use it. Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
This commit is contained in:
parent
16cc7b9678
commit
d3bf08872b
1 changed files with 20 additions and 14 deletions
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
;; Copyright © 2014, 2015, 2016, 2017 Alex Kost <alezost@gmail.com>
|
;; Copyright © 2014, 2015, 2016, 2017 Alex Kost <alezost@gmail.com>
|
||||||
;; Copyright © 2017 Kyle Meyer <kyle@kyleam.com>
|
;; Copyright © 2017 Kyle Meyer <kyle@kyleam.com>
|
||||||
;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
|
;; Copyright © 2019, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
|
||||||
|
|
||||||
;; This file is part of GNU Guix.
|
;; This file is part of GNU Guix.
|
||||||
|
|
||||||
|
@ -47,6 +47,13 @@ The files in the list do not have extensions (.el, .elc)."
|
||||||
(string-match-p "/share/emacs/site-lisp" dir))
|
(string-match-p "/share/emacs/site-lisp" dir))
|
||||||
load-path))
|
load-path))
|
||||||
|
|
||||||
|
(defun guix-emacs--subdirs-files ()
|
||||||
|
"Return the Guix subdirs.el files found on the (non-core) load path."
|
||||||
|
(seq-filter #'file-exists-p
|
||||||
|
(mapcar (lambda (dir)
|
||||||
|
(expand-file-name "subdirs.el" dir))
|
||||||
|
(guix-emacs--non-core-load-path))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun guix-emacs-autoload-packages ()
|
(defun guix-emacs-autoload-packages ()
|
||||||
"Autoload Emacs packages found in EMACSLOADPATH.
|
"Autoload Emacs packages found in EMACSLOADPATH.
|
||||||
|
@ -63,19 +70,18 @@ The files in the list do not have extensions (.el, .elc)."
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun guix-emacs-load-package-descriptors ()
|
(defun guix-emacs-load-package-descriptors ()
|
||||||
"Load descriptors for packages found in EMACSLOADPATH via subdirs.el."
|
"Load descriptors for packages found in EMACSLOADPATH via subdirs.el."
|
||||||
(dolist (dir (guix-emacs--non-core-load-path))
|
(dolist (subdirs-file (guix-emacs--subdirs-files))
|
||||||
(let ((subdirs-file (expand-file-name "subdirs.el" dir)))
|
(with-temp-buffer
|
||||||
(when (file-exists-p subdirs-file)
|
(insert-file-contents subdirs-file)
|
||||||
(with-temp-buffer
|
(goto-char (point-min))
|
||||||
(insert-file-contents subdirs-file)
|
(let ((subdirs (read (current-buffer))))
|
||||||
(goto-char (point-min))
|
(and (equal (car-safe subdirs) 'normal-top-level-add-to-load-path)
|
||||||
(let ((subdirs (read (current-buffer))))
|
(equal (car-safe (cadr subdirs)) 'list)
|
||||||
(and (equal (car-safe subdirs) 'normal-top-level-add-to-load-path)
|
(dolist (subdir (cdadr subdirs))
|
||||||
(equal (car-safe (cadr subdirs)) 'list)
|
(let ((pkg-dir (expand-file-name
|
||||||
(dolist (subdir (cdadr subdirs))
|
subdir (file-name-directory subdirs-file))))
|
||||||
(let ((pkg-dir (expand-file-name subdir dir)))
|
(when (file-directory-p pkg-dir)
|
||||||
(when (file-directory-p pkg-dir)
|
(package-load-descriptor pkg-dir)))))))))
|
||||||
(package-load-descriptor pkg-dir)))))))))))
|
|
||||||
|
|
||||||
;; If emacs built with tree-sitter, read the value of the environment variable
|
;; If emacs built with tree-sitter, read the value of the environment variable
|
||||||
;; to make tree-sitter grammars available in emacs out-of-the-box.
|
;; to make tree-sitter grammars available in emacs out-of-the-box.
|
||||||
|
|
Loading…
Reference in a new issue