[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bookmarks in EWW
From: |
Michael Heerdegen |
Subject: |
Re: Bookmarks in EWW |
Date: |
Wed, 25 Mar 2020 04:05:25 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> So should we expect a patch shortly on `master`?
My thoughts.
Ok, I've thrown something together (draft!) and tested quickly:
From 1c5929ee230d4efddfb4b0e0c647653026da4bd1 Mon Sep 17 00:00:00 2001
From: Michael Heerdegen <michael_heerdegen@web.de>
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
Questions:
Does it make sense that these bookmarks save a text part? Surely makes
sense for some cases, e.g. locally saved documentation in html, but
makes not much sense for e.g. newspaper sites.
Do I need to declare `bookmark-make-record-function' as special when
setting with `setq-local' (that's what doc-view does)? If the answer is
"yes", do I need to do it at top-level?
Do I have to add a NEWS entry?
TIA,
Michael.
- Bookmarks in EWW, Marcin Borkowski, 2020/03/23
- RE: Bookmarks in EWW, Drew Adams, 2020/03/23
- Re: Bookmarks in EWW, Michael Heerdegen, 2020/03/23
- Re: Bookmarks in EWW, Stefan Monnier, 2020/03/25
- Re: Bookmarks in EWW, Michael Heerdegen, 2020/03/25
- Re: Bookmarks in EWW, Stefan Monnier, 2020/03/26
- Re: Bookmarks in EWW, Michael Heerdegen, 2020/03/26
- Re: Bookmarks in EWW, Stefan Monnier, 2020/03/26
- Re: Bookmarks in EWW, Michael Heerdegen, 2020/03/27