all messages for Emacs-related lists mirrored at yhetil.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

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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.