[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 644d0ba: Add support for url-retrieve-synchronously to eww-retrie
From: |
Juri Linkov |
Subject: |
master 644d0ba: Add support for url-retrieve-synchronously to eww-retrieve-command (bug#50680) |
Date: |
Mon, 20 Sep 2021 03:16:24 -0400 (EDT) |
branch: master
commit 644d0ba589b94b1a23702cf8bad86b70204196f8
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>
Add support for url-retrieve-synchronously to eww-retrieve-command
(bug#50680)
* doc/misc/eww.texi (Advanced): Mention url-retrieve-synchronously
for eww-retrieve-command.
* lisp/net/eww.el (eww-retrieve-command): Add choice 'sync' for
url-retrieve-synchronously.
(eww-retrieve): Use value 'sync' for url-retrieve-synchronously.
(eww-isearch-next-buffer): Let-bind eww-retrieve-command to 'sync'.
---
doc/misc/eww.texi | 3 ++-
etc/NEWS | 3 ++-
lisp/net/eww.el | 38 ++++++++++++++++++++++++--------------
3 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/doc/misc/eww.texi b/doc/misc/eww.texi
index cc546a9..2543dc2 100644
--- a/doc/misc/eww.texi
+++ b/doc/misc/eww.texi
@@ -228,7 +228,8 @@ in an external browser by customizing
@findex eww-retrieve-command
EWW normally uses @code{url-retrieve} to fetch the @acronym{HTML}
-before rendering it. It can sometimes be convenient to use an
+before rendering it, and @code{url-retrieve-synchronously} when
+the value is @code{sync}. It can sometimes be convenient to use an
external program to do this, and @code{eww-retrieve-command} should
then be a list that specifies a command and the parameters. For
instance, to use the Chromium browser, you could say something like
diff --git a/etc/NEWS b/etc/NEWS
index 971b716..726c625 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2302,7 +2302,8 @@ This is a regexp that can be set to alter how links are
followed in eww.
+++
*** New user option 'eww-retrieve-command'.
This can be used to download data via an external command. If nil
-(the default), then 'url-retrieve' is used.
+(the default), then 'url-retrieve' is used. When 'sync', then
+'url-retrieve-synchronously' is used.
+++
*** New Emacs command line convenience command.
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 36c6db0..701dc4f 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -143,11 +143,13 @@ The string will be passed through
`substitute-command-keys'."
(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 @@ killed after rendering."
(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 @@ killed after rendering."
(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 @@ Otherwise, the restored buffer will contain a prompt to
do so by using
(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)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 644d0ba: Add support for url-retrieve-synchronously to eww-retrieve-command (bug#50680),
Juri Linkov <=