Add some extra commands

This allows me to publish articles more easily.
This commit is contained in:
Tom Willemse 2013-06-13 23:21:45 +02:00
parent a134eef988
commit e616e0a2d7

View file

@ -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