>From 1d036b16903dd18268c499c4617d430172b08ffe Mon Sep 17 00:00:00 2001 From: Alex Branham Date: Fri, 30 Jun 2017 08:16:13 +0200 Subject: [PATCH] Make eww-search-words prompt for query if nothing selected * lisp/net/eww.el (eww-search-words): Make eww-search-words prompt the user for a search query if the region is inactive or if the region is just whitespace. Copyright-paperwork-exempt: yes --- lisp/net/eww.el | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lisp/net/eww.el b/lisp/net/eww.el index fe31657914..757e738a18 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -314,9 +314,17 @@ word(s) will be searched for via `eww-search-prefix'." ;;;###autoload (defun eww-search-words (&optional beg end) "Search the web for the text between BEG and END. -See the `eww-search-prefix' variable for the search engine used." +If region is active (and not whitespace), search the web for +the text between BEG and END. Else, prompt the user for a search +string. See the `eww-search-prefix' variable for the search +engine used." (interactive "r") - (eww (buffer-substring beg end))) + (if (use-region-p) + (let ((region-string (buffer-substring beg end))) + (if (not (string-match-p "\\`[ \n\t\r\v\f]*\\'" region-string)) + (eww region-string) + (eww (read-string "Query: ")))) + (eww (read-string "Query: ")))) (defun eww-open-in-new-buffer () "Fetch link at point in a new EWW buffer." -- 2.13.2