aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Kanis2013-06-23 20:22:28 +0200
committerLars Magne Ingebrigtsen2013-06-23 20:22:28 +0200
commita3ca09b9fa134246fe8f180c12d3ee603696be12 (patch)
treeed5ccfab5889e72f851d85717f825c0f20ba837c
parentc7041908b82205af2f812f9de782003d975f53da (diff)
downloademacs-a3ca09b9fa134246fe8f180c12d3ee603696be12.tar.gz
emacs-a3ca09b9fa134246fe8f180c12d3ee603696be12.zip
eww.el: If given a non-domain text, search for the term
* net/eww.el (eww-search-prefix): New variable. (eww): Use it.
-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 @@
12013-06-23 Ivan Kanis <ivan@kanis.fr>
2
3 * net/eww.el (eww-search-prefix): New variable.
4 (eww): Use it.
5
12013-06-23 Juanma Barranquero <lekktu@gmail.com> 62013-06-23 Juanma Barranquero <lekktu@gmail.com>
2 7
3 * emacs-lisp/tabulated-list.el (tabulated-list-init-header): 8 * 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 @@
40 "Header line format. 40 "Header line format.
41- %t is replaced by the title. 41- %t is replaced by the title.
42- %u is replaced by the URL." 42- %u is replaced by the URL."
43 :version "24.4"
44 :group 'eww
45 :type 'string)
46
47(defcustom eww-search-prefix "https://duckduckgo.com/html/?q="
48 "Prefix URL to search engine"
49 :version "24.4"
43 :group 'eww 50 :group 'eww
44 :type 'string) 51 :type 'string)
45 52
@@ -89,10 +96,16 @@
89 96
90;;;###autoload 97;;;###autoload
91(defun eww (url) 98(defun eww (url)
92 "Fetch URL and render the page." 99 "Fetch URL and render the page.
93 (interactive "sUrl: ") 100If the input doesn't look like an URL or a domain name, the
94 (unless (string-match-p "\\`[a-zA-Z][-a-zA-Z0-9+.]*://" url) 101word(s) will be searched for via `eww-search-prefix'."
95 (setq url (concat "http://" url))) 102 (interactive "sEnter URL or keywords: ")
103 (if (and (= (length (split-string url)) 1)
104 (> (length (split-string url "\\.")) 1))
105 (unless (string-match-p "\\`[a-zA-Z][-a-zA-Z0-9+.]*://" url)
106 (setq url (concat "http://" url)))
107 (setq url (concat eww-search-prefix
108 (replace-regexp-in-string " " "+" url))))
96 (url-retrieve url 'eww-render (list url))) 109 (url-retrieve url 'eww-render (list url)))
97 110
98;;;###autoload 111;;;###autoload