summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2021-09-27 18:18:54 -0500
committerCase Duckworth2021-09-27 18:19:22 -0500
commit910e982e3796faefd9cc248e2477596d01fb499a (patch)
treeededf4f4118a28cbff2ec5675a0c2da7cac4ee1f
parentRemove unneeded variables (diff)
downloademacs-910e982e3796faefd9cc248e2477596d01fb499a.tar.gz
emacs-910e982e3796faefd9cc248e2477596d01fb499a.zip
Add bookmarks to eww
Like, regular ones.
-rw-r--r--init.el37
-rw-r--r--lisp/acdw-eww.el38
2 files changed, 60 insertions, 15 deletions
diff --git a/init.el b/init.el index 35172e3..0ace8a4 100644 --- a/init.el +++ b/init.el
@@ -483,6 +483,7 @@ In short, DO NOT USE THIS FUNCTION!!!"
483 (load (expand-file-name "eshell" user-emacs-directory)))))) 483 (load (expand-file-name "eshell" user-emacs-directory))))))
484 484
485(setup eww 485(setup eww
486 (:also-load acdw-eww)
486 (defvar-local eww-readable-p nil 487 (defvar-local eww-readable-p nil
487 "Whether current buffer is in readable-mode.") 488 "Whether current buffer is in readable-mode.")
488 (:option eww-search-prefix "https://duckduckgo.com/html?q=" 489 (:option eww-search-prefix "https://duckduckgo.com/html?q="
@@ -497,23 +498,29 @@ In short, DO NOT USE THIS FUNCTION!!!"
497 (advice-add 'eww-render :after #'eww@is-not-readable) 498 (advice-add 'eww-render :after #'eww@is-not-readable)
498 (advice-add 'eww-back-url :after #'eww@is-not-readable) 499 (advice-add 'eww-back-url :after #'eww@is-not-readable)
499 500
500 (:hook #'reading-mode)) 501 (:hook #'reading-mode
502 (defun bookmark-eww--setup ()
503 "Setup eww bookmark integration."
504 (setq-local bookmark-make-record-function #'bookmark-eww--make)))
501 505
502(setup files 506 (:bind "b" #'bookmark-set
503 (:option 507 "B" #'bookmark-jump
504 auto-save-file-name-transforms `((".*" ,(acdw/dir "auto-save/" t) t)) 508 "M-n" nil
505 auto-save-list-file-prefix (acdw/dir "auto-save-list/.saves-" t) 509 "M-p" nil))
506 auto-save-interval 60
507 auto-save-timeout 60
508 auto-save-visited-interval auto-save-timeout
509 backup-by-copying t
510 backup-directory-alist `((".*" . ,(acdw/dir "backup/" t)))
511 delete-old-versions t
512 mode-require-final-newline 'visit-save
513 tramp-backup-directory-alist backup-directory-alist
514 vc-make-backup-files t
515 version-control t)
516 510
511(setup files
512 (:option auto-save-file-name-transforms `((".*" ,(acdw/dir "auto-save/" t) t))
513 auto-save-list-file-prefix (acdw/dir "auto-save-list/.saves-" t)
514 auto-save-interval 60
515 auto-save-timeout 60
516 auto-save-visited-interval auto-save-timeout
517 backup-by-copying t
518 backup-directory-alist `((".*" . ,(acdw/dir "backup/" t)))
519 delete-old-versions t
520 mode-require-final-newline 'visit-save
521 tramp-backup-directory-alist backup-directory-alist
522 vc-make-backup-files t
523 version-control t)
517 (auto-save-visited-mode +1)) 524 (auto-save-visited-mode +1))
518 525
519(setup find-func 526(setup find-func
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