aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas2021-09-29 03:24:10 +0200
committerStefan Kangas2021-09-29 03:53:07 +0200
commitda89bdde2e3aa941594a112db884ede1beaac658 (patch)
treee3465ab1356c411e001f6a9839ac4f75bacabcc4
parentee856b76ff6a241cefec1f448a2c5528ad0f1c56 (diff)
downloademacs-da89bdde2e3aa941594a112db884ede1beaac658.tar.gz
emacs-da89bdde2e3aa941594a112db884ede1beaac658.zip
Add bookmark.el support to eww
* lisp/net/eww.el (eww-bookmark-name, eww-bookmark-make-record) (eww-bookmark-jump): New defuns. (eww-mode): Set up bookmark handler.
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/net/eww.el23
2 files changed, 28 insertions, 0 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 21cc3c50cd1..38a8f3015d9 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2391,6 +2391,11 @@ The function that is invoked when clicking on or otherwise following a
2391'mailto:' link in an EWW buffer can now be customized. For more 2391'mailto:' link in an EWW buffer can now be customized. For more
2392information, see the related entry about 'shr-browse-url' above. 2392information, see the related entry about 'shr-browse-url' above.
2393 2393
2394---
2395*** Support for bookmark.el.
2396The command `bookmark-set' (bound to `C-x r m') is now supported, and
2397will create a bookmark that opens the current URL in EWW.
2398
2394** SHR 2399** SHR
2395 2400
2396--- 2401---
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index e9b31858073..bb6583c2a9a 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -1101,6 +1101,7 @@ the like."
1101 (setq-local thing-at-point-provider-alist 1101 (setq-local thing-at-point-provider-alist
1102 (append thing-at-point-provider-alist 1102 (append thing-at-point-provider-alist
1103 '((url . eww--url-at-point)))) 1103 '((url . eww--url-at-point))))
1104 (setq-local bookmark-make-record-function #'eww-bookmark-make-record)
1104 (buffer-disable-undo) 1105 (buffer-disable-undo)
1105 (setq buffer-read-only t)) 1106 (setq buffer-read-only t))
1106 1107
@@ -2419,6 +2420,28 @@ Otherwise, the restored buffer will contain a prompt to do so by using
2419 (eww-previous-url)))) 2420 (eww-previous-url))))
2420 (current-buffer)) 2421 (current-buffer))
2421 2422
2423;;; bookmark.el support
2424
2425(declare-function bookmark-make-record-default
2426 "bookmark" (&optional no-file no-context posn))
2427(declare-function bookmark-prop-get "bookmark" (bookmark prop))
2428
2429(defun eww-bookmark-name ()
2430 "Create a default bookmark name for the current EWW buffer."
2431 (plist-get eww-data :title))
2432
2433(defun eww-bookmark-make-record ()
2434 "Create a bookmark for the current EWW buffer."
2435 `(,(eww-bookmark-name)
2436 ,@(bookmark-make-record-default t)
2437 (location . ,(plist-get eww-data :url))
2438 (handler . eww-bookmark-jump)))
2439
2440;;;###autoload
2441(defun eww-bookmark-jump (bookmark)
2442 "Default bookmark handler for EWW buffers."
2443 (eww (bookmark-prop-get bookmark 'location)))
2444
2422(provide 'eww) 2445(provide 'eww)
2423 2446
2424;;; eww.el ends here 2447;;; eww.el ends here