Add hypo-get-file
This commit is contained in:
parent
bdbb16b57e
commit
f8d7a0e267
1 changed files with 22 additions and 0 deletions
22
hypo.el
22
hypo.el
|
@ -125,5 +125,27 @@ STATUS is ignored."
|
||||||
(setq hypo--last-post nil)
|
(setq hypo--last-post nil)
|
||||||
(message "Deleted %s" url)))
|
(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)
|
(provide 'hypo)
|
||||||
;;; hypo.el ends here
|
;;; hypo.el ends here
|
||||||
|
|
Loading…
Reference in a new issue