dev: merge branch 'master' of github.com:doomemacs

This commit is contained in:
Matt Nish-Lapidus 2024-09-11 10:00:32 -04:00
commit 25a4356ba1
15 changed files with 172 additions and 165 deletions

View file

@ -405,7 +405,16 @@ Defaults to the profile at `doom-profile-default'."
(letf! ((defun module-loader (group name file &optional noerror)
(doom-module-context-with (cons group name)
`(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)
(cl-loop for (cat . mod) in modules
if (doom-module-locate-path cat mod file)

View file

@ -247,7 +247,12 @@ the command instead."
(projectile-mode +1)
;; HACK: See bbatsov/projectile@3c92d28c056c
(remove-hook 'buffer-list-update-hook #'projectile-track-known-projects-find-file-hook)
(add-hook 'doom-switch-buffer-hook #'projectile-track-known-projects-find-file-hook t)))
(add-hook 'doom-switch-buffer-hook #'projectile-track-known-projects-find-file-hook t)
(add-hook! 'dired-after-readin-hook
(defun doom-project-track-known-project-h ()
(when projectile-mode
(setq projectile-project-root-cache (make-hash-table :test 'equal))
(projectile-track-known-projects-find-file-hook))))))
;;

View file

@ -590,8 +590,10 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
(put 'doom-theme 'previous-themes (or last-themes 'none))
;; DEPRECATED Hook into `enable-theme-functions' when we target 29
(doom-run-hooks 'doom-load-theme-hook)
(setf (alist-get 'foreground-color default-frame-alist) (face-foreground 'default nil t)
(alist-get 'background-color default-frame-alist) (face-background 'default nil t)))))))
(when-let* ((fg (face-foreground 'default nil t))
(bg (face-background 'default nil t)))
(setf (alist-get 'foreground-color default-frame-alist) fg
(alist-get 'background-color default-frame-alist) bg)))))))
;;

View file

@ -198,13 +198,15 @@ Activate this advice with:
-q or -Q, for example:
emacs -Q -l init.el -f doom-run-all-startup-hooks-h"
(setq after-init-time (current-time))
(setq after-init-time (current-time)
doom-init-time (current-time))
(let ((inhibit-startup-hooks nil))
(doom-run-hooks 'after-init-hook
'delayed-warnings-hook
'emacs-startup-hook
'tty-setup-hook
'window-setup-hook)))
'window-setup-hook
'doom-after-init-hook)))
;;

View file

@ -49,99 +49,74 @@
(defun doom--sandbox-run (&optional mode)
"TODO"
(doom--sandbox-launch
(unless (eq mode 'doom) '("-Q"))
(let ((forms
(read (format "(progn\n%s\n)"
(buffer-substring-no-properties
(point-min)
(point-max))))))
(if (eq mode 'doom)
forms
`(progn
;; doom variables
(setq init-file-debug t
doom-emacs-dir ,doom-emacs-dir
doom-cache-dir ,(expand-file-name "cache/" doom-sandbox-dir)
doom-data-dir ,(expand-file-name "data/" doom-sandbox-dir))
(defun doom--write-to-etc-dir-a (fn &rest args)
(let ((user-emacs-directory doom-data-dir))
(apply fn args)))
(advice-add #'locate-user-emacs-file :around #'doom--write-to-etc-dir-a)
;; emacs essential variables
(setq before-init-time (current-time)
after-init-time nil
init-file-debug init-file-debug
noninteractive nil
process-environment (get 'process-environment 'initial-value)
exec-path (get 'exec-path 'initial-value)
load-path ',load-path
user-init-file load-file-name)
;; package.el
(setq package--init-file-ensured t
package-user-dir ,package-user-dir
package-archives ',package-archives)
;; (add-hook 'kill-emacs-hook
;; (lambda ()
;; (delete-file user-init-file)
;; (when (file-equal-p user-emacs-directory ,doom-sandbox-dir)
;; (delete-directory user-emacs-directory 'recursive))))
(with-eval-after-load 'undo-tree
;; HACK `undo-tree' sometimes throws errors because
;; `buffer-undo-tree' isn't correctly initialized.
(setq-default buffer-undo-tree (make-undo-tree)))
;; Then launch as much about Emacs as we can
(defun --run-- () ,forms)
,(pcase mode
(`doom
'(--run--))
(`vanilla-doom+ ; Doom core + modules - private config
`(progn
(load-file ,(expand-file-name "doom.el" doom-core-dir))
(setq doom-modules-dirs (list doom-modules-dir))
(let ((doom-init-modules-p t))
(doom-initialize)
(doom-initialize-core-modules))
(setq doom-modules ',doom-modules)
(maphash (lambda (key plist)
(doom-module-put
(car key) (cdr key)
:path (doom-module-locate-path (car key) (cdr key))))
doom-modules)
(--run--)
(doom-run-hooks 'doom-before-modules-init-hook)
(maphash (doom-module-loader doom-module-init-file) doom-modules)
(doom-run-hooks 'doom-after-modules-init-hook)
(doom-run-hooks 'doom-before-modules-config-hook)
(maphash (doom-module-loader doom-module-config-file) doom-modules)
(doom-run-hooks 'doom-after-modules-config-hook)))
(`vanilla-doom ; only Doom core
`(progn
(load-file ,(expand-file-name "doom.el" doom-core-dir))
(let ((doom-init-modules-p t))
(doom-initialize)
(doom-initialize-core-modules))
(--run--)))
(`vanilla ; nothing loaded
`(progn
(if (boundp 'comp-deferred-compilation)
;; REVIEW Remove me after a month
(setq comp-deferred-compilation nil
comp-deferred-compilation-deny-list ',(bound-and-true-p native-comp-async-env-modifier-form)
comp-async-env-modifier-form ',(bound-and-true-p native-comp-async-env-modifier-form)
comp-eln-load-path ',(bound-and-true-p native-comp-eln-load-path))
(letenv! (("DOOMDIR" (if (eq mode 'vanilla-doom+)
(expand-file-name "___does_not_exist___" temporary-file-directory)
doom-user-dir)))
(doom--sandbox-launch
(unless (memq mode '(doom vanilla-doom+)) '("-Q"))
(let ((forms
(read (format "(progn\n%s\n)"
(buffer-substring-no-properties
(point-min)
(point-max))))))
(if (memq mode '(doom vanilla-doom+))
forms
`(progn
;; doom variables
(setq init-file-debug t
doom-log-level 2
doom-emacs-dir ,doom-emacs-dir
doom-cache-dir ,(expand-file-name "cache/" doom-sandbox-dir)
doom-data-dir ,(expand-file-name "data/" doom-sandbox-dir))
(define-advice locate-user-emacs-file (:around (fn &rest args) restrict-to-data-dir)
(let ((user-emacs-directory doom-data-dir))
(apply fn args)))
;; emacs essential variables
(setq before-init-time (current-time)
after-init-time nil
init-file-debug init-file-debug
noninteractive nil
process-environment (get 'process-environment 'initial-value)
exec-path (get 'exec-path 'initial-value)
load-path ',load-path
user-init-file load-file-name)
;; package.el
(setq package--init-file-ensured t
package-user-dir ,package-user-dir
package-archives ',package-archives)
(with-eval-after-load 'doom
(run-hooks 'doom-before-init-hook))
(with-eval-after-load 'undo-tree
;; HACK `undo-tree' sometimes throws errors because
;; `buffer-undo-tree' isn't correctly initialized.
(setq-default buffer-undo-tree (make-undo-tree)))
;; Then launch as much about Emacs as we can
(defun --run-- () ,forms)
,(pcase mode
(`vanilla-doom ; only Doom core
`(let ((doom-user-dir "/tmp/does/not/exist"))
(require 'doom ,(expand-file-name "doom.el" doom-core-dir))
(let ((doom-module-init-file "__does-not-exist__"))
(require 'doom-start))
(setq doom-modules (make-hash-table :test 'equal))
(--run--)))
(`vanilla ; nothing loaded
`(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--))))
;; 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))))))
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-doom (cmd! (doom--sandbox-run 'vanilla-doom)))