From a131be8f99862d5fdb34c2aa809c8716493ef56e Mon Sep 17 00:00:00 2001 From: Caleb Chase Date: Tue, 22 Feb 2022 19:55:58 -0600 Subject: emacs: populate load-path recursively Previous behavior only added /share/emacs/site-lisp/ and one level of subdirectories, whereas this commit adds all subdirectories recursively using normal-top-level-add-subdirs-to-load-path. This matches the behavior of Emacs on non-Nix distros, which include a /usr/share/emacs/site-lisp/subdirs.el file with identical recursive behavior. See also: https://www.emacswiki.org/emacs/LoadPath --- pkgs/applications/editors/emacs/site-start.el | 24 ++++++++---------------- 1 file 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. -- cgit 1.4.1