From e8c96c803854635736bbbceeb964e2a008e431f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Balay=C3=A9?= <pierre.balaye@univ-lille.fr> Date: Sun, 17 May 2020 13:16:58 +0200 Subject: [PATCH] Auto spacemacs configuration with configs dir contents --- 00-run-installers.sh | 2 +- 04-multiple-spacemacs-configs.sh | 16 +++++++++++++++- dot.emacs-profiles.el | 18 ++++++++++-------- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/00-run-installers.sh b/00-run-installers.sh index d376cda..fb9b735 100755 --- a/00-run-installers.sh +++ b/00-run-installers.sh @@ -9,7 +9,7 @@ mefs_indent_message () { export mefs_THISREPODIR=`pwd` export mefs_CHEMACSDIR="$mefs_EMACSDIR/chemacs" export mefs_FLAVORDIR="$mefs_EMACSDIR/flavors" -export mefs_CONFIGDIR="$mefs_FLAVORDIR/configs" +export mefs_CONFIGDIR="$mefs_EMACSDIR/configs" export -f mefs_indent_message ./01-create-dirs.sh diff --git a/04-multiple-spacemacs-configs.sh b/04-multiple-spacemacs-configs.sh index 69caf15..a8a8f48 100755 --- a/04-multiple-spacemacs-configs.sh +++ b/04-multiple-spacemacs-configs.sh @@ -1,10 +1,24 @@ #!/bin/bash +mefs_indent_message "Multiple spacemacs..." + +mefs_BEG_PATTERN="SPACEMACS MULTIPLE CONFIGURATIONS STARTS HERE" +mefs_END_PATTERN="SPACEMACS MULTIPLE CONFIGURATIONS ENDS HERE" +mefs_TEMPLATE1='("<conf>" . ((user-emacs-directory . "~/emacs/flavors/<conf>")' +mefs_TEMPLATE2='(env . (("SPACEMACSDIR" . "~/emacs/configs/<conf>")))))' + +sed -i "/$mefs_BEG_PATTERN/,/$mefs_END/{/;;/!d}" dot.emacs-profiles.el + mefs_CONFIGS=$(ls $mefs_CONFIGDIR | grep spacemacs) for conf in $mefs_CONFIGS do - mefs_indent_message "Creating dir for $conf" + mefs_indent_message "Creating dir for $conf..." [ -d ${mefs_FLAVORDIR}/${conf} ] || cp -r $mefs_FLAVORDIR/spacemacs-develop ${mefs_FLAVORDIR}/${conf} + + mefs_indent_message "Adding emacs profile for $conf..." + echo "${mefs_TEMPLATE//<conf>/$conf/}" + sed -i "/$mefs_BEG_PATTERN/a ${mefs_TEMPLATE2//<conf>/$conf/}" dot.emacs-profiles.el + sed -i "/$mefs_BEG_PATTERN/a ${mefs_TEMPLATE1//<conf>/$conf/}" dot.emacs-profiles.el done diff --git a/dot.emacs-profiles.el b/dot.emacs-profiles.el index b9a65da..492b635 100644 --- a/dot.emacs-profiles.el +++ b/dot.emacs-profiles.el @@ -1,11 +1,13 @@ ( ("vanilla" . ((user-emacs-directory . "~/emacs/configs/vanilla"))) - ("default" . ((user-emacs-directory . "~/emacs/configs/spacemacs-default") - (env . (("SPACEMACSDIR" . "~/emacs/flavors/spacemacs-default.d"))))) - ("minimal" . ((user-emacs-directory . "~/emacs/configs/spacemacs-minimal") - (env . (("SPACEMACSDIR" . "~/emacs/flavors/spacemacs-minimal.d"))))) - ("test" . ((user-emacs-directory . "~/emacs/configs/spacemacs-test") - (env . (("SPACEMACSDIR" . "~/emacs/flavors/spacemacs-test.d"))))) - ("doom" . ((user-emacs-directory . "~/emacs/flavors/doom-27") - (env . (("DOOMDIR" . "~/emacs/configs/doom-27.d"))))) + ("doom" . ((user-emacs-directory . "~/emacs/flavors/doom") + (env . (("DOOMDIR" . "~/emacs/configs/doom"))))) + ;; SPACEMACS MULTIPLE CONFIGURATIONS STARTS HERE +("spacemacs-test/" . ((user-emacs-directory . "~/emacs/flavors/spacemacs-test/") +(env . (("SPACEMACSDIR" . "~/emacs/configs/spacemacs-test/"))))) +("spacemacs-minimal/" . ((user-emacs-directory . "~/emacs/flavors/spacemacs-minimal/") +(env . (("SPACEMACSDIR" . "~/emacs/configs/spacemacs-minimal/"))))) +("spacemacs-default/" . ((user-emacs-directory . "~/emacs/flavors/spacemacs-default/") +(env . (("SPACEMACSDIR" . "~/emacs/configs/spacemacs-default/"))))) + ;; SPACEMACS MULTIPLE CONFIGURATIONS ENDS HERE ) -- GitLab