From dfb8f81cb0bc5915e2ffb45cd933b018e7f5d37e Mon Sep 17 00:00:00 2001 From: Ivan Kanis Date: Sun, 23 Jun 2013 18:20:03 +0200 Subject: [PATCH 1/3] allow entering keywords for search engine --- emacs/gnus/eww.el | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/emacs/gnus/eww.el b/emacs/gnus/eww.el index ad19758..4fc9fe0 100644 --- a/emacs/gnus/eww.el +++ b/emacs/gnus/eww.el @@ -43,6 +43,11 @@ :group 'eww :type 'string) +(defcustom eww-search-prefix "https://duckduckgo.com/html/?q=" + "Prefix URL to search engine" + :group 'eww + :type 'string) + (defface eww-form-submit '((((type x w32 ns) (class color)) ; Like default mode line :box (:line-width 2 :style released-button) @@ -90,9 +95,13 @@ ;;;###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))) + (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 -- 1.7.1