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.  (Bug#62800)
This commit is contained in:
Antero Mejr 2023-04-13 15:59:54 +00:00 committed by Eli Zaretskii
parent df6cc4d33b
commit c7fc4c8119
2 changed files with 18 additions and 4 deletions

View file

@ -236,6 +236,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
+++

View file

@ -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