Last active
December 15, 2015 22:59
-
-
Save htr/5336800 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define-minor-mode automate-mode | |
"Automate mode" | |
:group 'automate | |
:init-value t | |
:global nil | |
:lighter automate-lighter) | |
(defvar automate-lighter " auto") | |
(defvar automate:ongoing '()) | |
(defun automate:reset-lighter () | |
(setq automate-lighter (format " auto[%s]" (mapconcat 'identity automate:ongoing "|")))) | |
(defun automate:mk-sentinel (identifier) | |
(lambda (process event) | |
(message (process-name process)) | |
(setq automate:ongoing (delq (process-name process) automate:ongoing)) | |
(automate:reset-lighter) | |
(message (format "%s %s" (process-name process) event )))) ;; ) | |
(defun automate:start-cmd (identifier cmd) | |
(let ((buffer-name (concat "cmd-" identifier))) | |
(progn | |
(when (get-buffer buffer-name) | |
(kill-buffer buffer-name)) | |
(setq automate:ongoing (delete-dups (cons identifier automate:ongoing))) | |
(automate:reset-lighter) | |
(start-process-shell-command identifier (generate-new-buffer buffer-name) cmd) | |
(set-process-sentinel | |
(get-process identifier) | |
(automate:mk-sentinel identifier))))) | |
;; (define-minor-mode automate-mode "Automate mode" t "") | |
;; (automate:start-cmd "yada" "scp bigfile remoteserver: && ssh remoteserver ./deploy bigfile ") | |
(provide 'automate-mode) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment