💥 Replace config/private w/ first-class support

The config/private module has been removed. ~/.doom.d (or
~/.config/doom; whichever is detected first) is now a first class
citizen of Doom and should just work(tm).

Your init.el only needs to contain:

  (require 'core (concat user-emacs-directory "core/core"))

And you may place your doom! block in ~/.doom.d/init.el (or
~/.config/doom/init.el).
This commit is contained in:
Henrik Lissner 2018-04-03 03:07:26 -04:00
parent b701303909
commit 355b4b1364
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
10 changed files with 31 additions and 79 deletions

View file

@ -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.")

View file

@ -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)

View file

@ -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))

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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))

View file

@ -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)

View file

@ -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 "~")))

View file

@ -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)