Subject: 30.0.50; *lisp/net/eww.el: new function 'eww-open-in-new-buffer-background'
From: Lin Sun <[email-masked]>
To: "[email-masked]" <[email-masked]>
Date: Wed, 16 Aug 2023 19:39:30 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

In a EWW buffer, the user can use the 'eww-open-in-new-buffer' or "M-RET" to
open a URL in a new buffer and focus on the new buffer.

Sometimes people want to open the URLs in the background first and read them
later, so here is the 'eww-open-in-new-buffer-background' function,
binding to "C-<return>".

Example: using the eww to open the hack news and browse the topics,
open some topics in background with "C-<return>", and read them later.

Please help review the patch. Thanks.

Best Regards
Lin
From 23e8580726cffc6883ad7f553414f257c263e2ba Mon Sep 17 00:00:00 2001
From: Lin Sun <[email-masked]>
Date: Wed, 16 Aug 2023 01:00:07 +0000
Subject: [PATCH] *lisp/net/eww.el: new function
 `eww-open-in-new-buffer-backgroud'

---
 lisp/net/eww.el | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index cb73926f46..3e9ad51f10 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -561,6 +561,12 @@ eww-open-in-new-buffer
           (eww-mode)
           (eww (if (consp url) (car url) url)))))))
 
+(defun eww-open-in-new-buffer-background ()
+  "Fetch link at point in a new background EWW buffer."
+  (interactive)
+  (save-window-excursion
+    (call-interactively #'eww-open-in-new-buffer)))
+
 (defun eww-html-p (content-type)
   "Return non-nil if CONTENT-TYPE designates an HTML content type.
 Currently this means either text/html or application/xhtml+xml."
@@ -1073,6 +1079,7 @@ eww-mode-map
   "g" #'eww-reload             ;FIXME: revert-buffer-function instead!
   "G" #'eww
   "M-RET" #'eww-open-in-new-buffer
+  "C-<return>" #'eww-open-in-new-buffer-background
   "TAB" #'shr-next-link
   "C-M-i" #'shr-previous-link
   "<backtab>" #'shr-previous-link
@@ -1112,6 +1119,7 @@ eww-mode-map
           ["Close browser" quit-window t]
           ["Reload" eww-reload t]
           ["Follow URL in new buffer" eww-open-in-new-buffer]
+          ["Follow URL in background" eww-open-in-new-buffer-background]
           ["Back to previous page" eww-back-url
            :active (not (zerop (length eww-history)))]
           ["Forward to next page" eww-forward-url
-- 
2.20.5