dump: add variable dotspacemacs-enable-emacs-pdumper

Controls wether the portable dumper is activated or not
This commit is contained in:
syl20bnr 2018-05-20 04:35:30 -04:00
parent 4407bfa8b3
commit caf5822f40
4 changed files with 86 additions and 71 deletions

View File

@ -58,13 +58,42 @@ In the root directory of your freshly cloned Emacs repository and with the
#+END_SRC
*** Update your dotfile
A new user dotfile function has been added which is called before doing the
dump. The function name is =dotspacemacs/user-load=.
In the function =dotspacemacs/init= add the following variables if you have
not them already and intialize them:
You can copy/paste the following snippet in your dotfile and provide a
value for =dotspacemacs-emacs-pdumper-executable-file= which must point to
the Emacs executable you compiled at the previous step. For me it was:
"~/dev/emacs/src/emacs"
#+BEGIN_SRC emacs-lisp
(defun dotspacemacs/init ()
"Initialization:
This function is called at the very beginning of Spacemacs startup,
before layer configuration.
It should only modify the values of Spacemacs settings."
(setq-default
;; If non-nil then enable support for the portable dumper. You'll need
;; to compile Emacs 27 from source following the instructions in file
;; EXPERIMENTAL.org at to root of the git repository.
;; (default nil)
dotspacemacs-enable-emacs-pdumper t
;; File path pointing to emacs 27.1 executable compiled with support
;; for the portable dumper (this is currently the branch pdumper).
;; (default "emacs")
dotspacemacs-emacs-pdumper-executable-file "/path/to/emacs27"
;; Name of the Spacemacs dump file. This is the file will be created by the
;; portable dumper in the cache directory under dumps sub-directory.
;; To load it when starting Emacs add the parameter `--dump-file'
;; when invoking Emacs 27.1 executable on the command line, for instance:
;; ./emacs --dump-file=~/.emacs.d/.cache/dumps/spacemacs.pdmp
;; (default spacemacs.pdmp)
dotspacemacs-emacs-dumper-dump-file "spacemacs.pdmp"))
#+END_SRC
A new user dotfile function has been added which is called before doing the
dump. The function name is =dotspacemacs/user-load=. You can require additional
libraries before the dump so they won't need to be lazy loaded.
Add this to your dotfile if you don't have it already.
#+BEGIN_SRC emacs-lisp
(defun dotspacemacs/user-load ()
@ -72,35 +101,14 @@ the Emacs executable you compiled at the previous step. For me it was:
This function is called while dumping Spacemacs configuration. You can
`require' or `load' the libraries of your choice that will be included
in the dump."
(setq-default
;; Absolute file path pointing to emacs 27.1 executable compiled with support
;; for the portable dumper (this is currently the branch pdumper)
;; If nil then automatic Emacs dump is disabled.
;; (default nil)
dotspacemacs-emacs-pdumper-executable-file nil
;; Name of the Spacemacs dump file. This is the file will be created by the
;; portable dumper in the cache directory under dumps sub-directory.
;; To load it when starting Emacs add the parameter `--dump-file'
;; when invoking Emacs 27.1 executable on the command line, for instance:
;; ./emacs --dump-file=/Users/sylvain/.emacs.d/.cache/dumps/spacemacs.pdmp
;; (default spacemacs.pdmp)
dotspacemacs-emacs-dumper-dump-file "spacemacs.pdmp"))
)
#+END_SRC
*** Test
Checkout the =moon= branch in `.emacs.d` and launch your Emacs as you usually
do. It can be Emacs 25.1 or later this is not important but obviously you can
also use the compiled Emacs version.
*Note:* the =moon= branch may be force-pushed regularly in order to rebase it
against the =develop= branch.
Each time Emacs starts, Spacemacs will check if the list of your layers has
changed, if it has changed then Emacs will be automatically dumped for you in
an asynchronous process. The buffer for the output of the process is named
=*spacemacs dumper*=.
Restart Emacs. Each time Emacs starts, Spacemacs will check if the list of your
layers has changed, if it has changed then Emacs will be automatically dumped
for you in an asynchronous process. The buffer for the output of the process is
named =*spacemacs dumper*=.
If you have no error during the dump you can test it out!
@ -118,10 +126,10 @@ If you want to report an issue regarding this new feature please use the label
All the related issues can be found with [[https://github.com/syl20bnr/spacemacs/labels/Portable%20Dumper][this link]].
** Usage
Once =dotspacemacs-emacs-pdumper-executable-file= is set to a non-nil and valid
file path to an Emacs 27.1 executable Emacs will be redumped automatically each
time the layer list changes or the =--force-dump= parameter is passed on the
command line.
Once =dotspacemacs-enable-emacs-pdumper= is set to =t= and
=dotspacemacs-emacs-pdumper-executable-file= is set to a valid file path to an
Emacs 27.1 executable, Emacs will be redumped automatically each time the layer
list changes or the =--force-dump= parameter is passed on the command line.
To use the created dump file, open a shell in the =src= directory of the cloned
Emacs source and type:

View File

@ -55,10 +55,14 @@ exists. Otherwise, fallback to ~/.spacemacs"))
`+distributions'. For now available distributions are `spacemacs-base'
or `spacemacs'.")
(defvar dotspacemacs-emacs-pdumper-executable-file nil
"Absolute file path pointing to emacs 27.1 executable compiled with support
for the portable dumper (this is currently the branch pdumper).
If nil then automatic dump of emacs is disabled.")
(defvar dotspacemacs-enable-emacs-pdumper nil
"If non-nil then enable support for the portable dumper. You'll need
to compile Emacs 27 from source following the instructions in file
EXPERIMENTAL.org at to root of the git repository.")
(defvar dotspacemacs-emacs-pdumper-executable-file "emacs"
"File path pointing to emacs 27.1 executable compiled with support for the
portable dumper (this is currently the branch pdumper.")
(defvar dotspacemacs-emacs-dumper-dump-file "spacemacs.pdmp"
"Name of the Spacemacs dump file. This is the file will be created by the

View File

@ -59,7 +59,7 @@ You should not used this function, it is reserved for some specific process."
(defun spacemacs/emacs-with-pdumper-set-p ()
"Return non-nil if a portable dumper capable emacs executable is set."
(and dotspacemacs-emacs-pdumper-executable-file
(and dotspacemacs-enable-emacs-pdumper
(file-exists-p dotspacemacs-emacs-pdumper-executable-file)))
(defun spacemacs/dump-emacs ()
@ -69,21 +69,19 @@ You should not used this function, it is reserved for some specific process."
(delete-process spacemacs-dump-process)
(with-current-buffer spacemacs-dump-buffer-name
(erase-buffer)))
(let ((default-directory (file-name-directory
dotspacemacs-emacs-pdumper-executable-file)))
(make-directory spacemacs-dump-directory t)
(setq spacemacs-dump-process
(make-process
:name "spacemacs-dumper"
:buffer spacemacs-dump-buffer-name
:command
(list dotspacemacs-emacs-pdumper-executable-file
"--batch"
"-l" "~/.emacs.d/dump-init.el"
"-eval" (concat "(dump-emacs-portable \""
(concat spacemacs-dump-directory
dotspacemacs-emacs-dumper-dump-file)
"\")"))))))
(make-directory spacemacs-dump-directory t)
(setq spacemacs-dump-process
(make-process
:name "spacemacs-dumper"
:buffer spacemacs-dump-buffer-name
:command
(list dotspacemacs-emacs-pdumper-executable-file
"--batch"
"-l" "~/.emacs.d/dump-init.el"
"-eval" (concat "(dump-emacs-portable \""
(concat spacemacs-dump-directory
dotspacemacs-emacs-dumper-dump-file)
"\")")))))
;; ;; Brute-force load all .el files in ELPA packages
;; (dolist (d (directory-files package-user-dir t nil 'nosort))

View File

@ -87,6 +87,25 @@ It should only modify the values of Spacemacs settings."
;; This setq-default sexp is an exhaustive list of all the supported
;; spacemacs settings.
(setq-default
;; If non-nil then enable support for the portable dumper. You'll need
;; to compile Emacs 27 from source following the instructions in file
;; EXPERIMENTAL.org at to root of the git repository.
;; (default nil)
dotspacemacs-enable-emacs-pdumper nil
;; File path pointing to emacs 27.1 executable compiled with support
;; for the portable dumper (this is currently the branch pdumper).
;; (default "emacs")
dotspacemacs-emacs-pdumper-executable-file "emacs"
;; Name of the Spacemacs dump file. This is the file will be created by the
;; portable dumper in the cache directory under dumps sub-directory.
;; To load it when starting Emacs add the parameter `--dump-file'
;; when invoking Emacs 27.1 executable on the command line, for instance:
;; ./emacs --dump-file=~/.emacs.d/.cache/dumps/spacemacs.pdmp
;; (default spacemacs.pdmp)
dotspacemacs-emacs-dumper-dump-file "spacemacs.pdmp"
;; If non-nil ELPA repositories are contacted via HTTPS whenever it's
;; possible. Set it to nil if you have no way to use HTTPS in your
;; environment, otherwise it is strongly recommended to let it set to t.
@ -441,21 +460,7 @@ If you are unsure, try setting them in `dotspacemacs/user-config' first."
This function is called while dumping Spacemacs configuration. You can
`require' or `load' the libraries of your choice that will be included
in the dump."
(setq-default
;; Absolute file path pointing to emacs 27.1 executable compiled with support
;; for the portable dumper (this is currently the branch pdumper)
;; If nil then automatic Emacs dump is disabled.
;; (default nil)
dotspacemacs-emacs-pdumper-executable-file nil
;; Name of the Spacemacs dump file. This is the file will be created by the
;; portable dumper in the cache directory under dumps sub-directory.
;; To load it when starting Emacs add the parameter `--dump-file'
;; when invoking Emacs 27.1 executable on the command line, for instance:
;; ./emacs --dump-file=~/.emacs.d/.cache/dumps/spacedump.pdmp
;; (default spacemacs.pdmp)
dotspacemacs-emacs-dumper-dump-file "spacemacs.pdmp"))
)
(defun dotspacemacs/user-config ()
"Configuration for user code: