use process sentinel
This commit is contained in:
parent
43b6f0df86
commit
c824d1f198
@ -1,6 +1,35 @@
|
||||
(require 'cl-lib)
|
||||
(require 'comint)
|
||||
|
||||
(defvar emacs-start-kit "The name of emacs startkit we will use")
|
||||
(defvar emacs-config-name "The directory name of emacs startkit")
|
||||
(defvar emacs-config-directory "The based directory of emacs start configuration")
|
||||
(defvar emacs-init-file "The full path of emacs start file")
|
||||
(defvar startkit-info "Information to install emacs startkit")
|
||||
|
||||
(setq emacs-start-kit
|
||||
(let ((start-kit (getenv "EMACS_STARTKIT")))
|
||||
(if start-kit
|
||||
start-kit
|
||||
"spacemacs")))
|
||||
|
||||
(setq emacs-config-name emacs-start-kit)
|
||||
|
||||
(setq emacs-config-directory
|
||||
(let ((config-dir (getenv "EMACS_CONFIG_DIR")))
|
||||
(if config-dir
|
||||
(concat config-dir "/" emacs-config-name "/")
|
||||
(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))
|
||||
|
||||
(setq installation-done-stat-file "/tmp/.emacs.install.ok")
|
||||
(setq startkit-info
|
||||
'((doom-emacs .
|
||||
(lambda (dir)
|
||||
@ -34,54 +63,27 @@
|
||||
(list
|
||||
(concat "git clone https://github.com/syl20bnr/spacemacs.git " dir))))))
|
||||
|
||||
(defun on-installer-finished (process event)
|
||||
"Callback function when uinstaller process has finished."
|
||||
(cond
|
||||
((string= event "finished\n") (load-file emacs-init-file))
|
||||
(t (message "Event %s has been ignored" event))))
|
||||
|
||||
(defun install-emacs-startkit (name location)
|
||||
(progn (require 'comint)
|
||||
(let* ((shell-buffer (make-comint-in-buffer "installer" nil "/bin/sh"))
|
||||
(progn (let* ((shell-buffer (make-comint-in-buffer "installer" nil "/bin/sh"))
|
||||
(shell-process (get-buffer-process shell-buffer)))
|
||||
(progn
|
||||
(set-process-sentinel shell-process 'on-installer-finished)
|
||||
(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")))
|
||||
(if start-kit
|
||||
start-kit
|
||||
"spacemacs")))
|
||||
|
||||
(setq emacs-config-name emacs-start-kit)
|
||||
|
||||
(setq emacs-config-directory
|
||||
(let ((config-dir (getenv "EMACS_CONFIG_DIR")))
|
||||
(if config-dir
|
||||
(concat config-dir "/" emacs-config-name "/")
|
||||
(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 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
|
||||
(if (file-exists-p installation-done-stat-file)
|
||||
(delete-file installation-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))
|
||||
|
||||
|
||||
(provide 'dot.emacs)
|
||||
;;; dot.emacs.el ends here
|
||||
|
||||
Loading…
Reference in New Issue
Block a user