add mirror of china

This commit is contained in:
Rongsong Shen 2018-12-14 14:54:39 +08:00
parent be8f9c68f4
commit 13ba0b8b03

View File

@ -1,36 +1,49 @@
(defun install-emacs-startkit (name location) (require 'cl-lib)
(let ((startkit-info
'((doom-emacs . (setq installation-done-stat-file "/tmp/.emacs.install.ok")
(lambda (dir) (setq startkit-info
(concat "git clone git@github.com:shen390s/doom-emacs.git " '((doom-emacs .
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 .
(lambda (dir) (lambda (dir)
(concat "git clone git@github.com:shen390s/prelude.git " dir))) (list
(spacemacs . (concat "git clone git@github.com:shen390s/doom-emacs.git " dir)
(lambda (dir) (concat "cd " dir)
(concat "git clone https://github.com/syl20bnr/spacemacs.git " dir)))))) "cp init.example.el init.el"
(let ((installer (funcall (cdr (assoc (intern name) startkit-info)) location))) "make install"
(progn (require 'comint) "y")))
(let* ((shell-buffer (make-comint-in-buffer "installer" nil "/bin/sh")) (frontmacs .
(shell-process (get-buffer-process shell-buffer))) (lambda (dir)
(progn (list
(display-buffer shell-buffer) (concat "mkdir -p " dir )
(comint-simple-send shell-process installer) (concat "cd " dir)
(comint-simple-send shell-process "exit\n"))))))) "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 (setq emacs-start-kit
(let ((start-kit (getenv "EMACS_STARTKIT"))) (let ((start-kit (getenv "EMACS_STARTKIT")))
@ -47,21 +60,28 @@
(concat (substitute-in-file-name "~/.config/emacs/") (concat (substitute-in-file-name "~/.config/emacs/")
emacs-config-name "/")))) emacs-config-name "/"))))
(unless (file-exists-p emacs-config-directory)
(make-directory emacs-config-directory t))
(setq user-emacs-directory emacs-config-directory) (setq user-emacs-directory emacs-config-directory)
(setq emacs-init-file (setq emacs-init-file
(expand-file-name "init.el" user-emacs-directory)) (expand-file-name "init.el" user-emacs-directory))
(defun load-emacs-init-idle () (defun load-emacs-init-idle ()
(if (file-exists-p emacs-init-file) (if (file-exists-p installation-done-stat-file)
(load-file emacs-init-file) (when (file-exists-p emacs-init-file)
(load-file emacs-init-file)
(delete-file installation-done-stat-file))
(progn (progn
(run-with-idle-timer 5 nil #'load-emacs-init-idle)))) (run-with-idle-timer 5 nil #'load-emacs-init-idle))))
(if (not (file-exists-p emacs-init-file)) (if (not (file-exists-p emacs-init-file))
(progn (progn
(run-with-idle-timer 5 nil #'load-emacs-init-idle) (if (file-exists-p installation-done-stat-file)
(install-emacs-startkit emacs-start-kit (delete-file installatio-done-stat-file))
emacs-config-directory)) (run-with-idle-timer 5 nil #'load-emacs-init-idle)
(install-emacs-startkit emacs-start-kit
emacs-config-directory))
(load-file emacs-init-file)) (load-file emacs-init-file))