aboutsummaryrefslogtreecommitdiff
path: root/emacs/guix-emacs.el
diff options
context:
space:
mode:
Diffstat (limited to 'emacs/guix-emacs.el')
-rw-r--r--emacs/guix-emacs.el52
1 files changed, 34 insertions, 18 deletions
diff --git a/emacs/guix-emacs.el b/emacs/guix-emacs.el
index 0e3e8c211c..2f809ed16e 100644
--- a/emacs/guix-emacs.el
+++ b/emacs/guix-emacs.el
@@ -37,6 +37,11 @@ they are successfully installed."
(defvar guix-emacs-autoloads nil
"List of the last loaded Emacs autoloads.")
+(defvar guix-emacs-autoloads-regexp
+ (rx (group (* any) "-autoloads")
+ ".el" (zero-or-one "c") string-end)
+ "Regexp to match Emacs 'autoloads' file.")
+
(defun guix-emacs-directory (&optional profile)
"Return directory with Emacs packages installed in PROFILE.
If PROFILE is nil, use `guix-user-profile'."
@@ -44,8 +49,15 @@ If PROFILE is nil, use `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))
+ "Return a list of Emacs 'autoloads' files in DIRECTORY.
+The files in the list do not have extensions (.el, .elc)."
+ (cl-remove-duplicates
+ (delq nil
+ (mapcar (lambda (file)
+ (when (string-match guix-emacs-autoloads-regexp file)
+ (match-string 1 file)))
+ (directory-files directory 'full-name nil 'no-sort)))
+ :test #'string=))
(defun guix-emacs-subdirs (directory)
"Return list of DIRECTORY subdirectories."
@@ -74,29 +86,33 @@ Return nil if there are no emacs packages installed in PROFILE."
nil)))
;;;###autoload
-(defun guix-emacs-load-autoloads (&optional all)
- "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
-after the last activation, otherwise activate all Emacs packages
-installed in `guix-user-profile'."
- (interactive "P")
- (let* ((autoloads (guix-emacs-find-autoloads))
- (files (if all
- autoloads
- (cl-nset-difference autoloads guix-emacs-autoloads
- :test #'string=))))
- (dolist (file files)
- (cl-pushnew (file-name-directory file) load-path
+(defun guix-emacs-load-autoloads (&optional profile)
+ "Load autoloads for Emacs packages installed in PROFILE.
+If PROFILE is nil, use `guix-user-profile'.
+Add autoloads directories to `load-path'."
+ (interactive (list (guix-profile-prompt)))
+ (let* ((autoloads (guix-emacs-find-autoloads profile))
+ (new-autoloads (cl-nset-difference autoloads
+ guix-emacs-autoloads
+ :test #'string=)))
+ (dolist (file new-autoloads)
+ (cl-pushnew (directory-file-name (file-name-directory file))
+ load-path
:test #'string=)
(load file 'noerror))
- (setq guix-emacs-autoloads autoloads)))
+ (setq guix-emacs-autoloads
+ (append new-autoloads guix-emacs-autoloads))))
(defun guix-emacs-load-autoloads-maybe ()
"Load autoloads for Emacs packages if needed.
See `guix-emacs-activate-after-operation' for details."
(and guix-emacs-activate-after-operation
- (guix-emacs-load-autoloads)))
+ ;; FIXME Since a user can work with a non-current profile (using
+ ;; C-u before `guix-search-by-name' and other commands), emacs
+ ;; packages can be installed to another profile, and the
+ ;; following code will not work (i.e., the autoloads for this
+ ;; profile will not be loaded).
+ (guix-emacs-load-autoloads guix-current-profile)))
(provide 'guix-emacs)