From e616e0a2d7137dc91798982e72c0597af683f794 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Thu, 13 Jun 2013 23:21:45 +0200 Subject: Add some extra commands This allows me to publish articles more easily. --- emacs/site-lisp/eltuki.el | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'emacs/site-lisp/eltuki.el') diff --git a/emacs/site-lisp/eltuki.el b/emacs/site-lisp/eltuki.el index c64d20a..b64f786 100644 --- a/emacs/site-lisp/eltuki.el +++ b/emacs/site-lisp/eltuki.el @@ -230,5 +230,37 @@ (eltuki-commit) (kill-buffer buffer))) +(defun eltuki-process-sentinel (proc status) + "Print PROC's STATUS." + (message "git %s" (substring status 0 -1))) + +(defun eltuki--passwd-prompt (string) + "Decide on what to prompt based on STRING." + (cond + ((or + (string-match "^Enter passphrase for key '\\\(.*\\\)': $" string) + (string-match "^\\\(.*\\\)'s password:" string)) + (format "Password for '%s': " (match-string 1 string))) + ((string-match "^[pP]assword:" string) + "Password:"))) + +(defun eltuki-process-filter (proc string) + "Check if PROC is asking for a password in STRING." + (with-current-buffer (process-buffer proc) + (let ((inhibit-read-only t) + (ask (eltuki--passwd-prompt string))) + (if ask + (process-send-string proc (concat (read-passwd ask nil) "\n")) + (insert string))))) + +(defun eltuki-publish () + "Publish posts." + (interactive) + (let* ((default-directory (concat eltuki-blog-dir "/")) + (proc (start-process "eltuki-publish" "*eltuki-publish*" + "git" "push"))) + (set-process-sentinel proc 'eltuki-process-sentinel) + (set-process-filter proc 'eltuki-process-filter))) + (provide 'eltuki) ;;; eltuki.el ends here -- cgit v1.2.3-54-g00ecf