unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alex Branham <branham@utexas.edu>
To: npostavs@users.sourceforge.net
Cc: 27341@debbugs.gnu.org
Subject: bug#27341: updated patch to fix docstring
Date: Tue, 27 Jun 2017 15:23:17 +0200	[thread overview]
Message-ID: <878tkdy37e.fsf@utexas.edu> (raw)
In-Reply-To: <CAAvAa2wpwuakGSMK06p7+0x4Xn54mTtwU1TX-FEhmJZisVpdDw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1880 bytes --]

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@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@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@users.sourceforge.net> wrote:
>
>> Alex Branham <branham@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?
>>


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0004-eww-search-words-prompt-user-for-query-if-region-inactive.patch --]
[-- Type: text/x-diff, Size: 1291 bytes --]

From 685f3d0d2bfea7b3d6aad03d46a247fac25702d0 Mon Sep 17 00:00:00 2001
From: Alex Branham <branham@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


  reply	other threads:[~2017-06-27 13:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-12 11:21 bug#27341: eww-search-words should prompt if region inactive Alex Branham
2017-06-13  9:24 ` bug#27341: updated patch to fix docstring Alex Branham
2017-06-25 14:29   ` npostavs
2017-06-26 14:00     ` Alex Branham
2017-06-26 23:50       ` npostavs
2017-06-27  5:32         ` Alex Branham
2017-06-27 13:23           ` Alex Branham [this message]
2017-06-30  0:54             ` npostavs
2017-06-30  6:25               ` Alex Branham
2017-07-02 18:32             ` npostavs
2017-07-02 18:45               ` Alex Branham
2017-07-02 19:13                 ` npostavs
2017-07-02 19:25                   ` Alex Branham
2017-07-02 20:23                     ` npostavs
2017-06-27 14:40           ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878tkdy37e.fsf@utexas.edu \
    --to=branham@utexas.edu \
    --cc=27341@debbugs.gnu.org \
    --cc=npostavs@users.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).