Add bookmark support and keybindings to EWW in Emacs
This commit adds the ability to access EWW bookmarks. It modifies the init-eww.el configuration file by introducing a function to visit bookmarks and updating the keybindings to include commands for accessing and listing bookmarks.
This commit is contained in:
parent
4a7ccb378d
commit
8ad4c70070
@ -7,6 +7,7 @@
|
|||||||
(interactive
|
(interactive
|
||||||
(let* ((uris (eww-suggested-uris))
|
(let* ((uris (eww-suggested-uris))
|
||||||
(browser-history (mapcar (lambda (h) (plist-get h :url)) eww-history))
|
(browser-history (mapcar (lambda (h) (plist-get h :url)) eww-history))
|
||||||
|
(bookmarks (mapcar (lambda (b) (plist-get b :url)) eww-bookmarks))
|
||||||
(suggestions (delete-dups (append uris eww-prompt-history browser-history)))
|
(suggestions (delete-dups (append uris eww-prompt-history browser-history)))
|
||||||
(current-uri (plist-get eww-data :url)))
|
(current-uri (plist-get eww-data :url)))
|
||||||
(list (completing-read "URL or keywords: " suggestions nil nil current-uri 'eww-prompt-history)
|
(list (completing-read "URL or keywords: " suggestions nil nil current-uri 'eww-prompt-history)
|
||||||
@ -74,10 +75,24 @@ new EWW buffer."
|
|||||||
(position (replace-regexp-in-string "^.*(\\([0-9]+\\))[\s\t]+~" "\\1" selection))
|
(position (replace-regexp-in-string "^.*(\\([0-9]+\\))[\s\t]+~" "\\1" selection))
|
||||||
(point (string-to-number position)))
|
(point (string-to-number position)))
|
||||||
(goto-char point))))
|
(goto-char point))))
|
||||||
|
(defun eww-visit-bookmark (bookmark &optional arg)
|
||||||
|
"Visit BOOKMARK in EWW."
|
||||||
|
(interactive (list (let* ((bookmarks (mapcar (lambda (b)
|
||||||
|
(cons (format "%s | %s"
|
||||||
|
(plist-get b :title)
|
||||||
|
(plist-get b :url))
|
||||||
|
(plist-get b :url)))
|
||||||
|
eww-bookmarks))
|
||||||
|
(bookmark (completing-read "Bookmark: " bookmarks)))
|
||||||
|
(cdr (assoc bookmark bookmarks)))
|
||||||
|
current-prefix-arg))
|
||||||
|
(eww bookmark arg))
|
||||||
:general
|
:general
|
||||||
(leader-map "E" #'eww)
|
(leader-map "E" #'eww)
|
||||||
(normal eww-mode-map
|
(normal eww-mode-map
|
||||||
"go" #'eww
|
"go" #'eww
|
||||||
|
"gb" #'eww-visit-bookmark
|
||||||
|
"gB" #'eww-list-bookmarks
|
||||||
"gJ"#'eww-jump-to-url-on-page
|
"gJ"#'eww-jump-to-url-on-page
|
||||||
"gV" #'eww-visit-url-on-page))
|
"gV" #'eww-visit-url-on-page))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user