Skip to content

Commit

Permalink
tweak(core): centralize minemacs-ignore-user-config
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Jun 3, 2023
1 parent 2bcfb17 commit fd4a585
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
13 changes: 13 additions & 0 deletions core/me-vars.el
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@
"MinEmacs utility functions."
:group 'minemacs)

(defconst minemacs-ignore-user-config
(append
(if (getenv "MINEMACS_IGNORE_USER_CONFIG")
'(config modules early-config init-tweaks)
(when (getenv "MINEMACS_IGNORE_CONFIG_EL") '(config))
(when (getenv "MINEMACS_IGNORE_MODULES_EL") '(modules))
(when (getenv "MINEMACS_IGNORE_CONFIG_EL") '(early-config))
(when (getenv "MINEMACS_IGNORE_INIT_TWEAKS_EL") '(init-tweaks))))
"Ignore loading these user configuration files.
Accepted values are: `config', `modules', `early-config' and `init-tweaks'.
This list is automatically constructed from the environment variables
\"$MINEMACS_IGNORE_*\".")

(defconst minemacs-config-dir
(file-name-as-directory
(or (getenv "MINEMACS_DIR")
Expand Down
2 changes: 1 addition & 1 deletion early-init.el
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

;; Load the user early configuration file from "$MINEMACSDIR/early-config.el"
;; if it exists.
(unless (or (getenv "MINEMACS_IGNORE_USER_CONFIG") (getenv "MINEMACS_EARLY_CONFIG_EL"))
(unless (memq 'early-config minemacs-ignore-user-config)
(let ((early-config-path (concat minemacs-config-dir "early-config.el")))
(when (file-exists-p early-config-path)
(load early-config-path nil (not minemacs-verbose)))))
Expand Down
6 changes: 3 additions & 3 deletions init.el
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
(+load minemacs-loaddefs-file)

;; Load user init tweaks from "$MINEMACSDIR/init-tweaks.el" when available
(unless (or (getenv "MINEMACS_IGNORE_USER_CONFIG") (getenv "MINEMACS_IGNORE_INIT_TWEAKS_EL"))
(unless (memq 'init-tweaks minemacs-ignore-user-config)
(let ((user-init-tweaks (concat minemacs-config-dir "init-tweaks.el")))
(when (file-exists-p user-init-tweaks)
(+load user-init-tweaks))))
Expand Down Expand Up @@ -199,7 +199,7 @@
;; Load the default list of enabled modules (`minemacs-modules' and `minemacs-core-modules')
(+load minemacs-core-dir "me-modules.el")

(unless (or (getenv "MINEMACS_IGNORE_USER_CONFIG") (getenv "MINEMACS_IGNORE_MODULES_EL"))
(unless (memq 'modules minemacs-ignore-user-config)
;; The modules.el file can override minemacs-modules and minemacs-core-modules
(let ((user-conf-modules (concat minemacs-config-dir "modules.el")))
(when (file-exists-p user-conf-modules)
Expand Down Expand Up @@ -247,7 +247,7 @@
(+load custom-file))

;; Load user configuration from "$MINEMACSDIR/config.el" when available
(unless (or (getenv "MINEMACS_IGNORE_USER_CONFIG") (getenv "MINEMACS_IGNORE_CONFIG_EL"))
(unless (memq 'config minemacs-ignore-user-config)
(let ((user-config (concat minemacs-config-dir "config.el")))
(when (file-exists-p user-config)
(+load user-config))))
Expand Down

0 comments on commit fd4a585

Please sign in to comment.