From 1c5929ee230d4efddfb4b0e0c647653026da4bd1 Mon Sep 17 00:00:00 2001 From: Michael Heerdegen Date: Wed, 25 Mar 2020 03:55:41 +0100 Subject: [PATCH] WIP: Make standard bookmarks work for eww buffers --- lisp/net/eww.el | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lisp/net/eww.el b/lisp/net/eww.el index c83884fd25..8d0405ba0e 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -889,6 +889,9 @@ eww-mode (setq-local desktop-save-buffer #'eww-desktop-misc-data) ;; multi-page isearch support (setq-local multi-isearch-next-buffer-function #'eww-isearch-next-buffer) + ;; Emacs bookmarks support + (defvar bookmark-make-record-function) + (setq-local bookmark-make-record-function #'eww-bookmark-make-record) (setq truncate-lines t) (buffer-disable-undo) (setq buffer-read-only t)) @@ -1880,6 +1883,27 @@ eww-bookmark-mode (buffer-disable-undo) (setq truncate-lines t)) +;;; Emacs bookmarks support + +(declare-function bookmark-make-record-default + "bookmark" (&optional no-file no-context posn)) +(declare-function bookmark-prop-get "bookmark" (bookmark prop)) +(declare-function bookmark-default-handler "bookmark" (bmk)) + +(defun eww-bookmark-make-record () + "Doc..." + (let ((url (plist-get eww-data :url))) + `(,(plist-get eww-data :title) + ,@(bookmark-make-record-default 'no-file) + (url . ,url) + (handler . bookmark-eww-bookmark-jump)))) + +;;;###autoload +(defun bookmark-eww-bookmark-jump (bookmark) + "Default bookmark handler for eww buffers." + (eww-browse-url (bookmark-prop-get bookmark 'url)) + (bookmark-default-handler bookmark)) + ;;; History code (defun eww-save-history () -- 2.25.1