Add a command to download a file into a buffer

This commit is contained in:
Ivan Malison 2016-09-07 14:10:05 -07:00
parent f7300b3a66
commit ece9e88d5e
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8

View File

@ -325,6 +325,10 @@ but provide support for writing custom elisp.
(imalison:use-package emit
:demand t)
#+END_SRC
*** request
#+BEGIN_SRC emacs-lisp
(use-package request)
#+END_SRC
** Macros
*** Named Build
imalison:named-build provides a way to invoke a macro in such a way
@ -684,6 +688,22 @@ A macro for composing functions together to build an interactive command to copy
(save-excursion
(perform-replace "\\n" "\n" nil nil delimited nil nil beg end nil)))))
#+END_SRC
** Download a File Into a Buffer
#+BEGIN_SRC emacs-lisp
(defun imalison:download-to-buffer (uri)
(interactive (list (read-string "Enter uri: ")))
(request uri
:parser 'buffer-string
:success (cl-function
(lambda (&key data &allow-other-keys)
(message "called")
(let ((created-buffer (get-buffer-create uri)))
(message "here")
(message "buf: %s" created-buffer)
(with-current-buffer created-buffer
(insert data))
(switch-to-buffer created-buffer))))))
#+END_SRC
** Other
#+BEGIN_SRC emacs-lisp
(defun imalison:join-paths (&rest paths)