[dump] Fix several dumper issues
This commit contains the following original ones: [dump] don't assume spacemacs start directory when dumping [dump] dump to a temporary file and atomically rename it [dump] cleanup after dumping
This commit is contained in:
parent
d44522ee1d
commit
9176e93497
|
@ -1,4 +1,4 @@
|
||||||
;;; core-dumper.el --- Spacemacs Core File
|
;;; core-dumper.el --- Spacemacs Core File -*- lexical-binding: t -*-
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
|
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
|
||||||
;;
|
;;
|
||||||
|
@ -106,22 +106,38 @@ the end of the loading of the dump file."
|
||||||
(interactive)
|
(interactive)
|
||||||
(when spacemacs-dump-process
|
(when spacemacs-dump-process
|
||||||
(message "Cancel running dumping process to start a new one.")
|
(message "Cancel running dumping process to start a new one.")
|
||||||
(delete-process spacemacs-dump-process)
|
(delete-process spacemacs-dump-process))
|
||||||
(with-current-buffer spacemacs-dump-buffer-name
|
(when-let ((buf (get-buffer spacemacs-dump-buffer-name)))
|
||||||
|
(with-current-buffer buf
|
||||||
(erase-buffer)))
|
(erase-buffer)))
|
||||||
(make-directory spacemacs-dump-directory t)
|
(make-directory spacemacs-dump-directory t)
|
||||||
(setq spacemacs-dump-process
|
(let* ((dump-file (concat spacemacs-dump-directory dotspacemacs-emacs-dumper-dump-file))
|
||||||
(make-process
|
(dump-file-temp (concat dump-file ".new")))
|
||||||
:name "spacemacs-dumper"
|
(setq spacemacs-dump-process
|
||||||
:buffer spacemacs-dump-buffer-name
|
(make-process
|
||||||
:command
|
:name "spacemacs-dumper"
|
||||||
(list dotspacemacs-emacs-pdumper-executable-file
|
:buffer spacemacs-dump-buffer-name
|
||||||
"--batch"
|
:sentinel
|
||||||
"-l" "~/.emacs.d/dump-init.el"
|
(lambda (proc event)
|
||||||
"-eval" (concat "(dump-emacs-portable \""
|
(when (not (process-live-p proc))
|
||||||
(concat spacemacs-dump-directory
|
(if (and (eq (process-status proc) 'exit)
|
||||||
dotspacemacs-emacs-dumper-dump-file)
|
(= (process-exit-status proc) 0))
|
||||||
"\")")))))
|
(with-current-buffer spacemacs-dump-buffer-name
|
||||||
|
(rename-file dump-file-temp dump-file t)
|
||||||
|
(goto-char (point-max))
|
||||||
|
(insert (format "Done!\n" dump-file-temp dump-file)))
|
||||||
|
(with-current-buffer spacemacs-dump-buffer-name
|
||||||
|
(delete-file dump-file-temp nil)
|
||||||
|
(goto-char (point-max))
|
||||||
|
(insert "Failed\n")))
|
||||||
|
(delete-process spacemacs-dump-process)
|
||||||
|
(setq spacemacs-dump-process nil)))
|
||||||
|
:command
|
||||||
|
(list dotspacemacs-emacs-pdumper-executable-file
|
||||||
|
"--batch"
|
||||||
|
"-l" (concat spacemacs-start-directory "dump-init.el")
|
||||||
|
"-eval" (concat "(dump-emacs-portable \"" dump-file-temp "\")"))))
|
||||||
|
(pop-to-buffer spacemacs-dump-buffer-name)))
|
||||||
|
|
||||||
(defun spacemacs/dump-eval-delayed-functions ()
|
(defun spacemacs/dump-eval-delayed-functions ()
|
||||||
"Evaluate delayed functions."
|
"Evaluate delayed functions."
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
(setq spacemacs-dump-mode 'dumping)
|
(setq spacemacs-dump-mode 'dumping)
|
||||||
;; load init.el
|
;; load init.el
|
||||||
(load (concat (file-name-directory load-file-name) "init.el"))
|
(setq spacemacs-start-directory (file-name-directory load-file-name))
|
||||||
|
(load (concat spacemacs-start-directory "init.el"))
|
||||||
;; prepare the dump
|
;; prepare the dump
|
||||||
(spacemacs/dump-save-load-path)
|
(spacemacs/dump-save-load-path)
|
||||||
;; disable undo-tree to prevent from segfaulting when loading the dump
|
;; disable undo-tree to prevent from segfaulting when loading the dump
|
||||||
|
|
Loading…
Reference in New Issue