diff options
author | Lin Jian <me@linj.tech> | 2023-08-26 09:20:29 +0800 |
---|---|---|
committer | Anderson Torres <torres.anderson.85@protonmail.com> | 2023-08-28 15:46:04 +0000 |
commit | 1506ab49e39cb208774ac49c480b77e9edb4dea7 (patch) | |
tree | 3d371c01eb38cf2a81ed0b5e16d96e5bbea29a60 | |
parent | e8f6a5ce341d3db1cb4c707eb58b3162f93353a3 (diff) |
emacs: correct the order of profiles and their sub dirs in load-path
This patch does two things: 1. making user profiles preferred over system profiles 2. putting sub dirs of one profile to the right place - before this patch, they are appended to the end of load-path - after this patch, they are inserted right after the profile Example value of load-path before this patch: /run/current-system/sw/share/emacs/site-lisp/ /etc/profiles/per-user/user/share/emacs/site-lisp/ /nix/store/hash1-emacs-packages-deps/share/emacs/site-lisp /nix/store/hash1-emacs-packages-deps/share/emacs/site-lisp/elpa /nix/store/hash1-emacs-packages-deps/share/emacs/site-lisp/elpa/wgrep-20230203.1214 /nix/store/hash2-emacs-29.1-rc1/share/emacs/29.1/site-lisp /nix/store/hash2-emacs-29.1-rc1/share/emacs/site-lisp /nix/store/hash2-emacs-29.1-rc1/share/emacs/29.1/lisp /nix/store/hash2-emacs-29.1-rc1/share/emacs/29.1/lisp/vc ... /etc/profiles/per-user/user/share/emacs/site-lisp/elpa /etc/profiles/per-user/user/share/emacs/site-lisp/elpa/jinx-20230730.1200 /run/current-system/sw/share/emacs/site-lisp/elpa /run/current-system/sw/share/emacs/site-lisp/elpa/repology-1.2.3 after this patch: /etc/profiles/per-user/user/share/emacs/site-lisp /etc/profiles/per-user/user/share/emacs/site-lisp/elpa /etc/profiles/per-user/user/share/emacs/site-lisp/elpa/jinx-20230730.1200 /run/current-system/sw/share/emacs/site-lisp /run/current-system/sw/share/emacs/site-lisp/elpa /run/current-system/sw/share/emacs/site-lisp/elpa/repology-1.2.3 /nix/store/hash1-emacs-packages-deps/share/emacs/site-lisp /nix/store/hash1-emacs-packages-deps/share/emacs/site-lisp/elpa /nix/store/hash1-emacs-packages-deps/share/emacs/site-lisp/elpa/wgrep-20230203.1214 /nix/store/hash2-emacs-29.1-rc1/share/emacs/29.1/site-lisp /nix/store/hash2-emacs-29.1-rc1/share/emacs/site-lisp /nix/store/hash2-emacs-29.1-rc1/share/emacs/29.1/lisp /nix/store/hash2-emacs-29.1-rc1/share/emacs/29.1/lisp/vc ...
-rw-r--r-- | pkgs/applications/editors/emacs/site-start.el | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/pkgs/applications/editors/emacs/site-start.el b/pkgs/applications/editors/emacs/site-start.el index acc6833b98c9d..668b76cfd3e80 100644 --- a/pkgs/applications/editors/emacs/site-start.el +++ b/pkgs/applications/editors/emacs/site-start.el @@ -8,8 +8,11 @@ least specific (the system profile)" ;;; 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))) +(dolist (profile (reverse (nix--profile-paths))) + ;; `directory-file-name' is important to add sub dirs to the right place of `load-path' + ;; see the source code of `normal-top-level-add-to-load-path' + (let ((default-directory (directory-file-name + (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)))) |