emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] scratch/with-url bc505fd 1/8: Fix up some :wait issues


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] scratch/with-url bc505fd 1/8: Fix up some :wait issues
Date: Sun, 22 Jan 2017 22:25:22 +0000 (UTC)

branch: scratch/with-url
commit bc505fd29277a3e2fd4b0e2b83b1c0ee16a67791
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Fix up some :wait issues
---
 lisp/url/with-url.el |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lisp/url/with-url.el b/lisp/url/with-url.el
index 1f47b4f..a38f0f3 100644
--- a/lisp/url/with-url.el
+++ b/lisp/url/with-url.el
@@ -155,7 +155,8 @@ When using the posting methods, the data is usually encoded 
in
 some fashion.  Supported encodings are `url-form', `multipart'
 and `base64'."
   (declare (indent 1))
-  (let ((requestv (cl-gensym "request")))
+  (let ((requestv (cl-gensym "request"))
+        (buffer (cl-gensym "buffer")))
     `(let ((,requestv 
             (make-url-request :original-url ,url
                               :timeout ,timeout
@@ -177,15 +178,15 @@ and `base64'."
        ,(if wait
             `(progn
                (with-url--wait ,requestv)
-               (let ((buffer (process-buffer (url-request-process ,requestv))))
-                 (with-current-buffer buffer
+               (let ((,buffer (url-request-buffer ,requestv)))
+                 (with-current-buffer ,buffer
                    (unwind-protect
                        (if (and (url-request-ignore-errors ,requestv)
                                 (url-errorp))
                            (kill-buffer buffer)
                          (goto-char (point-min))
                          ,@body)
-                     (kill-buffer buffer)))))
+                     (kill-buffer ,buffer)))))
           `(progn
              (setf (url-request-callback ,requestv)
                    (lambda ()
@@ -251,6 +252,7 @@ If given, return the value in BUFFER instead."
           (with-url--parse-headers)
           (goto-char (point-min))
           (delete-region (point) (search-forward "\n\n"))
+          (setf (url-request-finished req) t)
           (with-url--possible-callback req))
       ;; If not, fetch it from the web.
       (let* ((coding-system-for-read 'binary)
@@ -741,6 +743,9 @@ If the headers don't allow caching, nothing will be done."
         (narrow-to-region (point) (or (search-forward "\n\n" nil t) (point)))
         (mail-fetch-field "last-modified")))))
 
+(defun with-url-cached-p (url)
+  (file-exists-p (with-url--cache-file-name url)))
+
 (defun with-url-get-cache (url)
   (let ((file (with-url--cache-file-name url)))
     (when (file-exists-p file)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]