Subject: Re: bug#27341: updated patch to fix docstring

From: Alex Branham <[email-masked]>
Date: Sun, 02 Jul 2017 20:45:49 +0200

On Sun 02 Jul 2017 at 18:32, [email-masked] wrote:

> Alex Branham <[email-masked]> writes:
>
>> On Fri 30 Jun 2017 at 00:54, [email-masked] wrote:
>
>>> Doc strings shouldn't be indented like that, and there should be a
>>> double space between sentences.
>>
>> Fixed.
>
> You missed the double spacing before the "Else,".

D'oh! Fixed this time, sorry!

>> Actually, we need to check (use-region-p) anyway in case the mark
>> hasn't been activated yet in the buffer:
>
> Hmm, I just tried this and it doesn't quite do the job.  I believe the
> problem is that the (interactive "r") form throws an error when the mark
> hasn't been activated yet.  To handle this case correctly you need to
> replace the "r" with some lisp code that produces the argument list.

Ok, now I don't use "r" and just get the region directly. I think that'll do the trick?

Thanks,
Alex

>From 9dc5deec743d827e6d099f0f46b257ab8e7142c1 Mon Sep 17 00:00:00 2001
From: Alex Branham <[email-masked]>
Date: Sun, 2 Jul 2017 20:43:12 +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 | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index fe31657914..438f635c5e 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."
-  (interactive "r")
-  (eww (buffer-substring beg end)))
+  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)
+  (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)
+          (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