From: Ivan Kanis Date: Sun, 23 Jun 2013 18:22:28 +0000 (+0200) Subject: eww.el: If given a non-domain text, search for the term X-Git-Url: http://git.hcoop.net/bpt/emacs.git/commitdiff_plain/a3ca09b9fa134246fe8f180c12d3ee603696be12 eww.el: If given a non-domain text, search for the term * net/eww.el (eww-search-prefix): New variable. (eww): Use it. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 1c4846e900..521827cb03 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2013-06-23 Ivan Kanis + + * net/eww.el (eww-search-prefix): New variable. + (eww): Use it. + 2013-06-23 Juanma Barranquero * emacs-lisp/tabulated-list.el (tabulated-list-init-header): diff --git a/lisp/net/eww.el b/lisp/net/eww.el index ad19758b4a..eb1b0a2b65 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