mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-25 22:08:16 -05:00
emacs: Find autoloads in "guix.d" subdirectories.
Co-authored-by: Federico Beffa <beffa@fbengineering.ch>. * emacs/guix-emacs.el (guix-emacs-find-autoloads-in-directory, guix-emacs-subdirs): New functions. (guix-emacs-find-autoloads): Search for autoloads in "guix.d" subdirectories. (guix-emacs-load-autoloads): Add subdirectories to 'load-path'. * emacs/guix-init.el.in: Do not add guix emacs directory to 'load-path' because it will be done by 'guix-emacs-load-autoloads'. Move requiring 'guix-emacs' from the top-level to a clause for checking for 'guix-package-enable-at-startup'.
This commit is contained in:
parent
d43002f645
commit
7741139080
2 changed files with 27 additions and 6 deletions
|
@ -42,19 +42,40 @@ If PROFILE is nil, use `guix-user-profile'."
|
||||||
(expand-file-name "share/emacs/site-lisp"
|
(expand-file-name "share/emacs/site-lisp"
|
||||||
(or profile guix-user-profile)))
|
(or profile guix-user-profile)))
|
||||||
|
|
||||||
|
(defun guix-emacs-find-autoloads-in-directory (directory)
|
||||||
|
"Return list of Emacs 'autoloads' files in DIRECTORY."
|
||||||
|
(directory-files directory 'full-name "-autoloads\\.el\\'" 'no-sort))
|
||||||
|
|
||||||
|
(defun guix-emacs-subdirs (directory)
|
||||||
|
"Return list of DIRECTORY subdirectories."
|
||||||
|
(cl-remove-if (lambda (file)
|
||||||
|
(or (string-match-p (rx "/." string-end) file)
|
||||||
|
(string-match-p (rx "/.." string-end) file)
|
||||||
|
(not (file-directory-p file))))
|
||||||
|
(directory-files directory 'full-name nil 'no-sort)))
|
||||||
|
|
||||||
(defun guix-emacs-find-autoloads (&optional profile)
|
(defun guix-emacs-find-autoloads (&optional profile)
|
||||||
"Return list of autoloads of Emacs packages installed in PROFILE.
|
"Return list of autoloads of Emacs packages installed in PROFILE.
|
||||||
If PROFILE is nil, use `guix-user-profile'.
|
If PROFILE is nil, use `guix-user-profile'.
|
||||||
Return nil if there are no emacs packages installed in PROFILE."
|
Return nil if there are no emacs packages installed in PROFILE."
|
||||||
(let ((dir (guix-emacs-directory profile)))
|
(let ((elisp-root-dir (guix-emacs-directory profile)))
|
||||||
(if (file-directory-p dir)
|
(if (file-directory-p elisp-root-dir)
|
||||||
(directory-files dir 'full-name "-autoloads\\.el\\'")
|
(let ((elisp-pkgs-dir (expand-file-name "guix.d" elisp-root-dir))
|
||||||
|
(root-autoloads (guix-emacs-find-autoloads-in-directory
|
||||||
|
elisp-root-dir)))
|
||||||
|
(if (file-directory-p elisp-pkgs-dir)
|
||||||
|
(let ((pkgs-autoloads
|
||||||
|
(cl-mapcan #'guix-emacs-find-autoloads-in-directory
|
||||||
|
(guix-emacs-subdirs elisp-pkgs-dir))))
|
||||||
|
(append root-autoloads pkgs-autoloads))
|
||||||
|
root-autoloads))
|
||||||
(message "Directory '%s' does not exist." dir)
|
(message "Directory '%s' does not exist." dir)
|
||||||
nil)))
|
nil)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun guix-emacs-load-autoloads (&optional all)
|
(defun guix-emacs-load-autoloads (&optional all)
|
||||||
"Load autoloads for Emacs packages installed in a user profile.
|
"Load autoloads for Emacs packages installed in a user profile.
|
||||||
|
Add autoloads directories to `load-path'.
|
||||||
If ALL is nil, activate only those packages that were installed
|
If ALL is nil, activate only those packages that were installed
|
||||||
after the last activation, otherwise activate all Emacs packages
|
after the last activation, otherwise activate all Emacs packages
|
||||||
installed in `guix-user-profile'."
|
installed in `guix-user-profile'."
|
||||||
|
@ -65,6 +86,8 @@ installed in `guix-user-profile'."
|
||||||
(cl-nset-difference autoloads guix-emacs-autoloads
|
(cl-nset-difference autoloads guix-emacs-autoloads
|
||||||
:test #'string=))))
|
:test #'string=))))
|
||||||
(dolist (file files)
|
(dolist (file files)
|
||||||
|
(cl-pushnew (file-name-directory file) load-path
|
||||||
|
:test #'string=)
|
||||||
(load file 'noerror))
|
(load file 'noerror))
|
||||||
(setq guix-emacs-autoloads autoloads)))
|
(setq guix-emacs-autoloads autoloads)))
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
(require 'guix-autoloads)
|
(require 'guix-autoloads)
|
||||||
(require 'guix-emacs)
|
|
||||||
|
|
||||||
(defvar guix-load-path
|
(defvar guix-load-path
|
||||||
(replace-regexp-in-string "${prefix}" "@prefix@" "@emacsuidir@")
|
(replace-regexp-in-string "${prefix}" "@prefix@" "@emacsuidir@")
|
||||||
|
@ -13,9 +12,8 @@ avoid loading autoloads of Emacs packages installed in
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
:group 'guix)
|
:group 'guix)
|
||||||
|
|
||||||
(add-to-list 'load-path (guix-emacs-directory))
|
|
||||||
|
|
||||||
(when guix-package-enable-at-startup
|
(when guix-package-enable-at-startup
|
||||||
|
(require 'guix-emacs)
|
||||||
(guix-emacs-load-autoloads 'all))
|
(guix-emacs-load-autoloads 'all))
|
||||||
|
|
||||||
(provide 'guix-init)
|
(provide 'guix-init)
|
||||||
|
|
Loading…
Reference in a new issue