emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 1fd6ca4 1/2: Make eww-search-words prompt for query


From: Noam Postavsky
Subject: [Emacs-diffs] master 1fd6ca4 1/2: Make eww-search-words prompt for query if nothing selected
Date: Sun, 2 Jul 2017 16:20:30 -0400 (EDT)

branch: master
commit 1fd6ca40fd50989b8f82b287c04a5079a051ed09
Author: Alex Branham <address@hidden>
Commit: Noam Postavsky <address@hidden>

    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 fe31657..2fc36e1 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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]