[core] Add pre-dump for layers and function spacemacs/dump-modes
This commit is contained in:
parent
cfd2b110f2
commit
f51fc8e13b
|
@ -13,6 +13,7 @@
|
||||||
- [[#install-emacs][Install Emacs]]
|
- [[#install-emacs][Install Emacs]]
|
||||||
- [[#windows-1][Windows]]
|
- [[#windows-1][Windows]]
|
||||||
- [[#update-your-dotfile][Update your dotfile]]
|
- [[#update-your-dotfile][Update your dotfile]]
|
||||||
|
- [[#add-pre-dump-function-to-layers][Add pre-dump function to layers]]
|
||||||
- [[#test][Test]]
|
- [[#test][Test]]
|
||||||
- [[#report-issues][Report issues]]
|
- [[#report-issues][Report issues]]
|
||||||
- [[#usage][Usage]]
|
- [[#usage][Usage]]
|
||||||
|
@ -201,13 +202,37 @@ Add this to your dotfile if you don't have it already.
|
||||||
)
|
)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
This is a good place to use the function =spacemacs/dump-modes= which
|
||||||
|
all to easily load modes in a temporary buffer to trigger all the possible
|
||||||
|
side effects.
|
||||||
|
|
||||||
|
For instance to load my-mode:
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(spacemacs/dump-modes '(my-mode))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
*Friendly suggestions:*
|
*Friendly suggestions:*
|
||||||
- If you have a lot of personal configuration in =user-init= and =user-config=,
|
- If you have a lot of personal configuration in =user-init= and =user-config=,
|
||||||
you can try to move them into =user-load= as this can reduce the time to load
|
you can try to move them into =user-load= as this can reduce the time to load
|
||||||
those customized configurations.
|
those customized configurations.
|
||||||
- It is better to use =(with-temp-buffer (org-mode))= lines in =user-load=
|
|
||||||
section instead of =(require 'org)=. This will decrease load times by a lot.
|
*** Add pre-dump function to layers
|
||||||
Suggested by [[https://github.com/syl20bnr/spacemacs/issues/10902#issuecomment-398710755][@et2010]].
|
|
||||||
|
It is also possible to execute some lisp for each used layer by defining a
|
||||||
|
function named =<layer>/pre-dump= in the =config.el= file of the layer.
|
||||||
|
|
||||||
|
Example for the org layer:
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
;; Dumper
|
||||||
|
|
||||||
|
(defun org/pre-dump ()
|
||||||
|
(spacemacs/dump-modes '(org-mode)))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*Note*: In order to not generate dump files that are too big we try to use this
|
||||||
|
mechanism only when it makes a noticeable difference for all users.
|
||||||
|
|
||||||
*** Test
|
*** Test
|
||||||
Restart Emacs. Each time Emacs starts, Spacemacs will check if the list of your
|
Restart Emacs. Each time Emacs starts, Spacemacs will check if the list of your
|
||||||
|
|
|
@ -666,6 +666,12 @@ To prevent package from being installed or uninstalled set the variable
|
||||||
(configuration-layer//load-layers-files configuration-layer--used-layers
|
(configuration-layer//load-layers-files configuration-layer--used-layers
|
||||||
'("keybindings.el"))
|
'("keybindings.el"))
|
||||||
(when (spacemacs-is-dumping-p)
|
(when (spacemacs-is-dumping-p)
|
||||||
|
;; dump stuff in layers
|
||||||
|
(dolist (layer-name configuration-layer--used-layers)
|
||||||
|
(let ((layer-dump-func (intern (format "%S/pre-dump" layer-name))))
|
||||||
|
(when (fboundp layer-dump-func)
|
||||||
|
(configuration-layer/message "Pre-dumping layer %S..." layer-name)
|
||||||
|
(funcall layer-dump-func))))
|
||||||
(dotspacemacs|call-func dotspacemacs/user-load
|
(dotspacemacs|call-func dotspacemacs/user-load
|
||||||
"Calling dotfile user-load...")))
|
"Calling dotfile user-load...")))
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,14 @@ You should not used this function, it is reserved for some specific process."
|
||||||
(locate-file (or dotspacemacs-emacs-pdumper-executable-file "emacs")
|
(locate-file (or dotspacemacs-emacs-pdumper-executable-file "emacs")
|
||||||
exec-path exec-suffixes 'file-executable-p))))
|
exec-path exec-suffixes 'file-executable-p))))
|
||||||
|
|
||||||
|
(defun spacemacs/dump-modes (modes)
|
||||||
|
"Load given MODES in order to be dumped."
|
||||||
|
(dolist (mode modes)
|
||||||
|
(with-temp-buffer
|
||||||
|
(when (fboundp mode)
|
||||||
|
(message "Loading mode %S..." mode)
|
||||||
|
(funcall-interactively mode)))))
|
||||||
|
|
||||||
(defun spacemacs/dump-emacs ()
|
(defun spacemacs/dump-emacs ()
|
||||||
"Dump emacs in a subprocess."
|
"Dump emacs in a subprocess."
|
||||||
(when spacemacs-dump-process
|
(when spacemacs-dump-process
|
||||||
|
|
Loading…
Reference in a new issue