diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/acdw-eww.el | 38 |
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 | ||