about summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
authorCase Duckworth2021-09-27 18:18:54 -0500
committerCase Duckworth2021-09-27 18:19:22 -0500
commit910e982e3796faefd9cc248e2477596d01fb499a (patch)
treeededf4f4118a28cbff2ec5675a0c2da7cac4ee1f /lisp
parentRemove unneeded variables (diff)
downloademacs-910e982e3796faefd9cc248e2477596d01fb499a.tar.gz
emacs-910e982e3796faefd9cc248e2477596d01fb499a.zip
Add bookmarks to eww
Like, regular ones.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/acdw-eww.el38
1 files changed, 38 insertions, 0 deletions
diff --git a/lisp/acdw-eww.el b/lisp/acdw-eww.el new file mode 100644 index 0000000..8e7f42d --- /dev/null +++ b/lisp/acdw-eww.el
@@ -0,0 +1,38 @@
1;;; acdw-eww.el --- EWW customizations -*- lexical-binding: t -*-
2
3(require 'bookmark)
4(require 'eww)
5
6(defun bookmark-eww--make ()
7 "Make eww bookmark record."
8 `((filename . ,(plist-get eww-data :url))
9 (title . ,(plist-get eww-data :title))
10 (time . ,(current-time-string))
11 (handler . ,#'bookmark-eww-handler)
12 (defaults . (,(concat
13 ;; url without the https and path
14 (replace-regexp-in-string
15 "/.*" ""
16 (replace-regexp-in-string
17 "\\`https?://" ""
18 (plist-get eww-data :url)))
19 " - "
20 ;; page title
21 (replace-regexp-in-string
22 "\\` +\\| +\\'" ""
23 (replace-regexp-in-string
24 "[\n\t\r ]+" " "
25 (plist-get eww-data :title))))))))
26
27
28
29(defun bookmark-eww-handler (bm)
30 "Handler for eww bookmarks."
31 (eww-browse-url (alist-get 'filename bm)))
32
33(defun bookmark-eww--setup ()
34 "Setup eww bookmark integration."
35 (setq-local bookmark-make-record-function #'bookmark-eww--make))
36
37(provide 'acdw-eww)
38;;; acdw-eww.el ends here