Subject: bug#27341: updated patch to fix docstring

From: Alex Branham <[email-masked]>
Date: Mon, 26 Jun 2017 16:00:46 +0200

Here's a new patch that checks the region directly, ignoring `use-empty-active-region'.

>From c3babb73d8f29ff3f27aacbac99c7226ef4b32a0 Mon Sep 17 00:00:00 2001
From: Alex Branham <[email-masked]>
Date: Mon, 26 Jun 2017 15:57:15 +0200
Subject: [PATCH] eww-search-words prompt user for query if region active and
 not empty

---
 lisp/net/eww.el | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index fe31657914..cf46530d35 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -314,9 +314,15 @@ 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)))
+  (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: ")))))

 (defun eww-open-in-new-buffer ()
   "Fetch link at point in a new EWW buffer."
--
2.13.1

On Sun 25 Jun 2017 at 14:29, [email-masked] wrote:

> Alex Branham <[email-masked]> writes:
>
>> -  (eww (buffer-substring beg end)))
>> +  (if (region-active-p)
>
> If think we should use `use-region-p' instead.  Or perhaps just check
> directly if region is empty?  I guess searching for an empty string
> doesn't make much sense even if `use-empty-active-region' is t.

>From c3babb73d8f29ff3f27aacbac99c7226ef4b32a0 Mon Sep 17 00:00:00 2001
From: Alex Branham <[email-masked]>
Date: Mon, 26 Jun 2017 15:57:15 +0200
Subject: [PATCH] eww-search-words prompt user for query if region active and
 not empty

---
 lisp/net/eww.el | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index fe31657914..cf46530d35 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -314,9 +314,15 @@ 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)))
+  (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: ")))))
 
 (defun eww-open-in-new-buffer ()
   "Fetch link at point in a new EWW buffer."
-- 
2.13.1