diff --git a/init/dot.emacs.el b/init/dot.emacs.el index f5fd78c..c4bb251 100644 --- a/init/dot.emacs.el +++ b/init/dot.emacs.el @@ -1,36 +1,49 @@ -(defun install-emacs-startkit (name location) - (let ((startkit-info - '((doom-emacs . - (lambda (dir) - (concat "git clone git@github.com:shen390s/doom-emacs.git " - dir " && cd " dir " && " - " cp init.example.el init.el && " - " make install "))) - (frontmacs . - (lambda (dir) - (concat "mkdir -p " dir " && cd " dir " && " - "wget https://raw.githubusercontent.com/shen390s/frontmacs/master/scripts/init-frontmacs.el && " - "echo \"(load (expand-file-name \\\"init-frontmacs.el\\\" user-emacs-directory))\" >>init.el"))) - (graphene . - (lambda (dir) - (concat "git clone git@github.com:shen390s/dotfiles-emacs.git " dir))) - (ohai-emacs . - (lambda (dir) - (concat "git clone git@github.com:shen390s/ohai-emacs.git " dir))) - (prelude . +(require 'cl-lib) + +(setq installation-done-stat-file "/tmp/.emacs.install.ok") +(setq startkit-info + '((doom-emacs . (lambda (dir) - (concat "git clone git@github.com:shen390s/prelude.git " dir))) - (spacemacs . - (lambda (dir) - (concat "git clone https://github.com/syl20bnr/spacemacs.git " dir)))))) - (let ((installer (funcall (cdr (assoc (intern name) startkit-info)) location))) - (progn (require 'comint) - (let* ((shell-buffer (make-comint-in-buffer "installer" nil "/bin/sh")) - (shell-process (get-buffer-process shell-buffer))) - (progn - (display-buffer shell-buffer) - (comint-simple-send shell-process installer) - (comint-simple-send shell-process "exit\n"))))))) + (list + (concat "git clone git@github.com:shen390s/doom-emacs.git " dir) + (concat "cd " dir) + "cp init.example.el init.el" + "make install" + "y"))) + (frontmacs . + (lambda (dir) + (list + (concat "mkdir -p " dir ) + (concat "cd " dir) + "wget https://raw.githubusercontent.com/shen390s/frontmacs/master/scripts/init-frontmacs.el" + "echo \"(load (expand-file-name \\\"init-frontmacs.el\\\" user-emacs-directory))\" >>init.el"))) + (graphene . + (lambda (dir) + (list + (concat "git clone git@github.com:shen390s/dotfiles-emacs.git " dir)))) + (ohai-emacs . + (lambda (dir) + (list + (concat "git clone git@github.com:shen390s/ohai-emacs.git " dir)))) + (prelude . + (lambda (dir) + (list + (concat "git clone git@github.com:shen390s/prelude.git " dir)))) + (spacemacs . + (lambda (dir) + (list + (concat "git clone https://github.com/syl20bnr/spacemacs.git " dir)))))) + +(defun install-emacs-startkit (name location) + (progn (require 'comint) + (let* ((shell-buffer (make-comint-in-buffer "installer" nil "/bin/sh")) + (shell-process (get-buffer-process shell-buffer))) + (progn + (display-buffer shell-buffer) + (cl-loop for cmd in (funcall (cdr (assoc (intern name) startkit-info)) location) + do (comint-simple-send shell-process (concat cmd "\n"))) + (comint-simple-send shell-process (concat "touch " installation-done-stat-file "\n")) + (comint-simple-send shell-process "exit\n"))))) (setq emacs-start-kit (let ((start-kit (getenv "EMACS_STARTKIT"))) @@ -47,21 +60,28 @@ (concat (substitute-in-file-name "~/.config/emacs/") emacs-config-name "/")))) +(unless (file-exists-p emacs-config-directory) + (make-directory emacs-config-directory t)) + (setq user-emacs-directory emacs-config-directory) (setq emacs-init-file (expand-file-name "init.el" user-emacs-directory)) (defun load-emacs-init-idle () - (if (file-exists-p emacs-init-file) - (load-file emacs-init-file) + (if (file-exists-p installation-done-stat-file) + (when (file-exists-p emacs-init-file) + (load-file emacs-init-file) + (delete-file installation-done-stat-file)) (progn (run-with-idle-timer 5 nil #'load-emacs-init-idle)))) (if (not (file-exists-p emacs-init-file)) - (progn - (run-with-idle-timer 5 nil #'load-emacs-init-idle) - (install-emacs-startkit emacs-start-kit - emacs-config-directory)) + (progn + (if (file-exists-p installation-done-stat-file) + (delete-file installatio-done-stat-file)) + (run-with-idle-timer 5 nil #'load-emacs-init-idle) + (install-emacs-startkit emacs-start-kit + emacs-config-directory)) (load-file emacs-init-file))