GNU bug report logs - #50680
eww-retrieve-synchronously

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Sun, 19 Sep 2021 16:29:01 UTC

Severity: wishlist

Tags: fixed, patch

Fixed in version 28.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50680 in the body.
You can then email your comments to 50680 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#50680; Package emacs. (Sun, 19 Sep 2021 16:29:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> linkov.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 19 Sep 2021 16:29:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: bug-gnu-emacs <at> gnu.org
Subject: eww-retrieve-synchronously
Date: Sun, 19 Sep 2021 19:12:39 +0300
[Message part 1 (text/plain, inline)]
Tags: patch

This is a spin-off from bug#50497.

>> What do you think about supporting synchronous mode in eww?
>> When adding a variable that causes eww-retrieve to use
>> url-retrieve-synchronously, isearch part could look like this:
>>
>>   (defun eww-isearch-next-buffer (&optional _buffer wrap)
>>     (let ((eww-synchronous t))
>>       (if wrap
>>           (condition-case nil
>>               (eww-top-url)
>>             (error nil))
>>         (if isearch-forward
>>             (eww-next-url)
>>           (eww-previous-url))))
>>     (current-buffer))
>
> Sure, makes sense to me.

Here is a patch that implements this:

[eww-retrieve-synchronously.patch (text/x-diff, inline)]
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index c1202974f4..7ae44fdc71 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -143,11 +143,13 @@ eww-history-limit
 
 (defcustom eww-retrieve-command nil
   "Command to retrieve an URL via an external program.
-If nil, `url-retrieve' is used to download the data.  If non-nil,
-this should be a list where the first item is the program, and
-the rest are the arguments."
+If nil, `url-retrieve' is used to download the data.
+If `sync', `url-retrieve-synchronously' is used.
+For other non-nil values, this should be a list where the first item
+is the program, and the rest are the arguments."
   :version "28.1"
   :type '(choice (const :tag "Use `url-retrieve'" nil)
+                 (const :tag "Use `url-retrieve-synchronously'" sync)
                  (repeat string)))
 
 (defcustom eww-use-external-browser-for-content-type
@@ -366,9 +368,16 @@ eww
                     (list url nil (current-buffer))))))
 
 (defun eww-retrieve (url callback cbargs)
-  (if (null eww-retrieve-command)
-      (url-retrieve url #'eww-render
-                    (list url nil (current-buffer)))
+  (cond
+   ((null eww-retrieve-command)
+    (url-retrieve url #'eww-render
+                  (list url nil (current-buffer))))
+   ((eq eww-retrieve-command 'sync)
+    (let ((orig-buffer (current-buffer))
+          (data-buffer (url-retrieve-synchronously url)))
+      (with-current-buffer data-buffer
+        (eww-render nil url nil orig-buffer))))
+   (t
     (let ((buffer (generate-new-buffer " *eww retrieve*"))
           (error-buffer (generate-new-buffer " *eww error*")))
       (with-current-buffer buffer
@@ -388,7 +397,7 @@ eww-retrieve
                          (with-current-buffer buffer
                            (goto-char (point-min))
                            (insert "Content-type: text/html; charset=utf-8\n\n")
-                           (apply #'funcall callback nil cbargs))))))))))
+                           (apply #'funcall callback nil cbargs)))))))))))
 
 (function-put 'eww 'browse-url-browser-kind 'internal)
 
@@ -2398,13 +2407,14 @@ eww-restore-desktop
 
 (defun eww-isearch-next-buffer (&optional _buffer wrap)
   "Go to the next page to search using `rel' attribute for navigation."
-  (if wrap
-      (condition-case nil
-	  (eww-top-url)
-	(error nil))
-    (if isearch-forward
-	(eww-next-url)
-      (eww-previous-url)))
+  (let ((eww-retrieve-command 'sync))
+    (if wrap
+        (condition-case nil
+	    (eww-top-url)
+	  (error nil))
+      (if isearch-forward
+	  (eww-next-url)
+        (eww-previous-url))))
   (current-buffer))
 
 (provide 'eww)

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50680; Package emacs. (Mon, 20 Sep 2021 05:50:02 GMT) Full text and rfc822 format available.

Message #8 received at 50680 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 50680 <at> debbugs.gnu.org
Subject: Re: bug#50680: eww-retrieve-synchronously
Date: Mon, 20 Sep 2021 07:49:22 +0200
Juri Linkov <juri <at> linkov.net> writes:

> Here is a patch that implements this:

I haven't tried the patch, but skimming it, it makes sense to me, so
please go ahead and push it.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50680; Package emacs. (Mon, 20 Sep 2021 07:18:02 GMT) Full text and rfc822 format available.

Message #11 received at 50680 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 50680 <at> debbugs.gnu.org
Subject: Re: bug#50680: eww-retrieve-synchronously
Date: Mon, 20 Sep 2021 10:16:27 +0300
tags 50680 fixed
close 50680 28.0.50
quit

>> Here is a patch that implements this:
>
> I haven't tried the patch, but skimming it, it makes sense to me, so
> please go ahead and push it.

Now pushed.




Added tag(s) fixed. Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Mon, 20 Sep 2021 07:18:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.0.50, send any further explanations to 50680 <at> debbugs.gnu.org and Juri Linkov <juri <at> linkov.net> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Mon, 20 Sep 2021 07:18:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 18 Oct 2021 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 162 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.