summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/net/eww.el21
2 files changed, 22 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1c4846e9002..521827cb03c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2013-06-23 Ivan Kanis <ivan@kanis.fr>
+
+ * net/eww.el (eww-search-prefix): New variable.
+ (eww): Use it.
+
2013-06-23 Juanma Barranquero <lekktu@gmail.com>
* emacs-lisp/tabulated-list.el (tabulated-list-init-header):
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index ad19758b4a6..eb1b0a2b659 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -40,6 +40,13 @@
"Header line format.
- %t is replaced by the title.
- %u is replaced by the URL."
+ :version "24.4"
+ :group 'eww
+ :type 'string)
+
+(defcustom eww-search-prefix "https://duckduckgo.com/html/?q="
+ "Prefix URL to search engine"
+ :version "24.4"
:group 'eww
:type 'string)
@@ -89,10 +96,16 @@
;;;###autoload
(defun eww (url)
- "Fetch URL and render the page."
- (interactive "sUrl: ")
- (unless (string-match-p "\\`[a-zA-Z][-a-zA-Z0-9+.]*://" url)
- (setq url (concat "http://" url)))
+ "Fetch URL and render the page.
+If the input doesn't look like an URL or a domain name, the
+word(s) will be searched for via `eww-search-prefix'."
+ (interactive "sEnter URL or keywords: ")
+ (if (and (= (length (split-string url)) 1)
+ (> (length (split-string url "\\.")) 1))
+ (unless (string-match-p "\\`[a-zA-Z][-a-zA-Z0-9+.]*://" url)
+ (setq url (concat "http://" url)))
+ (setq url (concat eww-search-prefix
+ (replace-regexp-in-string " " "+" url))))
(url-retrieve url 'eww-render (list url)))
;;;###autoload