refactor: use doom-module-*-file variables; add two
- Adds doom-module-packages-file and doom-module-metadata-file. - Uses them and the other doom-module-*-file variables where they were previously hardcoded. - Add .el extension to doom-module-{init,config}-file; it is now the consumer's responsibility to strip/change/keep the extension as they see fit.
This commit is contained in:
parent
d33478dc79
commit
6c76b98dbb
12 changed files with 57 additions and 34 deletions
|
@ -180,7 +180,7 @@ If RECOMPILE-P is non-nil, only recompile out-of-date files."
|
||||||
(defun doom-compile--ignore-file-p (path)
|
(defun doom-compile--ignore-file-p (path)
|
||||||
(let ((filename (file-name-nondirectory path)))
|
(let ((filename (file-name-nondirectory path)))
|
||||||
(or (not (equal (file-name-extension path) "el"))
|
(or (not (equal (file-name-extension path) "el"))
|
||||||
(member filename (list "packages.el" "doctor.el"))
|
(member filename (list doom-module-packages-file "doctor.el"))
|
||||||
(string-prefix-p "." filename)
|
(string-prefix-p "." filename)
|
||||||
(string-prefix-p "test-" filename)
|
(string-prefix-p "test-" filename)
|
||||||
(string-prefix-p "flycheck_" filename)
|
(string-prefix-p "flycheck_" filename)
|
||||||
|
|
|
@ -245,7 +245,7 @@ in."
|
||||||
(let ((doom--current-module key)
|
(let ((doom--current-module key)
|
||||||
(doom--current-flags (plist-get plist :flags))
|
(doom--current-flags (plist-get plist :flags))
|
||||||
(doctor-file (doom-module-expand-path (car key) (cdr key) "doctor.el"))
|
(doctor-file (doom-module-expand-path (car key) (cdr key) "doctor.el"))
|
||||||
(packages-file (doom-module-expand-path (car key) (cdr key) "packages.el")))
|
(packages-file (doom-module-expand-path (car key) (cdr key) doom-module-packages-file)))
|
||||||
(cl-loop with doom-output-indent = 6
|
(cl-loop with doom-output-indent = 6
|
||||||
for name in (let* (doom-packages
|
for name in (let* (doom-packages
|
||||||
doom-disabled-packages)
|
doom-disabled-packages)
|
||||||
|
|
|
@ -63,6 +63,7 @@ Change `$DOOMDIR' with the `--doomdir' option, e.g.
|
||||||
(print-group!
|
(print-group!
|
||||||
(mapc (lambda (file)
|
(mapc (lambda (file)
|
||||||
(cl-destructuring-bind (filename . template) file
|
(cl-destructuring-bind (filename . template) file
|
||||||
|
(setq filenam)
|
||||||
(if (file-exists-p! filename doom-user-dir)
|
(if (file-exists-p! filename doom-user-dir)
|
||||||
(print! (item "Skipping %s (already exists)")
|
(print! (item "Skipping %s (already exists)")
|
||||||
(path filename))
|
(path filename))
|
||||||
|
@ -70,9 +71,16 @@ Change `$DOOMDIR' with the `--doomdir' option, e.g.
|
||||||
(with-temp-file (doom-path doom-user-dir filename)
|
(with-temp-file (doom-path doom-user-dir filename)
|
||||||
(insert-file-contents template))
|
(insert-file-contents template))
|
||||||
(print! (success "Done!")))))
|
(print! (success "Done!")))))
|
||||||
`(("init.el" . ,(doom-path doom-emacs-dir "templates/init.example.el"))
|
(let ((template-dir (doom-path doom-emacs-dir "templates")))
|
||||||
("config.el" . ,(doom-path doom-emacs-dir "templates/config.example.el"))
|
`((,doom-module-init-file
|
||||||
("packages.el" . ,(doom-path doom-emacs-dir "templates/packages.example.el"))))))
|
. ,(file-name-with-extension (doom-path template-dir doom-module-init-file)
|
||||||
|
".example.el"))
|
||||||
|
(,doom-module-config-file
|
||||||
|
. ,(file-name-with-extension (doom-path template-dir doom-module-config-file)
|
||||||
|
".example.el"))
|
||||||
|
(,doom-module-packages-file
|
||||||
|
. ,(file-name-with-extension (doom-path template-dir doom-module-packages-file)
|
||||||
|
".example.el")))))))
|
||||||
|
|
||||||
;; In case no init.el was present the first time it was loaded.
|
;; In case no init.el was present the first time it was loaded.
|
||||||
(doom-load (doom-path doom-user-dir doom-module-init-file) t)
|
(doom-load (doom-path doom-user-dir doom-module-init-file) t)
|
||||||
|
|
|
@ -154,7 +154,7 @@ following shell commands:
|
||||||
|
|
||||||
(defun doom-upgrade--get-straight-recipe ()
|
(defun doom-upgrade--get-straight-recipe ()
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(insert-file-contents (doom-path doom-core-dir "packages.el"))
|
(insert-file-contents (doom-path doom-core-dir doom-module-packages-file))
|
||||||
(when (re-search-forward "(package! straight" nil t)
|
(when (re-search-forward "(package! straight" nil t)
|
||||||
(goto-char (match-beginning 0))
|
(goto-char (match-beginning 0))
|
||||||
(let ((sexp (sexp-at-point)))
|
(let ((sexp (sexp-at-point)))
|
||||||
|
|
|
@ -13,18 +13,33 @@
|
||||||
doom-modules-dir)
|
doom-modules-dir)
|
||||||
"A list of module root directories. Order determines priority.")
|
"A list of module root directories. Order determines priority.")
|
||||||
|
|
||||||
(defvar doom-module-init-file "init"
|
;;; Module file variables
|
||||||
"The basename of init files for modules.
|
(defvar doom-module-init-file "init.el"
|
||||||
|
"The filename for module early initialization config files.
|
||||||
|
|
||||||
Init files are loaded early, just after Doom core, and before modules' config
|
Init files are loaded early, just after Doom core, and before modules' config
|
||||||
files. They are always loaded, even in non-interactive sessions, and before
|
files. They are always loaded, even in non-interactive sessions, and before
|
||||||
`doom-before-modules-init-hook'. Related to `doom-module-config-file'.")
|
`doom-before-modules-init-hook'. Related to `doom-module-config-file'.")
|
||||||
|
|
||||||
(defvar doom-module-config-file "config"
|
(defvar doom-module-config-file "config.el"
|
||||||
"The basename of config files for modules.
|
"The filename for module configuration files.
|
||||||
|
|
||||||
Config files are loaded later, and almost always in interactive sessions. These
|
Config files are loaded later, and almost always in interactive sessions. These
|
||||||
run before `doom-after-modules-config-hook'. Relevant to `doom-module-init-file'.")
|
run before `doom-after-modules-config-hook' and after `doom-module-init-file'.")
|
||||||
|
|
||||||
|
(defvar doom-module-packages-file "packages.el"
|
||||||
|
"The filename for the package configuration file.
|
||||||
|
|
||||||
|
Package files are read whenever Doom's package manager wants a manifest of all
|
||||||
|
desired packages. They are rarely read in interactive sessions (unless the user
|
||||||
|
uses a straight or package.el command directly).")
|
||||||
|
|
||||||
|
(defvar doom-module-metadata-file ".doommodule"
|
||||||
|
"The filename for a module's metadata file.
|
||||||
|
|
||||||
|
NOT IMPLEMENTED YET. This file contains a module's metadata: their version,
|
||||||
|
maintainers, checks, features, submodules, debug information, etc. And are used
|
||||||
|
to locate modules in the user's file tree.")
|
||||||
|
|
||||||
(defconst doom-obsolete-modules
|
(defconst doom-obsolete-modules
|
||||||
'((:feature (version-control (:emacs vc) (:ui vc-gutter))
|
'((:feature (version-control (:emacs vc) (:ui vc-gutter))
|
||||||
|
|
|
@ -455,7 +455,7 @@ also be a list of module keys."
|
||||||
((symbolp module-list) (doom-module-list 'all))
|
((symbolp module-list) (doom-module-list 'all))
|
||||||
(module-list)))
|
(module-list)))
|
||||||
;; TODO: doom-module-context + doom-context
|
;; TODO: doom-module-context + doom-context
|
||||||
(packages-file "packages.el")
|
(packages-file doom-module-packages-file)
|
||||||
doom-disabled-packages
|
doom-disabled-packages
|
||||||
doom-packages)
|
doom-packages)
|
||||||
(when (assq :user module-list)
|
(when (assq :user module-list)
|
||||||
|
|
|
@ -400,12 +400,12 @@ Defaults to the profile at `doom-profile-default'."
|
||||||
(post-config-modules
|
(post-config-modules
|
||||||
(seq-filter (fn! (>= (doom-module-depth (car %) (cdr %)) 100))
|
(seq-filter (fn! (>= (doom-module-depth (car %) (cdr %)) 100))
|
||||||
config-modules-list))
|
config-modules-list))
|
||||||
(init-file (concat doom-module-init-file ".el"))
|
(init-file doom-module-init-file)
|
||||||
(config-file (concat doom-module-config-file ".el")))
|
(config-file doom-module-config-file))
|
||||||
(letf! ((defun module-loader (group name file &optional noerror)
|
(letf! ((defun module-loader (group name file &optional noerror)
|
||||||
`(let ((doom--current-module '(,group . ,name))
|
`(let ((doom--current-module '(,group . ,name))
|
||||||
(doom--current-flags ',(doom-module-get group name :flags)))
|
(doom--current-flags ',(doom-module-get group name :flags)))
|
||||||
(doom-load ,(abbreviate-file-name file))))
|
(doom-load ,(abbreviate-file-name (file-name-sans-extension file)))))
|
||||||
(defun module-list-loader (modules file &optional noerror)
|
(defun module-list-loader (modules file &optional noerror)
|
||||||
(cl-loop for (cat . mod) in modules
|
(cl-loop for (cat . mod) in modules
|
||||||
if (doom-module-locate-path cat mod file)
|
if (doom-module-locate-path cat mod file)
|
||||||
|
|
|
@ -318,7 +318,7 @@ If RETURN-P, return the message as a string instead of displaying it."
|
||||||
|
|
||||||
;;; Load $DOOMDIR/init.el early
|
;;; Load $DOOMDIR/init.el early
|
||||||
;; TODO: Catch errors
|
;; TODO: Catch errors
|
||||||
(doom-load (file-name-concat doom-user-dir doom-module-init-file) t)
|
(load! (string-remove-suffix ".el" doom-module-init-file) doom-user-dir t)
|
||||||
|
|
||||||
;;; Load the rest of $DOOMDIR + modules if noninteractive
|
;;; Load the rest of $DOOMDIR + modules if noninteractive
|
||||||
;; If the user is loading this file from a batch script, let's assume they want
|
;; If the user is loading this file from a batch script, let's assume they want
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
"Open your private init.el file.
|
"Open your private init.el file.
|
||||||
And jumps to your `doom!' block."
|
And jumps to your `doom!' block."
|
||||||
(interactive)
|
(interactive)
|
||||||
(find-file (expand-file-name "init.el" doom-user-dir))
|
(find-file (expand-file-name doom-module-init-file doom-user-dir))
|
||||||
(goto-char
|
(goto-char
|
||||||
(or (save-excursion
|
(or (save-excursion
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
|
@ -45,13 +45,13 @@ And jumps to your `doom!' block."
|
||||||
(defun doom/goto-private-config-file ()
|
(defun doom/goto-private-config-file ()
|
||||||
"Open your private config.el file."
|
"Open your private config.el file."
|
||||||
(interactive)
|
(interactive)
|
||||||
(find-file (expand-file-name "config.el" doom-user-dir)))
|
(find-file (expand-file-name doom-module-config-file doom-user-dir)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/goto-private-packages-file ()
|
(defun doom/goto-private-packages-file ()
|
||||||
"Open your private packages.el file."
|
"Open your private packages.el file."
|
||||||
(interactive)
|
(interactive)
|
||||||
(find-file (expand-file-name "packages.el" doom-user-dir)))
|
(find-file (expand-file-name doom-module-packages-file doom-user-dir)))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -331,7 +331,7 @@ ready to be pasted in a bug report on github."
|
||||||
,@(condition-case e
|
,@(condition-case e
|
||||||
(mapcar
|
(mapcar
|
||||||
#'cdr (doom--collect-forms-in
|
#'cdr (doom--collect-forms-in
|
||||||
(doom-path doom-user-dir "packages.el")
|
(doom-path doom-user-dir doom-module-packages-file)
|
||||||
"package!"))
|
"package!"))
|
||||||
(error (format "<%S>" e))))
|
(error (format "<%S>" e))))
|
||||||
(unpin
|
(unpin
|
||||||
|
@ -339,7 +339,7 @@ ready to be pasted in a bug report on github."
|
||||||
(mapcan #'identity
|
(mapcan #'identity
|
||||||
(mapcar
|
(mapcar
|
||||||
#'cdr (doom--collect-forms-in
|
#'cdr (doom--collect-forms-in
|
||||||
(doom-path doom-user-dir "packages.el")
|
(doom-path doom-user-dir doom-module-packages-file)
|
||||||
"unpin!")))
|
"unpin!")))
|
||||||
(error (list (format "<%S>" e)))))
|
(error (list (format "<%S>" e)))))
|
||||||
(elpa
|
(elpa
|
||||||
|
|
|
@ -162,7 +162,7 @@ each package."
|
||||||
(ignore-errors (intern (cadr module)))
|
(ignore-errors (intern (cadr module)))
|
||||||
current-prefix-arg)))
|
current-prefix-arg)))
|
||||||
(mapc (lambda! ((cat . mod))
|
(mapc (lambda! ((cat . mod))
|
||||||
(if-let (packages-file (doom-module-locate-path cat mod "packages.el"))
|
(if-let (packages-file (doom-module-locate-path cat mod doom-module-packages-file))
|
||||||
(with-current-buffer
|
(with-current-buffer
|
||||||
(or (get-file-buffer packages-file)
|
(or (get-file-buffer packages-file)
|
||||||
(find-file-noselect packages-file))
|
(find-file-noselect packages-file))
|
||||||
|
@ -185,7 +185,7 @@ each package."
|
||||||
(unless modules
|
(unless modules
|
||||||
(user-error "This package isn't installed by any Doom module"))
|
(user-error "This package isn't installed by any Doom module"))
|
||||||
(dolist (module modules)
|
(dolist (module modules)
|
||||||
(when-let (packages-file (doom-module-locate-path (car module) (cdr module)))
|
(when (doom-module-locate-path (car module) (cdr module) doom-module-packages-file)
|
||||||
(doom/bump-module (car module) (cdr module))))))
|
(doom/bump-module (car module) (cdr module))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
"Tangles `+literate-config-file' if it has changed."
|
"Tangles `+literate-config-file' if it has changed."
|
||||||
(or (getenv "__NOTANGLE")
|
(or (getenv "__NOTANGLE")
|
||||||
(and (+literate-tangle +literate-config-file
|
(and (+literate-tangle +literate-config-file
|
||||||
(concat doom-module-config-file ".el")
|
doom-module-config-file
|
||||||
doom-user-dir)
|
doom-user-dir)
|
||||||
(or (not noninteractive)
|
(or (not noninteractive)
|
||||||
(exit! "__NOTANGLE=1 $@")))))
|
(exit! "__NOTANGLE=1 $@")))))
|
||||||
|
@ -80,7 +80,7 @@
|
||||||
(prin1-to-string
|
(prin1-to-string
|
||||||
`(funcall #',(symbol-function #'+literate-tangle)
|
`(funcall #',(symbol-function #'+literate-tangle)
|
||||||
,+literate-config-file
|
,+literate-config-file
|
||||||
,(concat doom-module-config-file ".el")
|
,doom-module-config-file
|
||||||
,doom-user-dir))))
|
,doom-user-dir))))
|
||||||
(add-hook 'kill-emacs-hook #'+literate-tangle-check-finished-h)
|
(add-hook 'kill-emacs-hook #'+literate-tangle-check-finished-h)
|
||||||
(set-process-sentinel +literate-tangle--async-proc #'+literate-tangle--async-sentinel)
|
(set-process-sentinel +literate-tangle--async-proc #'+literate-tangle--async-sentinel)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue