unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#67602: 29.1; [PATCH] Add function eww-copy-point-link-url to eww.
@ 2023-12-03 15:13 Osmo Karppinen
  2023-12-03 17:02 ` Juri Linkov
  2023-12-03 18:02 ` Osmo Karppinen
  0 siblings, 2 replies; 5+ messages in thread
From: Osmo Karppinen @ 2023-12-03 15:13 UTC (permalink / raw)
  To: 67602

[-- Attachment #1: Type: text/plain, Size: 587 bytes --]

Tags: patch

New function eww-copy-point-link-url will copy URL of link pointed by
the pointer to the killring in eww. Patch adds also new key binding for
the function and also menuitem. I think that key "c" is good for this
operation.

Why? Sometimes it is needed to get url from link at the point to your
killring. Data behind the url could be in form what eww or emacs can't
handle well. So it is not quite handy to load page and then copy it's
url to the killring with eww-copy-page-url.

GNU Emacs 30.0.50 Development version fb4b0b30a24e on master branch;
build date 2023-12-03.



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-function-eww-copy-point-link-url-to-eww.patch --]
[-- Type: text/x-diff, Size: 1837 bytes --]

From 10c3a26ace07f2e2d9a2c55839c0ccfa3a1fad32 Mon Sep 17 00:00:00 2001
From: Osmo Karppinen <osmkarp@gmail.com>
Date: Sun, 3 Dec 2023 16:23:36 +0200
Subject: [PATCH] Add function eww-copy-point-link-url to eww.

Function will copy URL of link pointed by the pointer to the killring in
eww. Also new key binding and menu item added for the function. I think
that key "c" is good key for this.
---
 lisp/net/eww.el | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 77bb6be..80b56b1 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -1102,6 +1102,7 @@ eww-mode-map
   "&" #'eww-browse-with-external-browser
   "d" #'eww-download
   "w" #'eww-copy-page-url
+  "c" #'eww-copy-point-link-url
   "A" #'eww-copy-alternate-url
   "C" #'url-cookie-list
   "v" #'eww-view-source
@@ -1136,6 +1137,7 @@ eww-mode-map
           ["Download" eww-download t]
           ["View page source" eww-view-source]
           ["Copy page URL" eww-copy-page-url t]
+          ["Copy link URL pointed" eww-copy-point-link-url t]
           ["List histories" eww-list-histories t]
           ["Switch to buffer" eww-switch-to-buffer t]
           ["List buffers" eww-list-buffers t]
@@ -1984,6 +1986,17 @@ eww-copy-page-url
   (message "%s" (plist-get eww-data :url))
   (kill-new (plist-get eww-data :url)))
 
+(defun eww-copy-point-link-url ()
+  "Copy the URL of the link pointed by the pointer to the killring."
+  (interactive nil eww-mode)
+  (let ((url (get-text-property (point) 'shr-url)))
+    (if url
+        (progn
+          (kill-new url)
+          (message "%s" url))
+      (progn (message "No url at the point.")
+             nil))))
+
 (defun eww-download ()
   "Download URL to `eww-download-directory'.
 Use link at point if there is one, else the current page's URL."
-- 
2.42.0


[-- Attachment #3: Type: text/plain, Size: 30 bytes --]



With thanks,
Osmo Karppinen

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#67602: 29.1; [PATCH] Add function eww-copy-point-link-url to eww.
  2023-12-03 15:13 bug#67602: 29.1; [PATCH] Add function eww-copy-point-link-url to eww Osmo Karppinen
@ 2023-12-03 17:02 ` Juri Linkov
  2023-12-03 17:48   ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-12-03 18:02 ` Osmo Karppinen
  1 sibling, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2023-12-03 17:02 UTC (permalink / raw)
  To: Osmo Karppinen; +Cc: 67602

> New function eww-copy-point-link-url will copy URL of link pointed by
> the pointer to the killring in eww. Patch adds also new key binding for
> the function and also menuitem. I think that key "c" is good for this
> operation.

Another variant would be to reuse 'eww-copy-page-url' bound to "w",
and to copy a link with a prefix argument.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#67602: 29.1; [PATCH] Add function eww-copy-point-link-url to eww.
  2023-12-03 17:02 ` Juri Linkov
@ 2023-12-03 17:48   ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 5+ messages in thread
From: Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-12-03 17:48 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Osmo Karppinen, 67602

Juri Linkov <juri@linkov.net> writes:

>> New function eww-copy-point-link-url will copy URL of link pointed by
>> the pointer to the killring in eww. Patch adds also new key binding for
>> the function and also menuitem. I think that key "c" is good for this
>> operation.
>
> Another variant would be to reuse 'eww-copy-page-url' bound to "w",
> and to copy a link with a prefix argument.

I'm think "w" already does that in EWW when point is on a link, no?
That's thanks to the fact that SHR renders links with a `keymap`
property that binds "w" to `shr-maybe-probe-and-copy-url`.


Best,

Eshel





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#67602: 29.1; [PATCH] Add function eww-copy-point-link-url to eww.
  2023-12-03 15:13 bug#67602: 29.1; [PATCH] Add function eww-copy-point-link-url to eww Osmo Karppinen
  2023-12-03 17:02 ` Juri Linkov
@ 2023-12-03 18:02 ` Osmo Karppinen
  2023-12-03 18:16   ` Eli Zaretskii
  1 sibling, 1 reply; 5+ messages in thread
From: Osmo Karppinen @ 2023-12-03 18:02 UTC (permalink / raw)
  To: Eshel Yaron; +Cc: 67602, Juri Linkov


You were right. This case is closed. Documentation is bit misleading.
When you Type C-h k and your point is not on link it shows you
eww-copy-page-url. And same when you look at your local eww keymap.
It is somehow hard to find that there is eww-link-keymap.

With thanks,
Osmo Karppinen





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#67602: 29.1; [PATCH] Add function eww-copy-point-link-url to eww.
  2023-12-03 18:02 ` Osmo Karppinen
@ 2023-12-03 18:16   ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2023-12-03 18:16 UTC (permalink / raw)
  To: Osmo Karppinen; +Cc: 67602, me, juri

> Cc: 67602@debbugs.gnu.org, Juri Linkov <juri@linkov.net>
> Date: Sun, 03 Dec 2023 20:02:36 +0200
> From: Osmo Karppinen <osmkarp@gmail.com>
> 
> 
> You were right. This case is closed. Documentation is bit misleading.
> When you Type C-h k and your point is not on link it shows you
> eww-copy-page-url. And same when you look at your local eww keymap.
> It is somehow hard to find that there is eww-link-keymap.

EWW has its own manual, and this feature is described there, see the
node "Basics".





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-12-03 18:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-03 15:13 bug#67602: 29.1; [PATCH] Add function eww-copy-point-link-url to eww Osmo Karppinen
2023-12-03 17:02 ` Juri Linkov
2023-12-03 17:48   ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-03 18:02 ` Osmo Karppinen
2023-12-03 18:16   ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).