mirror of
https://github.com/protesilaos/dotfiles.git
synced 2026-09-10 07:16:20 -04:00
emacs: provide eww and bookmark.el integration
This commit is contained in:
parent
2fd4e7e57d
commit
438f9549c1
|
|
@ -84,6 +84,7 @@
|
|||
(use-package prot-eww
|
||||
:ensure nil
|
||||
:after eww
|
||||
:hook (eww-mode . prot-eww-set-bookmark-handler)
|
||||
:config
|
||||
(setq prot-eww-save-history-file
|
||||
(locate-user-emacs-file "prot-eww-visited-history"))
|
||||
|
|
@ -94,6 +95,7 @@
|
|||
|
||||
(define-prefix-command 'prot-eww-map)
|
||||
(define-key global-map (kbd "C-c w") 'prot-eww-map)
|
||||
|
||||
(prot-emacs-keybind prot-eww-map
|
||||
"b" #'prot-eww-visit-bookmark
|
||||
"e" #'prot-eww-browse-dwim
|
||||
|
|
|
|||
|
|
@ -10195,6 +10195,7 @@ account default : pub
|
|||
(use-package prot-eww
|
||||
:ensure nil
|
||||
:after eww
|
||||
:hook (eww-mode . prot-eww-set-bookmark-handler)
|
||||
:config
|
||||
(setq prot-eww-save-history-file
|
||||
(locate-user-emacs-file "prot-eww-visited-history"))
|
||||
|
|
@ -10205,6 +10206,7 @@ account default : pub
|
|||
|
||||
(define-prefix-command 'prot-eww-map)
|
||||
(define-key global-map (kbd "C-c w") 'prot-eww-map)
|
||||
|
||||
(prot-emacs-keybind prot-eww-map
|
||||
"b" #'prot-eww-visit-bookmark
|
||||
"e" #'prot-eww-browse-dwim
|
||||
|
|
@ -12541,6 +12543,31 @@ As a final step, save `prot-eww-visited-history' to a file (see
|
|||
(when (yes-or-no-p "Are you sure you want to quit eww?")
|
||||
(run-hooks 'prot-eww-quit-hook))))
|
||||
|
||||
;;;; Bookmark support
|
||||
|
||||
(declare-function bookmark-prop-get "bookmark" (bookmark prop))
|
||||
|
||||
(defun prot-eww-bookmark-name ()
|
||||
"Return name of bookmark based on currect directory."
|
||||
(buffer-name))
|
||||
|
||||
(defun prot-eww-bookmark-make-record ()
|
||||
"Create a bookmark for the current Shell buffer."
|
||||
`(,(prot-eww-bookmark-name)
|
||||
(url . ,(prot-eww--get-current-url))
|
||||
(handler . prot-eww-bookmark-jump)))
|
||||
|
||||
;;;###autoload
|
||||
(defun prot-eww-bookmark-jump (bookmark)
|
||||
"Default BOOKMARK handler for Shell buffers."
|
||||
(eww (bookmark-prop-get bookmark 'url)))
|
||||
|
||||
(put 'prot-eww-bookmark-jump 'bookmark-handler-type "EWW")
|
||||
|
||||
(defun prot-eww-set-bookmark-handler ()
|
||||
"Set my EWW bookmark handler for integration with bookmark.el."
|
||||
(setq-local bookmark-make-record-function #'prot-eww-bookmark-make-record))
|
||||
|
||||
(provide 'prot-eww)
|
||||
;;; prot-eww.el ends here
|
||||
#+end_src
|
||||
|
|
|
|||
|
|
@ -656,5 +656,30 @@ As a final step, save `prot-eww-visited-history' to a file (see
|
|||
(when (yes-or-no-p "Are you sure you want to quit eww?")
|
||||
(run-hooks 'prot-eww-quit-hook))))
|
||||
|
||||
;;;; Bookmark support
|
||||
|
||||
(declare-function bookmark-prop-get "bookmark" (bookmark prop))
|
||||
|
||||
(defun prot-eww-bookmark-name ()
|
||||
"Return name of bookmark based on currect directory."
|
||||
(buffer-name))
|
||||
|
||||
(defun prot-eww-bookmark-make-record ()
|
||||
"Create a bookmark for the current Shell buffer."
|
||||
`(,(prot-eww-bookmark-name)
|
||||
(url . ,(prot-eww--get-current-url))
|
||||
(handler . prot-eww-bookmark-jump)))
|
||||
|
||||
;;;###autoload
|
||||
(defun prot-eww-bookmark-jump (bookmark)
|
||||
"Default BOOKMARK handler for Shell buffers."
|
||||
(eww (bookmark-prop-get bookmark 'url)))
|
||||
|
||||
(put 'prot-eww-bookmark-jump 'bookmark-handler-type "EWW")
|
||||
|
||||
(defun prot-eww-set-bookmark-handler ()
|
||||
"Set my EWW bookmark handler for integration with bookmark.el."
|
||||
(setq-local bookmark-make-record-function #'prot-eww-bookmark-make-record))
|
||||
|
||||
(provide 'prot-eww)
|
||||
;;; prot-eww.el ends here
|
||||
|
|
|
|||
Loading…
Reference in a new issue