fix(lib): doom/sandbox: vanilla-doom+ target
Between this and60083a2
, doom/sandbox is now fully functional (this is a stopgap fix until v3.0). Ref:60083a2626
Fix: #5845 Fix: #6505 Fix: #7486
This commit is contained in:
parent
60083a2626
commit
a022e55c08
2 changed files with 78 additions and 85 deletions
|
@ -405,7 +405,16 @@ Defaults to the profile at `doom-profile-default'."
|
||||||
(letf! ((defun module-loader (group name file &optional noerror)
|
(letf! ((defun module-loader (group name file &optional noerror)
|
||||||
(doom-module-context-with (cons group name)
|
(doom-module-context-with (cons group name)
|
||||||
`(let ((doom-module-context ,doom-module-context))
|
`(let ((doom-module-context ,doom-module-context))
|
||||||
(doom-load ,(abbreviate-file-name (file-name-sans-extension file))))))
|
(doom-load
|
||||||
|
,(pcase (cons group name)
|
||||||
|
('(:core . nil)
|
||||||
|
`(file-name-concat
|
||||||
|
doom-core-dir ,(file-name-nondirectory (file-name-sans-extension file))))
|
||||||
|
('(:user . nil)
|
||||||
|
`(file-name-concat
|
||||||
|
doom-user-dir ,(file-name-nondirectory (file-name-sans-extension file))))
|
||||||
|
(_ (abbreviate-file-name (file-name-sans-extension file))))
|
||||||
|
t))))
|
||||||
(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)
|
||||||
|
|
|
@ -49,90 +49,74 @@
|
||||||
|
|
||||||
(defun doom--sandbox-run (&optional mode)
|
(defun doom--sandbox-run (&optional mode)
|
||||||
"TODO"
|
"TODO"
|
||||||
(doom--sandbox-launch
|
(letenv! (("DOOMDIR" (if (eq mode 'vanilla-doom+)
|
||||||
(unless (eq mode 'doom) '("-Q"))
|
(expand-file-name "___does_not_exist___" temporary-file-directory)
|
||||||
(let ((forms
|
doom-user-dir)))
|
||||||
(read (format "(progn\n%s\n)"
|
(doom--sandbox-launch
|
||||||
(buffer-substring-no-properties
|
(unless (memq mode '(doom vanilla-doom+)) '("-Q"))
|
||||||
(point-min)
|
(let ((forms
|
||||||
(point-max))))))
|
(read (format "(progn\n%s\n)"
|
||||||
(if (eq mode 'doom)
|
(buffer-substring-no-properties
|
||||||
forms
|
(point-min)
|
||||||
`(progn
|
(point-max))))))
|
||||||
;; doom variables
|
(if (memq mode '(doom vanilla-doom+))
|
||||||
(setq init-file-debug t
|
forms
|
||||||
doom-emacs-dir ,doom-emacs-dir
|
`(progn
|
||||||
doom-cache-dir ,(expand-file-name "cache/" doom-sandbox-dir)
|
;; doom variables
|
||||||
doom-data-dir ,(expand-file-name "data/" doom-sandbox-dir))
|
(setq init-file-debug t
|
||||||
(define-advice locate-user-emacs-file (:around (fn &rest args) restrict-to-data-dir)
|
doom-log-level 2
|
||||||
(let ((user-emacs-directory doom-data-dir))
|
doom-emacs-dir ,doom-emacs-dir
|
||||||
(apply fn args)))
|
doom-cache-dir ,(expand-file-name "cache/" doom-sandbox-dir)
|
||||||
;; emacs essential variables
|
doom-data-dir ,(expand-file-name "data/" doom-sandbox-dir))
|
||||||
(setq before-init-time (current-time)
|
(define-advice locate-user-emacs-file (:around (fn &rest args) restrict-to-data-dir)
|
||||||
after-init-time nil
|
(let ((user-emacs-directory doom-data-dir))
|
||||||
init-file-debug init-file-debug
|
(apply fn args)))
|
||||||
noninteractive nil
|
;; emacs essential variables
|
||||||
process-environment (get 'process-environment 'initial-value)
|
(setq before-init-time (current-time)
|
||||||
exec-path (get 'exec-path 'initial-value)
|
after-init-time nil
|
||||||
load-path ',load-path
|
init-file-debug init-file-debug
|
||||||
user-init-file load-file-name)
|
noninteractive nil
|
||||||
;; package.el
|
process-environment (get 'process-environment 'initial-value)
|
||||||
(setq package--init-file-ensured t
|
exec-path (get 'exec-path 'initial-value)
|
||||||
package-user-dir ,package-user-dir
|
load-path ',load-path
|
||||||
package-archives ',package-archives)
|
user-init-file load-file-name)
|
||||||
(with-eval-after-load 'doom
|
;; package.el
|
||||||
(run-hooks 'doom-before-init-hook))
|
(setq package--init-file-ensured t
|
||||||
(with-eval-after-load 'undo-tree
|
package-user-dir ,package-user-dir
|
||||||
;; HACK `undo-tree' sometimes throws errors because
|
package-archives ',package-archives)
|
||||||
;; `buffer-undo-tree' isn't correctly initialized.
|
(with-eval-after-load 'doom
|
||||||
(setq-default buffer-undo-tree (make-undo-tree)))
|
(run-hooks 'doom-before-init-hook))
|
||||||
;; Then launch as much about Emacs as we can
|
(with-eval-after-load 'undo-tree
|
||||||
(defun --run-- () ,forms)
|
;; HACK `undo-tree' sometimes throws errors because
|
||||||
,(pcase mode
|
;; `buffer-undo-tree' isn't correctly initialized.
|
||||||
(`vanilla-doom+ ; Doom core + modules - private config
|
(setq-default buffer-undo-tree (make-undo-tree)))
|
||||||
(user-error "Not supported yet!")
|
;; Then launch as much about Emacs as we can
|
||||||
`(progn
|
(defun --run-- () ,forms)
|
||||||
(require 'doom ,(expand-file-name "doom.el" doom-core-dir))
|
,(pcase mode
|
||||||
(let ((doom-module-init-file "__does-not-exist__"))
|
(`vanilla-doom ; only Doom core
|
||||||
(require 'doom-start))
|
`(let ((doom-user-dir "/tmp/does/not/exist"))
|
||||||
(setq doom-module-load-path (list doom-modules-dir))
|
(require 'doom ,(expand-file-name "doom.el" doom-core-dir))
|
||||||
(setq doom-modules ',doom-modules)
|
(let ((doom-module-init-file "__does-not-exist__"))
|
||||||
(maphash (lambda (key plist)
|
(require 'doom-start))
|
||||||
(doom-module-put
|
(setq doom-modules (make-hash-table :test 'equal))
|
||||||
(car key) (cdr key)
|
(--run--)))
|
||||||
:path (doom-module-locate-path (car key) (cdr key))))
|
(`vanilla ; nothing loaded
|
||||||
doom-modules)
|
`(progn
|
||||||
(--run--)
|
(setq native-comp-deferred-compilation nil
|
||||||
(doom-run-hooks 'doom-before-modules-init-hook)
|
native-comp-deferred-compilation-deny-list ',(bound-and-true-p native-comp-async-env-modifier-form)
|
||||||
(maphash (doom-module-loader doom-module-init-file) doom-modules)
|
native-comp-async-env-modifier-form ',(bound-and-true-p native-comp-async-env-modifier-form)
|
||||||
(doom-run-hooks 'doom-after-modules-init-hook)
|
native-comp-eln-load-path ',(bound-and-true-p native-comp-eln-load-path))
|
||||||
(doom-run-hooks 'doom-before-modules-config-hook)
|
(package-initialize t)
|
||||||
(maphash (doom-module-loader doom-module-config-file) doom-modules)
|
(--run--))))
|
||||||
(doom-run-hooks 'doom-after-modules-config-hook)))
|
(with-eval-after-load 'doom
|
||||||
(`vanilla-doom ; only Doom core
|
;; Then rerun Emacs' startup hooks to simulate a fresh Emacs session,
|
||||||
`(let ((doom-user-dir "/tmp/does/not/exist"))
|
;; because they've already fired.
|
||||||
(require 'doom ,(expand-file-name "doom.el" doom-core-dir))
|
(fset 'doom-run-hook #',(symbol-function #'doom-run-hook))
|
||||||
(let ((doom-module-init-file "__does-not-exist__"))
|
(fset 'doom-run-hooks #',(symbol-function #'doom-run-hooks))
|
||||||
(require 'doom-start))
|
(fset 'doom-run-all-startup-hooks-h #',(symbol-function #'doom-run-all-startup-hooks-h))
|
||||||
(setq doom-modules (make-hash-table :test 'equal))
|
;; (doom-run-all-startup-hooks-h)
|
||||||
(--run--)))
|
(unless (default-toplevel-value 'mode-line-format)
|
||||||
(`vanilla ; nothing loaded
|
(setq-default mode-line-format (get 'mode-line-format 'initial-value))))))))))
|
||||||
`(progn
|
|
||||||
(setq native-comp-deferred-compilation nil
|
|
||||||
native-comp-deferred-compilation-deny-list ',(bound-and-true-p native-comp-async-env-modifier-form)
|
|
||||||
native-comp-async-env-modifier-form ',(bound-and-true-p native-comp-async-env-modifier-form)
|
|
||||||
native-comp-eln-load-path ',(bound-and-true-p native-comp-eln-load-path))
|
|
||||||
(package-initialize t)
|
|
||||||
(--run--))))
|
|
||||||
(with-eval-after-load 'doom
|
|
||||||
;; Then rerun Emacs' startup hooks to simulate a fresh Emacs session,
|
|
||||||
;; because they've already fired.
|
|
||||||
(fset 'doom-run-hook #',(symbol-function #'doom-run-hook))
|
|
||||||
(fset 'doom-run-hooks #',(symbol-function #'doom-run-hooks))
|
|
||||||
(fset 'doom-run-all-startup-hooks-h #',(symbol-function #'doom-run-all-startup-hooks-h))
|
|
||||||
;; (doom-run-all-startup-hooks-h)
|
|
||||||
(unless (default-toplevel-value 'mode-line-format)
|
|
||||||
(setq-default mode-line-format (get 'mode-line-format 'initial-value)))))))))
|
|
||||||
|
|
||||||
(fset 'doom--run-vanilla-emacs (cmd! (doom--sandbox-run 'vanilla)))
|
(fset 'doom--run-vanilla-emacs (cmd! (doom--sandbox-run 'vanilla)))
|
||||||
(fset 'doom--run-vanilla-doom (cmd! (doom--sandbox-run 'vanilla-doom)))
|
(fset 'doom--run-vanilla-doom (cmd! (doom--sandbox-run 'vanilla-doom)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue