emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/eev 5b27f53 09/10: Added `find-urlretrieve'.


From: Stefan Monnier
Subject: [elpa] externals/eev 5b27f53 09/10: Added `find-urlretrieve'.
Date: Tue, 25 Jun 2019 00:05:10 -0400 (EDT)

branch: externals/eev
commit 5b27f53c2c39c542d700769ba8cf438b2c987d9b
Author: Eduardo Ochs <address@hidden>
Commit: Eduardo Ochs <address@hidden>

    Added `find-urlretrieve'.
---
 ChangeLog     |  3 +++
 VERSION       |  4 ++--
 eev-plinks.el | 43 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6d03de4..1e47737 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2019-06-24  Eduardo Ochs  <address@hidden>
 
+       * eev-plinks.el (find-urlretrieve00, ee-urlretrieve-3)
+       (find-urlretrieve0, find-urlretrieve): new functions.
+
        * eev-elinks.el (find-here-links-3): ask if the user wants to
        overwrite `ee-window-configuration-before-M-h-M-3'.
 
diff --git a/VERSION b/VERSION
index 8587a80..187a3e5 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-Mon Jun 24 21:04:12 GMT 2019
-Mon Jun 24 18:04:12 -03 2019
+Tue Jun 25 00:31:30 GMT 2019
+Mon Jun 24 21:31:30 -03 2019
diff --git a/eev-plinks.el b/eev-plinks.el
index c473085..5fdd10d 100644
--- a/eev-plinks.el
+++ b/eev-plinks.el
@@ -111,6 +111,7 @@
 ;; (find-eev "eev-brxxx.el")
 
 
+;; «.find-urlretrieve» (to "find-urlretrieve")
 ;; «.find-wget»                (to "find-wget")
 ;; «.find-gitk»                (to "find-gitk")
 ;; «.find-tkdiff»      (to "find-tkdiff")
@@ -247,6 +248,48 @@
 
 
 
+;;;             _                _        _                
+;;;  _   _ _ __| |      _ __ ___| |_ _ __(_) _____   _____ 
+;;; | | | | '__| |_____| '__/ _ \ __| '__| |/ _ \ \ / / _ \
+;;; | |_| | |  | |_____| | |  __/ |_| |  | |  __/\ V /  __/
+;;;  \__,_|_|  |_|     |_|  \___|\__|_|  |_|\___| \_/ \___|
+;;;                                                        
+;; «find-urlretrieve»  (to ".find-urlretrieve")
+;; See: (find-node "(url)Retrieving URLs" "url-retrieve-synchronously")
+;; Tests: http://angg.twu.net/e/emacs.e.html#find-urlretrieve
+;;                    (find-es "emacs"      "find-urlretrieve")
+;;
+(defun find-urlretrieve00 (url &rest pos-spec-list)
+  "Download URL with `url-retrieve-synchronously'. Show the full response."
+  (apply 'find-ebuffer (url-retrieve-synchronously url) pos-spec-list))
+
+(defun ee-urlretrieve-3 (url)
+  "Download URL with `url-retrieve-synchronously'. Return status, headers, 
body."
+  (find-urlretrieve00 url 1 "\n\n")
+  (let* ((header (buffer-substring 1 (- (point) 1)))
+        (body   (buffer-substring (point) (point-max)))
+        (status (replace-regexp-in-string "\n.*" "" header)))
+    (ee-kill-this-buffer)
+    (list status header body)))
+
+(defun find-urlretrieve0 (url)
+  "Download URL with `url-retrieve-synchronously'. Return body as a raw 
string."
+  (let* ((shb (ee-urlretrieve-3 url))
+        (status (nth 0 shb))
+        (body   (nth 2 shb)))
+    (if (equal status "HTTP/1.1 200 OK")
+       body
+      (error "%s -> %s" url status))))
+
+(defun find-urlretrieve (url &rest pos-spec-list)
+  "Download URL with `url-retrieve-synchronously'.
+TODO: detect the encoding!!!"
+  (let ((ee-buffer-name url))
+    (apply 'find-estring (find-urlretrieve0 url) pos-spec-list)))
+
+
+
+
 ;; «find-wget» (to ".find-wget")
 ;;
 (defun find-wget00 (url)



reply via email to

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