Search the web with dynamic suggestions and browse the results – all from the comfort of Emacs and ivy.
The main idea in counsel-web is to not have to browse search results in a browser–instead go directly to the page you were searching for. It accomplishes that in two steps:
counsel-web-suggestprompts for a search string, displays dynamic suggestions, and passes the chosen suggestion to:counsel-web-search, which takes a search string and browses a search candidate.
counsel-web-suggest shows search suggestions as you type. Press RET to accept the suggestion and send it to counsel-web-search.
counsel-web-search searches and presents the results in the ivy minibuffer.
- Press
RETto browse to the selected result. - Type a new search and press
C-jto update the search. - Press
C-M-j(ivy-alternate-action) to choose a secondary action. - Press
M-oto choose from a menu of alternate actions.
To open the selected result in the operating system browser instead of Emacs:
(setq counsel-web-search-action #'browse-url)(setq counsel-web-search-alternate-action #'w3m)DuckDuckGo and Google are built in. DuckDuckGo is the default. Change to Google like this:
(setq counsel-web-engine 'google)See counsel-web-engine-alist to learn how to add more search engines.
Experimental! To update the search (not suggestions–the actual search results) with each key press:
(setq counsel-web-search-dynamic-update t)Note that dynamic updates can sometimes lead the search engine to temporarily block requests if it decides Emacs is a running a search robot. This seems to be a bigger problem with DuckDuckGo than with Google. Suggestions regarding how to fix this are welcome.
- Install
counselversion0.13.0or later. - Clone this repository, add it to
load-path, andrequireit.
(add-to-list 'load-path "/path/to/counsel-web")
(require 'counsel-web)- Optionally, create some key bindings.
;; Define "C-c w" as a prefix key.
(defvar counsel-web-map
(let ((map (make-sparse-keymap "counsel-web")))
(define-key map (kbd "w") #'counsel-web-suggest)
(define-key map (kbd "s") #'counsel-web-search)
(define-key map (kbd ".") #'counsel-web-thing-at-point)
map))
(global-set-key (kbd "C-c w") counsel-web-map)counsel-search is very similar to counsel-web-suggest. However, counsel currently does not provide an equivalent to counsel-web-search.
https://github.com/Malabarba/emacs-google-this
Google this searches Google for things under point, somewhat similar to counsel-web-thing-at-point. However, it does not have equivalent functions to counsel-web-suggest or counsel-web-search.
https://github.com/hrs/engine-mode Engine-mode sends a search to the browser, it doesn’t parse the search and results in Emacs.
https://framagit.org/steckerhalter/helm-google
The most similar, it displays search results in the helm buffer like counse-web does in the ivy minibuffer.
counsel-web is released under the GNU General Public License 3.0.