Subject: bug#77857: [PATCH] Let eww-copy-page-url append to existing kill

From: Stefan Kangas <[email-masked]>
Date: Wed, 16 Apr 2025 22:52:12 -0700

James Thomas via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <[email-masked]> writes:

> Tags: patch
> Severity: wishlist
>
> From c1f63607d0107c1ec39489bdcfdeb2c086112fbf Mon Sep 17 00:00:00 2001
> From: James Thomas <[email-masked]>
> Date: Thu, 17 Apr 2025 09:56:27 +0530
> Subject: [PATCH] Let eww-copy-page-url append to existing kill
>
> * lisp/net/eww.el (eww-copy-page-url): Make the change.
> ---
>  lisp/net/eww.el | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/lisp/net/eww.el b/lisp/net/eww.el
> index c3e927b74a6..df16f12875a 100644
> --- a/lisp/net/eww.el
> +++ b/lisp/net/eww.el
> @@ -2159,7 +2159,10 @@ eww-copy-page-url
>    "Copy the URL of the current page into the kill ring."
>    (interactive nil eww-mode)
>    (message "%s" (plist-get eww-data :url))
> -  (kill-new (plist-get eww-data :url)))
> +  (let ((str (plist-get eww-data :url)))
> +    (if (eq last-command 'kill-region)
> +        (kill-append str nil)
> +      (kill-new str))))
>
>  (defun eww-download ()
>    "Download a Web page to `eww-download-directory'.
> --
> 2.46.0
>
>
> The way I use this, it lets me add the link to a description of the page
> (usually text copied from itself) which is now fit for sharing with C-y.
>
> Thoughts?

Makes sense to me, but I think we should make it optional somehow.  It's
not the typical use case, and it changes current behavior.  Perhaps a
new defcustom is in order.

This should also be in NEWS, and possibly in the EWW manual.