]> git.eshelyaron.com Git - emacs.git/commitdiff
eww: Provide completions for bookmarks and suggested URIs.
authorAntero Mejr <antero@mailbox.org>
Thu, 13 Apr 2023 15:59:54 +0000 (15:59 +0000)
committerEli Zaretskii <eliz@gnu.org>
Tue, 25 Apr 2023 14:29:23 +0000 (17:29 +0300)
* 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
lisp/net/eww.el

index 38858a4bc63d730dfa5086dd73185d491779d825..004c8bcc6da8ea77ace5a856954d126e8ef43e64 100644 (file)
--- 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
 
 +++
index eb123864973fc7685453e82bcbe6d973c7e704ef..61f0f47373d2cb7ff190e20cf8cca55dc217f20a 100644 (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