Subject: bug#65346: 30.0.50; *lisp/net/eww.el: new function 'eww-open-in-new-buffer-background'

From: Eli Zaretskii <[email-masked]>
Date: Fri, 18 Aug 2023 08:52:32 +0300

> From: Lin Sun <[email-masked]>
> Date: Thu, 17 Aug 2023 22:51:04 +0000
> Cc: [email-masked]
> 
> Thank you for the comment, and agree with you, so I rewrote the
> function `eww-open-in-new-buffer' with "C-u" support (also with an
> optional argument "url"), then there is no "background" description.
> 
> I also tested the new patch with tab-bar-mode on and off, it works for
> both scenarios.
> 
> Please help review again. Thanks.

Thanks.  However, the way you implemented my suggestion is not what I
had in mind.

> -(defun eww-open-in-new-buffer ()
> -  "Fetch link at point in a new EWW buffer."
> -  (interactive)
> -  (let ((url (eww-suggested-uris)))
> -    (if (null url) (user-error "No link at point")
> -      (when (or (eq eww-browse-url-new-window-is-tab t)
> -                (and (eq eww-browse-url-new-window-is-tab 'tab-bar)
> -                     tab-bar-mode))
> -        (let ((tab-bar-new-tab-choice t))
> -          (tab-new)))
> -      ;; clone useful to keep history, but
> -      ;; should not clone from non-eww buffer
> -      (with-current-buffer
> -          (if (eq major-mode 'eww-mode) (clone-buffer)
> -            (generate-new-buffer "*eww*"))
> -        (unless (equal url (eww-current-url))
> -          (eww-mode)
> -          (eww (if (consp url) (car url) url)))))))
> +(defun eww--open-url-in-new-buffer (url)
> +  "Open the URL in a new EWW buffer."
> +  ;; clone useful to keep history, but
> +  ;; should not clone from non-eww buffer
> +  (with-current-buffer
> +      (if (eq major-mode 'eww-mode) (clone-buffer)
> +        (generate-new-buffer "*eww*"))
> +    (unless (equal url (eww-current-url))
> +      (eww-mode)
> +      (eww (if (consp url) (car url) url)))))
> +
> +(defun eww-open-in-new-buffer (stay &optional url)
> +  "Fetch URL in a new EWW buffer.

This changes the API of a public function in incompatible ways, which
we try very hard not to do.  Instead, the signature or
eww-open-in-new-buffer should be like this:

  (defun eww-open-in-new-buffer (&optional no-select)

and the new NO-SELECT argument should be set non-nil by C-u.

> +    (user-error "No avaliable link")))

This also changes the text of the error message in this case.  Was
that really necessary?  The original text was more accurate, I think.

Also, this new feature needs a NEWS entry and a suitable addition to
the EWW manual.

Thanks.