Improve vanilla sandbox
Can now launch four different sessions: 1. Vanilla Emacs 2. Vanilla Doom (only Doom core) 3. Doom core + modules - private config 4. A full Doom session (load everything)
This commit is contained in:
parent
cec93933d0
commit
681d0f1a2a
2 changed files with 75 additions and 28 deletions
|
@ -139,25 +139,38 @@ pasting into a bug report or discord."
|
||||||
|
|
||||||
(defvar doom--sandbox-init-doom-p nil)
|
(defvar doom--sandbox-init-doom-p nil)
|
||||||
|
|
||||||
(defun doom--run-vanilla-sandbox (&optional load-doom-p)
|
(defun doom--run-vanilla-sandbox (&optional mode)
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((contents (buffer-string))
|
(let ((contents (buffer-string))
|
||||||
(file (make-temp-file "doom-sandbox-")))
|
(file (make-temp-file "doom-sandbox-")))
|
||||||
|
(require 'package)
|
||||||
(with-temp-file file
|
(with-temp-file file
|
||||||
(insert
|
(insert
|
||||||
(prin1-to-string
|
(prin1-to-string
|
||||||
`(cond (,load-doom-p
|
(macroexp-progn
|
||||||
(setq doom-private-dir "/tmp/does/not/exist"
|
(append `((setq debug-on-error t
|
||||||
doom-modules ,doom-modules)
|
package--init-file-ensured t
|
||||||
(load ,user-init-file))
|
package-user-dir ,package-user-dir
|
||||||
((setq package--init-file-ensured t
|
package-archives ',package-archives
|
||||||
package-user-dir ,package-user-dir
|
user-emacs-directory ,doom-emacs-dir
|
||||||
package-archives ',package-archives
|
doom-modules ,doom-modules))
|
||||||
user-emacs-directory ,doom-emacs-dir)
|
(pcase mode
|
||||||
(package-initialize))))
|
(`vanilla-doom+ ; Doom core + modules - private config
|
||||||
|
`((setq doom-private-dir "/tmp/does/not/exist")
|
||||||
|
(load-file ,user-init-file)
|
||||||
|
(doom|run-all-startup-hooks)))
|
||||||
|
(`vanilla-doom ; only Doom core
|
||||||
|
`((setq doom-private-dir "/tmp/does/not/exist"
|
||||||
|
doom-init-modules-p t)
|
||||||
|
(load-file ,user-init-file)
|
||||||
|
(doom|run-all-startup-hooks)))
|
||||||
|
(`vanilla ; nothing loaded
|
||||||
|
`((package-initialize)))))))
|
||||||
"\n(unwind-protect (progn\n" contents "\n)\n"
|
"\n(unwind-protect (progn\n" contents "\n)\n"
|
||||||
(format "(delete-file %S))" file)))
|
(format "(delete-file %S))" file)))
|
||||||
(let ((args (list "-Q" "-l" file)))
|
(let ((args (if (eq mode 'doom)
|
||||||
|
(list "-l" file)
|
||||||
|
(list "-Q" "-l" file))))
|
||||||
(require 'restart-emacs)
|
(require 'restart-emacs)
|
||||||
(condition-case e
|
(condition-case e
|
||||||
(cond ((display-graphic-p)
|
(cond ((display-graphic-p)
|
||||||
|
@ -174,30 +187,58 @@ pasting into a bug report or discord."
|
||||||
(delete-file file)
|
(delete-file file)
|
||||||
(signal (car e) (cdr e)))))))
|
(signal (car e) (cdr e)))))))
|
||||||
|
|
||||||
(defun doom--run-vanilla-doom-sandbox ()
|
(fset 'doom--run-vanilla-emacs (lambda! (doom--run-vanilla-sandbox 'vanilla)))
|
||||||
(interactive)
|
(fset 'doom--run-vanilla-doom (lambda! (doom--run-vanilla-sandbox 'vanilla-doom)))
|
||||||
(doom--run-vanilla-sandbox t))
|
(fset 'doom--run-vanilla-doom+ (lambda! (doom--run-vanilla-sandbox 'vanilla-doom+)))
|
||||||
|
(fset 'doom--run-full-doom (lambda! (doom--run-vanilla-sandbox 'doom)))
|
||||||
|
|
||||||
|
(defvar doom-sandbox-emacs-lisp-mode-map
|
||||||
|
(let ((map (make-sparse-keymap)))
|
||||||
|
(define-key map (kbd "C-c C-c") #'doom--run-vanilla-emacs)
|
||||||
|
(define-key map (kbd "C-c C-d") #'doom--run-vanilla-doom)
|
||||||
|
(define-key map (kbd "C-c C-p") #'doom--run-vanilla-doom+)
|
||||||
|
(define-key map (kbd "C-c C-f") #'doom--run-full-doom)
|
||||||
|
(define-key map (kbd "C-c C-k") #'kill-this-buffer)
|
||||||
|
map))
|
||||||
|
|
||||||
|
(define-derived-mode doom-sandbox-emacs-lisp-mode emacs-lisp-mode "Sandbox Elisp"
|
||||||
|
"TODO")
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/open-vanilla-sandbox ()
|
(defun doom/open-vanilla-sandbox ()
|
||||||
"Open an Emacs Lisp buffer destinated to run in a blank Emacs session (and
|
"Open the Emacs Lisp sandbox.
|
||||||
optionally load only Doom and its modules, without your private config).
|
|
||||||
|
|
||||||
This provides a testbed for debugging code without Doom (or your private config)
|
This is a test bed for running Emacs Lisp in an instance of Emacs with varying
|
||||||
standing in the way, and without sacrificing access to installed packages."
|
amounts of Doom loaded, including:
|
||||||
|
|
||||||
|
a) vanilla Emacs (nothing loaded),
|
||||||
|
b) vanilla Doom (only Doom core) and
|
||||||
|
c) Doom + modules - your private config.
|
||||||
|
|
||||||
|
This is done without sacrificing access to installed packages. Use the sandbox
|
||||||
|
to reproduce bugs and determine if Doom is to blame."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let* ((buffer-name "*doom:vanilla-sandbox*")
|
(let* ((buffer-name "*doom:vanilla-sandbox*")
|
||||||
(exists (get-buffer buffer-name))
|
(exists (get-buffer buffer-name))
|
||||||
(buf (get-buffer-create buffer-name)))
|
(buf (get-buffer-create buffer-name)))
|
||||||
(with-current-buffer buf
|
(with-current-buffer buf
|
||||||
(emacs-lisp-mode)
|
(doom-sandbox-emacs-lisp-mode)
|
||||||
(local-set-key (kbd "C-c C-c") #'doom--run-vanilla-sandbox)
|
(setq header-line-format
|
||||||
(local-set-key (kbd "C-c C-d") #'doom--run-vanilla-doom-sandbox)
|
(concat "C-c C-c = vanilla Emacs"
|
||||||
(local-set-key (kbd "C-c C-k") #'kill-this-buffer)
|
" / "
|
||||||
(setq header-line-format "C-c C-c to run the session / C-c C-d to run it with vanilla Doom loaded / C-c C-k to abort it")
|
"C-c C-d = Doom core"
|
||||||
|
" / "
|
||||||
|
"C-c C-p = Doom core + modules - private config"
|
||||||
|
" / "
|
||||||
|
"C-c C-f = Full Doom"
|
||||||
|
" / "
|
||||||
|
"C-c C-k to abort"))
|
||||||
(setq-local default-directory doom-emacs-dir)
|
(setq-local default-directory doom-emacs-dir)
|
||||||
(unless (buffer-live-p exists)
|
(unless (buffer-live-p exists)
|
||||||
(doom-template-insert "VANILLA_SANDBOX"))
|
(doom-template-insert "VANILLA_SANDBOX")
|
||||||
|
(let ((contents (substitute-command-keys (buffer-string))))
|
||||||
|
(erase-buffer)
|
||||||
|
(insert contents "\n")))
|
||||||
(goto-char (point-max)))
|
(goto-char (point-max)))
|
||||||
(pop-to-buffer buf)))
|
(pop-to-buffer buf)))
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
;; Welcome to the vanilla sandbox!
|
;; Welcome to the vanilla sandbox!
|
||||||
;;
|
;;
|
||||||
;; This is a test bed for running Emacs Lisp in either a vanilla Emacs session
|
;; This is a test bed for running Emacs Lisp in an instance of Emacs with varying
|
||||||
;; free of Doom's clutches (C-c C-c), or in a vanilla Doom session free of your
|
;; amounts of Doom loaded:
|
||||||
;; private config (C-c C-d).
|
;;
|
||||||
|
;; a) vanilla Emacs (nothing loaded) \\[doom--run-vanilla-emacs]
|
||||||
|
;; b) vanilla Doom (only Doom core) \\[doom--run-vanilla-doom]
|
||||||
|
;; c) Doom + modules - your private config \\[doom--run-vanilla-doom+]
|
||||||
|
;; d) Doom (normal) \\[doom--run-full-doom]
|
||||||
|
;;
|
||||||
|
;; This is done without sacrificing access to installed packages. Use the sandbox
|
||||||
|
;; to reproduce bugs and determine if Doom is to blame.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue