[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master c2c4c89dbc 1/2: Also use eww URL transformers in the actual links
From: |
Lars Ingebrigtsen |
Subject: |
master c2c4c89dbc 1/2: Also use eww URL transformers in the actual links |
Date: |
Wed, 14 Sep 2022 09:18:05 -0400 (EDT) |
branch: master
commit c2c4c89dbc4be55114f2874284bf46cf5bb711ed
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Also use eww URL transformers in the actual links
* lisp/net/eww.el (eww-mode): Use it to transform URLs
(bug#57796).
* lisp/net/shr.el (shr-url-transformer): New variable.
(shr-tag-a): Use it.
---
lisp/net/eww.el | 1 +
lisp/net/shr.el | 9 ++++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 35e5bdd734..34e74f8ffa 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -1180,6 +1180,7 @@ the like."
'((url . eww--url-at-point))))
(setq-local bookmark-make-record-function #'eww-bookmark-make-record)
(buffer-disable-undo)
+ (setq-local shr-url-transformer #'eww--transform-url)
(setq buffer-read-only t))
(defun eww--url-at-point ()
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index a06978d9ce..54ce9b1a41 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -295,6 +295,11 @@ and other things:
(make-composed-keymap shr-map image-map)
shr-map))
+(defvar shr-url-transformer #'identity
+ "Function to transform URLs.
+It's called with the URL as the parameter, and should return the
+ URL to use.")
+
;; Public functions and commands.
(declare-function libxml-parse-html-region "xml.c"
(start end &optional base-url discard-comments))
@@ -1489,7 +1494,9 @@ ones, in case fg and bg are nil."
(dom-attr dom 'name)))) ; Obsolete since HTML5.
(push (cons id (set-marker (make-marker) start)) shr--link-targets))
(when url
- (shr-urlify (or shr-start start) (shr-expand-url url) title)
+ (shr-urlify (or shr-start start)
+ (funcall shr-url-transformer (shr-expand-url url))
+ title)
;; Check whether the URL is suspicious.
(when-let ((warning (or (textsec-suspicious-p
(shr-expand-url url) 'url)