summaryrefslogtreecommitdiffstats
path: root/pkgs/applications/editors/emacs/site-start.el
diff options
context:
space:
mode:
authorMoritz Ulrich <moritz@tarn-vedra.de>2018-01-04 11:16:35 +0100
committerMoritz Ulrich <moritz@tarn-vedra.de>2018-01-05 10:50:13 +0100
commit1543c8cc01a4501ec9286e03ccf92965deff611e (patch)
tree2f8005b72f3fb57ce4ed264bde6ca9fc9ccb0939 /pkgs/applications/editors/emacs/site-start.el
parent6484eac5b2e38490724d9df3079e736605c7eeb6 (diff)
emacs: Add more documentation to `site-start.el`
`site-start.el` is the file loaded on startup, containing nix-specific customizations like adding paths in `NIX_PROFILES` to the emacs-specific search-path (`load-path`) or making man-pages in these directories discoverable.
Diffstat (limited to 'pkgs/applications/editors/emacs/site-start.el')
-rw-r--r--pkgs/applications/editors/emacs/site-start.el26
1 files changed, 18 insertions, 8 deletions
diff --git a/pkgs/applications/editors/emacs/site-start.el b/pkgs/applications/editors/emacs/site-start.el
index b41ca92db086..004b917ebb6d 100644
--- a/pkgs/applications/editors/emacs/site-start.el
+++ b/pkgs/applications/editors/emacs/site-start.el
@@ -1,18 +1,28 @@
-;;; NixOS specific load-path
+(defun nix--profile-paths ()
+ "Returns a list of all paths in the NIX_PROFILES environment
+variable, 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'
(setq load-path
- (append (reverse (mapcar (lambda (x) (concat x "/share/emacs/site-lisp/"))
- (split-string (or (getenv "NIX_PROFILES") ""))))
+ (append (mapcar (lambda (x) (concat x "/share/emacs/site-lisp/"))
+ (nix--profile-paths))
load-path))
;;; Make `woman' find the man pages
(eval-after-load 'woman
'(setq woman-manpath
- (append (reverse (mapcar (lambda (x) (concat x "/share/man/"))
- (split-string (or (getenv "NIX_PROFILES") ""))))
+ (append (mapcar (lambda (x) (concat x "/share/man/"))
+ (nix--profile-paths))
woman-manpath)))
;;; Make tramp work for remote NixOS machines
(eval-after-load 'tramp
+ ;; TODO: We should also add the other `NIX_PROFILES' to this path.
+ ;; However, these are user-specific, so we would need to discover
+ ;; them dynamically after connecting via `tramp'
'(add-to-list 'tramp-remote-path "/run/current-system/sw/bin"))
;;; C source directory
@@ -22,9 +32,9 @@
;;; from: /nix/store/<hash>-emacs-<version>/share/emacs/site-lisp/site-start.el
;;; to: /nix/store/<hash>-emacs-<version>/share/emacs/<version>/src/
(let ((emacs
- (file-name-directory ;; .../emacs/
- (directory-file-name ;; .../emacs/site-lisp
- (file-name-directory load-file-name)))) ;; .../emacs/site-lisp/
+ (file-name-directory ; .../emacs/
+ (directory-file-name ; .../emacs/site-lisp
+ (file-name-directory load-file-name)))) ; .../emacs/site-lisp/
(version
(file-name-as-directory
(concat