Add function to create a new configuration layer
This commit is contained in:
parent
8cb1230e7e
commit
382a72c9a3
|
@ -60,6 +60,44 @@ sub-directory of the contribution directory.")
|
|||
'("marmalade" . "http://marmalade-repo.org/packages/")))
|
||||
(setq warning-minimum-level :error)))
|
||||
|
||||
(defun config-system/create-layer (name)
|
||||
"Ask the user for a configuration layer name and create a layer with this
|
||||
name in the private layers directory."
|
||||
(interactive "sConfiguration layer name: ")
|
||||
(let ((layer-dir (config-system//get-private-layer-dir name)))
|
||||
(cond
|
||||
((string-equal "" name)
|
||||
(message "Cannot create a configuration layer without a name."))
|
||||
((file-exists-p layer-dir)
|
||||
(message "Cannot create configuration layer \"%s\", this layer already exists."
|
||||
name))
|
||||
(t
|
||||
(make-directory layer-dir)
|
||||
(config-system//copy-template "extensions")
|
||||
(config-system//copy-template "packages")
|
||||
(message "Configuration layer \"%s\" successfully created." name))
|
||||
)))
|
||||
|
||||
(defun config-system//get-private-layer-dir (name)
|
||||
"Return an absolute path the the private configuration layer with name
|
||||
NAME."
|
||||
(concat config-system-private-directory name "/"))
|
||||
|
||||
(defun config-system//copy-template (template)
|
||||
"Copy and replace special values of TEMPLATE to LAYER_DIR."
|
||||
(let ((src (concat spacemacs-template-directory
|
||||
(format "%s.template" template)))
|
||||
(dest (concat (config-system//get-private-layer-dir name)
|
||||
(format "%s.el" template))))
|
||||
|
||||
(copy-file src dest)
|
||||
(find-file dest)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "NAME" nil t)
|
||||
(replace-match name t)))
|
||||
(save-buffer)))
|
||||
|
||||
(defun config-system/declare-layer (sym &optional contrib)
|
||||
"Declare a layer with SYM name (symbol). If CONTRIB is non nil then the layer
|
||||
is a contribution layer."
|
||||
|
|
21
core/templates/extensions.template
Normal file
21
core/templates/extensions.template
Normal file
|
@ -0,0 +1,21 @@
|
|||
(defvar NAME-pre-extensions
|
||||
'(
|
||||
;; pre extension names go here
|
||||
)
|
||||
"List of all extensions to load before the packages.")
|
||||
|
||||
(defvar NAME-post-extensions
|
||||
'(
|
||||
;; post extension names go here
|
||||
)
|
||||
"List of all extensions to load after the packages.")
|
||||
|
||||
;; For each extension, define a function NAME/init-<extension-name>
|
||||
;;
|
||||
;; (defun NAME/init-my-extension ()
|
||||
;; "Initialize my extension"
|
||||
;; )
|
||||
;;
|
||||
;; Often the body of an initialize function uses `use-package'
|
||||
;; For more info on `use-package', see readme:
|
||||
;; https://github.com/jwiegley/use-package
|
19
core/templates/packages.template
Normal file
19
core/templates/packages.template
Normal file
|
@ -0,0 +1,19 @@
|
|||
(defvar NAME-packages
|
||||
'(
|
||||
;; package names go here
|
||||
)
|
||||
"List of all packages to install and/or initialize. Built-in packages
|
||||
which require an initialization must be listed explicitly in the list.")
|
||||
|
||||
(defvar NAME-excluded-packages '()
|
||||
"List of packages to exclude.")
|
||||
|
||||
;; For each package, define a function NAME/init-<package-name>
|
||||
;;
|
||||
;; (defun NAME/init-my-package ()
|
||||
;; "Initialize my package"
|
||||
;; )
|
||||
;;
|
||||
;; Often the body of an initialize function uses `use-package'
|
||||
;; For more info on `use-package', see readme:
|
||||
;; https://github.com/jwiegley/use-package
|
Loading…
Reference in a new issue