diff --git a/core/core-packages.el b/core/core-packages.el index 2750d40a5..ec8ae5a11 100644 --- a/core/core-packages.el +++ b/core/core-packages.el @@ -50,10 +50,12 @@ this is nil after Emacs has started something is wrong.") (make-hash-table :test #'equal :size 100 :rehash-threshold 1.0) "A hash table of enabled modules. Set by `doom-initialize-modules'.") -(defvar doom-modules-dirs (list doom-modules-dir) +(defvar doom-modules-dirs + (list doom-modules-dir (expand-file-name "modules/" doom-private-dir)) "A list of module root directories. Order determines priority.") -(defvar doom-psuedo-module-dirs () +(defvar doom-psuedo-module-dirs + (list doom-private-dir) "Additional paths for modules that are outside of `doom-modules-dirs'. `doom//reload-autoloads', `doom//byte-compile' and `doom-initialize-packages' will include the directories in this list.") diff --git a/core/core.el b/core/core.el index 205980913..35a9346ef 100644 --- a/core/core.el +++ b/core/core.el @@ -53,6 +53,14 @@ Use this for files that change often, like cache files.") (defvar doom-packages-dir (concat doom-local-dir "packages/") "Where package.el and quelpa plugins (and their caches) are stored.") +(defvar doom-private-dir + (if (file-directory-p "~/.doom.d") + "~/.doom.d/" + (concat (or (getenv "XDG_CONFIG_HOME") + "~/.config") + "/doom/")) + "TODO") + (defconst EMACS26+ (not (version< emacs-version "26"))) (defconst EMACS27+ (not (version< emacs-version "27"))) @@ -146,6 +154,8 @@ ability to invoke the debugger in debug mode." gc-cons-percentage 0.6 file-name-handler-alist nil)) + (load (expand-file-name "early-init.el" doom-private-dir) t t) + (require 'core-packages (concat doom-core-dir "core-packages")) (doom-initialize noninteractive) (load! core-lib) @@ -156,12 +166,15 @@ ability to invoke the debugger in debug mode." (load! core-projects) ; making Emacs project-aware (load! core-keybinds)) ; centralized keybind system + which-key + (load (expand-file-name "init.el" doom-private-dir) t t) + (defun doom|after-init () "Run `doom-init-hook' and `doom-post-init-hook', start the Emacs server, and display the loading benchmark." (dolist (hook '(doom-init-hook doom-post-init-hook)) (run-hook-wrapped hook #'doom-try-run-hook hook)) (unless noninteractive + (load (expand-file-name "config.el" doom-private-dir) t t) (when (display-graphic-p) (require 'server) (unless (server-running-p) diff --git a/init.example.el b/init.example.el index 68c5ddc15..200b8211a 100644 --- a/init.example.el +++ b/init.example.el @@ -147,10 +147,5 @@ ;; a Spacemacs-inspired keybinding scheme, a custom yasnippet library, ;; and additional ex commands for evil-mode. Use it as a reference for ;; your own modules. - (default +bindings +snippets +evil-commands) - - ;; This allows you to store your private module at - ;; $XDG_CONFIG_HOME/doom/. Without +xdg it uses ~/.doom.d/. If your - ;; config directory doesn't exist, this module does nothing. - (private +xdg)) + (default +bindings +snippets +evil-commands)) diff --git a/modules/config/default/+bindings.el b/modules/config/default/+bindings.el index 47f72fb67..ebd85a5e5 100644 --- a/modules/config/default/+bindings.el +++ b/modules/config/default/+bindings.el @@ -185,9 +185,8 @@ :desc "Recent files" :n "r" #'recentf-open-files :desc "Recent project files" :n "R" #'projectile-recentf :desc "Yank filename" :n "y" #'+default/yank-buffer-filename - (:when (featurep! :config private) - :desc "Find file in private config" :n "p" #'+private/find-in-config - :desc "Browse private config" :n "P" #'+private/browse-config)) + :desc "Find file in private config" :n "p" #'+default/find-in-config + :desc "Browse private config" :n "P" #'+default/browse-config) (:desc "git" :prefix "g" :desc "Magit blame" :n "b" #'magit-blame diff --git a/modules/config/default/autoload/default.el b/modules/config/default/autoload/default.el index 15ba85e03..6526c029e 100644 --- a/modules/config/default/autoload/default.el +++ b/modules/config/default/autoload/default.el @@ -39,6 +39,17 @@ (interactive) (doom-project-browse emacs-snippets-dir)) ;; NOTE No need for a browse-snippets variant, use `yas-visit-snippet-file' +;;;###autoload +(defun +default/find-in-config () + "Open a file somewhere in `doom-private-dir' via a fuzzy filename search." + (interactive) + (doom-project-find-file doom-private-dir)) + +;;;###autoload +(defun +default/browse-config () + "Browse the files in `doom-private-dir'." + (interactive) + (doom-project-browse doom-private-dir)) ;;;###autoload (defun +default/compile (arg) diff --git a/modules/config/private/README.org b/modules/config/private/README.org deleted file mode 100644 index 0a7684d02..000000000 --- a/modules/config/private/README.org +++ /dev/null @@ -1,23 +0,0 @@ -#+TITLE: :config private - -This module enables support for an external private module and nested -submodules, either at =~/.doom.d= (or =$XDG_CONFIG_HOME/doom= with the ~+xdg~ -flag). - -* Table of Contents :TOC: -- [[Module Flags][Module Flags]] -- [[Features][Features]] - - [[Private sub-modules][Private sub-modules]] - -* Module Flags -+ ~+xdg~ Tells this module to respect XDG conventions and look for your private - config in ~$XDG_CONFIG_HOME/doom~ (falls back to =~/.config/doom=). - -* Features -** Private sub-modules -Modules placed in the =modules/= subdirectory of your external config are -symlinked to =~/.emacs.d/modules/private=, and can be activated from ~doom!~: - -#+BEGIN_SRC emacs-lisp -(doom! :private private-module1 private-module2 ...) -#+END_SRC diff --git a/modules/config/private/autoload.el b/modules/config/private/autoload.el deleted file mode 100644 index f85c9d298..000000000 --- a/modules/config/private/autoload.el +++ /dev/null @@ -1,13 +0,0 @@ -;;; config/private/autoload.el -*- lexical-binding: t; -*- - -;;;###autoload -(defun +private/find-in-config () - "Open a file somewhere in `+private-config-path' via a fuzzy filename search." - (interactive) - (doom-project-find-file +private-config-path)) - -;;;###autoload -(defun +private/browse-config () - "Browse the files in `+private-config-path'." - (interactive) - (doom-project-browse +private-config-path)) diff --git a/modules/config/private/config.el b/modules/config/private/config.el deleted file mode 100644 index d90410d87..000000000 --- a/modules/config/private/config.el +++ /dev/null @@ -1,8 +0,0 @@ -;;; config/private/config.el -*- lexical-binding: t; -*- - -(defun +private|load-config () - "Loads your private config.el in `+private-config-path'." - (load (expand-file-name "config.el" +private-config-path) - 'noerror 'nomessage)) - -(add-hook 'after-init-hook #'+private|load-config) diff --git a/modules/config/private/doctor.el b/modules/config/private/doctor.el deleted file mode 100644 index 094b94132..000000000 --- a/modules/config/private/doctor.el +++ /dev/null @@ -1,5 +0,0 @@ -;;; config/private/doctor.el -*- lexical-binding: t; -*- - -(unless (file-directory-p +private-config-path) - (warn! "Couldn't find '%s'" (file-relative-name +private-config-path "~"))) - diff --git a/modules/config/private/init.el b/modules/config/private/init.el deleted file mode 100644 index d6f40753d..000000000 --- a/modules/config/private/init.el +++ /dev/null @@ -1,19 +0,0 @@ -;;; config/private/init.el -*- lexical-binding: t; -*- - -(defvar +private-config-path - (if (featurep! +xdg) - (expand-file-name "doom/" (or (getenv "XDG_CONFIG_HOME") "~/.config")) - "~/.doom.d") - "The directory that serves as the root of your external private config for -Doom Emacs.") - -;; Ensure `doom//reload-autoloads', `doom//byte-compile' and -;; `doom-initialize-packages' will treat `+private-config-path' as the root of -;; this module. -(cl-pushnew +private-config-path doom-psuedo-module-dirs) -(cl-pushnew (expand-file-name "modules/" +private-config-path) - doom-modules-dirs :test #'string=) - -;; -(load (expand-file-name "init.el" +private-config-path) - 'noerror 'nomessage)