Subject: bug#27341: updated patch to fix docstring

From: Alex Branham <[email-masked]>
Date: Sun, 02 Jul 2017 21:25:56 +0200

On Sun 02 Jul 2017 at 19:13, [email-masked] wrote:

> Alex Branham <[email-masked]> writes:
>
>>> You missed the double spacing before the "Else,".
>>
>> D'oh! Fixed this time, sorry!
>
> Oh, the funny indentation came back, do you have some Emacs setting
> that's doing that?

Ugh. Fixed. I think it has to do with how I'm copy/pasting from my own init file.

>> Ok, now I don't use "r" and just get the region directly. I think that'll do the trick?
>
> Oh yeah, that works.  We should try not to add compiler warnings though:
>
>   ELC      net/eww.elc
>
> In toplevel form:
> ../../emacs-master/lisp/net/eww.el:315:1:Warning: Unused lexical argument
>     ‘end’
> ../../emacs-master/lisp/net/eww.el:315:1:Warning: Unused lexical argument
>     ‘beg’
>
> I think we can just drop the arguments as well, lisp programs can always
> do (eww (buffer-substring BEG END)) instead.

Dropped.

> Do you think the prompt string should be a bit more detailed?  "Query"
> seems a bit vague (e.g., consider if you hit M-s M-w by accident).
> Maybe we should just do (call-interactively 'eww) and then we'll get the
> prompt from there.

Yes, that's much better. Done, thanks.

>From 71e4329943541325f59a224b494e5ca82f07fdef Mon Sep 17 00:00:00 2001
From: Alex Branham <[email-masked]>
Date: Sun, 2 Jul 2017 21:18:47 +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 | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index fe31657914..2fc36e180e 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -312,11 +312,19 @@ word(s) will be searched for via `eww-search-prefix'."
 	       (expand-file-name file))))
 
 ;;;###autoload
-(defun eww-search-words (&optional beg end)
+(defun eww-search-words ()
   "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)
+          (call-interactively 'eww)))
+    (call-interactively 'eww)))
 
 (defun eww-open-in-new-buffer ()
   "Fetch link at point in a new EWW buffer."
-- 
2.13.2