From f3353bb12456aa74d21418c889879f327bd5d969 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Tue, 23 Jul 2024 10:58:04 -0400 Subject: [PATCH] Add eww configuration and custom URL prompt function This commit adds configuration for the built-in `eww` web browser in Emacs. It introduces a custom prompting function that suggests URLs or keywords based on the browsing history, current URL, and other suggestions, enhancing the user experience. Additionally, a key binding for the `eww` function is added in `eww-mode-map`. --- emacs/.emacs.d/config/init-built-ins.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/emacs/.emacs.d/config/init-built-ins.el b/emacs/.emacs.d/config/init-built-ins.el index 089bfa6..d686d6f 100644 --- a/emacs/.emacs.d/config/init-built-ins.el +++ b/emacs/.emacs.d/config/init-built-ins.el @@ -80,4 +80,19 @@ (browse-url url-or-symbol) (browse-url (format "https://www.google.com/search?q=%s" url-or-symbol))))) +(use-package eww + :straight (:type built-in) + :config + (defun eww-before-advice (&rest args) + (interactive + (let* ((uris (eww-suggested-uris)) + (browser-history (mapcar (lambda (h) (plist-get h :url)) eww-history)) + (suggestions (delete-dups (append uris eww-prompt-history browser-history))) + (current-uri (plist-get eww-data :url))) + (list (completing-read "URL or keywords: " suggestions nil nil current-uri 'eww-prompt-history) + current-prefix-arg)))) + (advice-add 'eww :before #'eww-before-advice) + :general + (normal eww-mode-map "go" #'eww)) + (provide 'init-built-ins)