[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master c7fc4c81192 2/3: eww: Provide completions for bookmarks and sugge
From: |
Eli Zaretskii |
Subject: |
master c7fc4c81192 2/3: eww: Provide completions for bookmarks and suggested URIs. |
Date: |
Tue, 25 Apr 2023 10:30:57 -0400 (EDT) |
branch: master
commit c7fc4c811923725b961cfbf7e6a2051ae08c1eea
Author: Antero Mejr <antero@mailbox.org>
Commit: Eli Zaretskii <eliz@gnu.org>
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)
---
etc/NEWS | 6 ++++++
lisp/net/eww.el | 16 ++++++++++++----
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 38858a4bc63..004c8bcc6da 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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
+++
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index eb123864973..61f0f47373d 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