]> git.eshelyaron.com Git - emacs.git/commitdiff
Provide a (thing-at-point 'url) in eww buffers
authorLars Ingebrigtsen <larsi@gnus.org>
Sat, 23 Jan 2021 19:39:45 +0000 (20:39 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Sat, 23 Jan 2021 19:40:07 +0000 (20:40 +0100)
* lisp/net/eww.el (eww-mode): Allow (thing-at-point 'url) to work
in eww buffers.
(eww--url-at-point): New function.

lisp/net/eww.el

index d131b2bf8c90b4a78bef683052103a51e0f53972..e39a4c33b2062a0aeb584fc8da80e90f0ceb5dbe 100644 (file)
@@ -1050,9 +1050,16 @@ the like."
   ;; multi-page isearch support
   (setq-local multi-isearch-next-buffer-function #'eww-isearch-next-buffer)
   (setq truncate-lines t)
+  (setq-local thing-at-point-provider-alist
+              (append thing-at-point-provider-alist
+                      '((url . eww--url-at-point))))
   (buffer-disable-undo)
   (setq buffer-read-only t))
 
+(defun eww--url-at-point ()
+  "`thing-at-point' provider function."
+  (get-text-property (point) 'shr-url))
+
 ;;;###autoload
 (defun eww-browse-url (url &optional new-window)
   "Ask the EWW browser to load URL.