From 2edc2cb12fd47304c92fdaeed71ffb401b76b7a7 Mon Sep 17 00:00:00 2001 From: Kristian Nygaard Jensen Date: Sat, 7 Jan 2023 14:38:45 +0100 Subject: [PATCH] Custom personal dir By setting PRELUDE_PERSONAL_DIR personal prelude configuration can be kept outside the main prelude directory. --- CHANGELOG.md | 1 + docs/configuration.md | 3 +++ init.el | 7 ++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1708b5bdf..9f2c3fa590 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * Add a Lua module. * Auto-install `racket-mode` if needed. * Add a F# module. +* Custom personal dir ### Changes diff --git a/docs/configuration.md b/docs/configuration.md index bbc99583f1..b689478fae 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -83,6 +83,9 @@ lexicographical order. The overall loading precedence is: 3. `personal/prelude-modules.el` (or deprecated `prelude-modules.el`) 4. `personal/*` +By setting the environment variable `PRELUDE_PERSONAL_DIR` the +personal directory can be placed outside the main prelude directory. + ### Personalization Example Suppose you want to configure `go-mode` to autoformat on each save. You diff --git a/init.el b/init.el index 955c9f301e..0ee73d543e 100644 --- a/init.el +++ b/init.el @@ -58,7 +58,12 @@ "The home of Prelude's core functionality.") (defvar prelude-modules-dir (expand-file-name "modules" prelude-dir) "This directory houses all of the built-in Prelude modules.") -(defvar prelude-personal-dir (expand-file-name "personal" prelude-dir) +(defvar prelude-personal-dir (or (let ((personal-dir (getenv "PRELUDE_PERSONAL_DIR"))) + (when personal-dir + (let ((personal-dir-exp (expand-file-name personal-dir))) + (when (file-directory-p personal-dir-exp) + personal-dir-exp)))) + (expand-file-name "personal" prelude-dir)) "This directory is for your personal configuration. Users of Emacs Prelude are encouraged to keep their personal configuration