about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAnderson Torres <torres.anderson.85@protonmail.com>2022-08-27 02:37:21 -0300
committerGitHub <noreply@github.com>2022-08-27 02:37:21 -0300
commit7165bcb7969ad8ef1ab0ec365f7525616730c41f (patch)
treef88e6a3293dbb7b38dca99eb8799ccfa9fd9ddc3
parentd493cf539f55c2b3daca5f931dc3a630735b861d (diff)
parenta131be8f99862d5fdb34c2aa809c8716493ef56e (diff)
Merge pull request #161445 from chasecaleb/fix-emacs-recursive-load-path
emacs: populate load-path recursively
-rw-r--r--pkgs/applications/editors/emacs/site-start.el24
1 files changed, 8 insertions, 16 deletions
diff --git a/pkgs/applications/editors/emacs/site-start.el b/pkgs/applications/editors/emacs/site-start.el
index 3f9ec25d99f0f..acc6833b98c9d 100644
--- a/pkgs/applications/editors/emacs/site-start.el
+++ b/pkgs/applications/editors/emacs/site-start.el
@@ -5,22 +5,14 @@ The list is ordered from more-specific (the user profile) to the
 least specific (the system profile)"
   (reverse (split-string (or (getenv "NIX_PROFILES") ""))))
 
-;;; Extend `load-path' to search for elisp files in subdirectories of
-;;; all folders in `NIX_PROFILES'. Also search for one level of
-;;; subdirectories in these directories to handle multi-file libraries
-;;; like `mu4e'.'
-(require 'seq)
-(let* ((subdirectory-sites (lambda (site-lisp)
-                             (when (file-exists-p site-lisp)
-                               (seq-filter (lambda (f) (file-directory-p (file-truename f)))
-                                           ;; Returns all files in `site-lisp', excluding `.' and `..'
-                                           (directory-files site-lisp 'full "^\\([^.]\\|\\.[^.]\\|\\.\\..\\)")))))
-       (paths (apply #'append
-                     (mapcar (lambda (profile-dir)
-                               (let ((site-lisp (concat profile-dir "/share/emacs/site-lisp/")))
-                                 (cons site-lisp (funcall subdirectory-sites site-lisp))))
-                             (nix--profile-paths)))))
-  (setq load-path (append paths load-path)))
+;;; Extend `load-path' to search for elisp files in subdirectories of all folders in `NIX_PROFILES'.
+;;; Non-Nix distros have similar logic in /usr/share/emacs/site-lisp/subdirs.el.
+;;; See https://www.gnu.org/software/emacs/manual/html_node/elisp/Library-Search.html
+(dolist (profile (nix--profile-paths))
+  (let ((default-directory (expand-file-name "share/emacs/site-lisp/" profile)))
+    (when (file-exists-p default-directory)
+      (setq load-path (cons default-directory load-path))
+      (normal-top-level-add-subdirs-to-load-path))))
 
 ;;; Remove wrapper site-lisp from EMACSLOADPATH so it's not propagated
 ;;; to any other Emacsen that might be started as subprocesses.