:parent shr-image-map
"RET" #'eww-follow-link)
-(defvar-keymap eww-minibuffer-url-keymap
- :doc "Keymap used in the minibuffer prompt for URLs or keywords."
- :parent minibuffer-local-completion-map
- "SPC" #'self-insert-command
- "?" #'self-insert-command)
-
(defun eww-suggested-uris nil
"Return the list of URIs to suggest at the `eww' prompt.
This list can be customized via `eww-suggest-uris'."
(user-error "No URL given"))
(eww (pop command-line-args-left)))
+(defun eww-read-url-or-search-string (&optional initial-input)
+ (let ((uris (eww-suggested-uris)))
+ (completing-read (format-prompt "Enter URL or keywords" uris)
+ (seq-uniq (append eww-prompt-history uris))
+ nil nil initial-input 'eww-prompt-history uris)))
;;;###autoload
(defun eww (url &optional new-buffer buffer)
For more information, see Info node `(eww) Top'."
(interactive
- (let ((uris (eww-suggested-uris))
- (minibuffer-local-completion-map eww-minibuffer-url-keymap))
- (list (completing-read (format-prompt "Enter URL or keywords"
- (and uris (car uris)))
- (seq-uniq (append eww-prompt-history uris))
- nil nil nil 'eww-prompt-history uris)
- current-prefix-arg)))
+ (list (eww-read-url-or-search-string) current-prefix-arg))
(setq url (eww--dwim-expand-url url))
(pop-to-buffer-same-window
(cond
user for a search string. See the variable `eww-search-prefix'
for the search engine used."
(interactive)
- (if (use-region-p)
- (let ((region-string (buffer-substring (region-beginning) (region-end))))
- (if (not (string-match-p "\\`[ \n\t\r\v\f]*\\'" region-string))
- (eww region-string)
- (call-interactively #'eww)))
- (call-interactively #'eww)))
+ (eww (eww-read-url-or-search-string
+ (and (use-region-p)
+ (string-trim (buffer-substring-no-properties (point) (mark)))))))
(defun eww--open-url-in-new-buffer (url)
"Open the URL in a new EWW buffer."