From 1c635c024a9b7e01c29704af0939c7a39583ee9c Mon Sep 17 00:00:00 2001 From: Antero Mejr Date: Thu, 13 Apr 2023 15:59:54 +0000 Subject: [PATCH v3 2/2] eww: Provide completions for bookmarks and suggested URIs. * lisp/net/eww.el (eww): Add the result of 'eww-suggest-uris' to the completion collection argument. (eww-bookmark-urls): New procedure. (eww-suggest-uris): Add "eww-bookmark-urls" to the default list. * etc/NEWS (EWW): Add NEWS entry for the change. --- etc/NEWS | 6 ++++++ lisp/net/eww.el | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 2df0d969991..41880208c7e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -224,6 +224,12 @@ activate this behavior. The interactive minibuffer prompt when invoking 'eww' now has support for tab completion. ++++ +*** 'eww' URL and keyword prompt now completes suggested URIs and bookmarks. +The interactive minibuffer prompt when invoking 'eww' now provides +completions from 'eww-suggest-uris'. 'eww-suggest-uris' now includes +bookmark URIs. + ** go-ts-mode +++ diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 7f0c9167c6a..48a1813c92d 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -94,7 +94,8 @@ no parameters) that returns a directory name." (defcustom eww-suggest-uris '(eww-links-at-point thing-at-point-url-at-point - eww-current-url) + eww-current-url + eww-bookmark-urls) "List of functions called to form the list of default URIs for `eww'. Each of the elements is a function returning either a string or a list of strings. The results will be joined into a single list with @@ -104,7 +105,8 @@ duplicate entries (if any) removed." :type 'hook :options '(eww-links-at-point thing-at-point-url-at-point - eww-current-url)) + eww-current-url + eww-bookmark-urls)) (defcustom eww-bookmarks-directory user-emacs-directory "Directory where bookmark files will be stored." @@ -387,8 +389,8 @@ For more information, see Info node `(eww) Top'." (minibuffer-local-completion-map eww-minibuffer-url-keymap)) (list (completing-read (format-prompt "Enter URL or keywords" (and uris (car uris))) - eww-prompt-history nil nil nil - 'eww-prompt-history uris) + (seq-uniq (append eww-prompt-history uris)) + nil nil nil 'eww-prompt-history uris) current-prefix-arg))) (setq url (eww--dwim-expand-url url)) (pop-to-buffer-same-window @@ -2235,6 +2237,12 @@ If ERROR-OUT, signal user-error if there are no bookmarks." 'eww-bookmark))) (eww-browse-url (plist-get bookmark :url)))) +(defun eww-bookmark-urls () + "Get the URLs from the current list of bookmarks." + (interactive nil eww-boomark-mode) + (eww-read-bookmarks) + (mapcar (lambda (x) (plist-get x :url)) eww-bookmarks)) + (defvar-keymap eww-bookmark-mode-map "C-k" #'eww-bookmark-kill "C-y" #'eww-bookmark-yank -- 2.39.2