diff options
author | 2013-06-13 23:21:45 +0200 | |
---|---|---|
committer | 2013-06-13 23:21:45 +0200 | |
commit | e616e0a2d7137dc91798982e72c0597af683f794 (patch) | |
tree | 80cb026900021469816efc830d11c24bfea14196 /emacs/site-lisp | |
parent | a134eef9883c436fa18ffcb8782cfebee732f88f (diff) | |
download | dotfiles-e616e0a2d7137dc91798982e72c0597af683f794.tar.gz dotfiles-e616e0a2d7137dc91798982e72c0597af683f794.zip |
Add some extra commands
This allows me to publish articles more easily.
Diffstat (limited to 'emacs/site-lisp')
-rw-r--r-- | emacs/site-lisp/eltuki.el | 32 |
1 files changed, 32 insertions, 0 deletions
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 |