diff options
author | Tom Willemse | 2013-12-28 13:39:29 +0100 |
---|---|---|
committer | Tom Willemse | 2013-12-28 13:39:29 +0100 |
commit | f8d7a0e267d305a841b130d2ba7a7c11e022e172 (patch) | |
tree | 6af3b5fc91479bc3527906a39c0eb3d767e094f2 /hypo.el | |
parent | bdbb16b57e154ac989cc9894c77d223290a6310d (diff) | |
download | hypo-emacs-f8d7a0e267d305a841b130d2ba7a7c11e022e172.tar.gz hypo-emacs-f8d7a0e267d305a841b130d2ba7a7c11e022e172.zip |
Add hypo-get-file
Diffstat (limited to 'hypo.el')
-rw-r--r-- | hypo.el | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -125,5 +125,27 @@ STATUS is ignored." (setq hypo--last-post nil) (message "Deleted %s" url))) +(defun hypo--file-shower (filename) + "Make a function to show file as FILENAME." + (lambda (status) + (ignore status) + (let* ((start (1+ (marker-position url-http-end-of-headers))) + (end (point-max)) + (contents (buffer-substring-no-properties start end)) + (buffer (generate-new-buffer filename))) + (with-current-buffer buffer + (insert contents) + (write-file (concat "/tmp/" filename)) + (goto-char (point-min))) + (kill-buffer) + (set-window-buffer nil buffer)))) + +;;;###autoload +(defun hypo-get-file (hash filename) + "Get the file HASH/FILENAME from your hypo instance." + (interactive "MHash: \nMFile: ") + (let ((url (format "%s/raw/%s/%s" hypo-instance-url hash filename))) + (url-retrieve url (hypo--file-shower filename)))) + (provide 'hypo) ;;; hypo.el ends here |