GNU bug report logs - #27341
eww-search-words should prompt if region inactive

Previous Next

Package: emacs;

Reported by: Alex Branham <branham <at> utexas.edu>

Date: Mon, 12 Jun 2017 11:22:02 UTC

Severity: minor

Tags: fixed, patch

Fixed in version 26.1

Done: npostavs <at> users.sourceforge.net

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Alex Branham <branham <at> utexas.edu>
To: npostavs <at> users.sourceforge.net
Cc: 27341 <at> debbugs.gnu.org
Subject: bug#27341: updated patch to fix docstring
Date: Tue, 27 Jun 2017 15:23:17 +0200
[Message part 1 (text/plain, inline)]
Actually, we need to check (use-region-p) anyway in case the mark hasn't been activated yet in the buffer:


From 685f3d0d2bfea7b3d6aad03d46a247fac25702d0 Mon Sep 17 00:00:00 2001
From: Alex Branham <branham <at> utexas.edu>
Date: Tue, 27 Jun 2017 15:20:27 +0200
Subject: [PATCH] eww-search-words prompt for query if region inactive or blank

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

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

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



On Tue 27 Jun 2017 at 05:32, Alex Branham <branham <at> utexas.edu> wrote:

> No, I haven't. Do I need to for something this small? Happy to do so if
> it's necessary.
>
> Alex
>
> On Jun 27, 2017 1:49 AM, <npostavs <at> users.sourceforge.net> wrote:
>
>> Alex Branham <branham <at> utexas.edu> writes:
>>
>> > Here's a new patch that checks the region directly, ignoring
>> `use-empty-active-region'.
>>
>> Looks good, I'll push in a few days.  You haven't assigned copyright,
>> have you?
>>

[0004-eww-search-words-prompt-user-for-query-if-region-inactive.patch (text/x-diff, attachment)]

This bug report was last modified 8 years and 20 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.