Skip to content

mnewt/counsel-web

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

counsel-web – Dynamic web search and suggestions with ivy

Description

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:

  1. counsel-web-suggest prompts for a search string, displays dynamic suggestions, and passes the chosen suggestion to:
  2. counsel-web-search, which takes a search string and browses a search candidate.

Demo

counsel-web-demo.gif

Usage

Suggestions

counsel-web-suggest shows search suggestions as you type. Press RET to accept the suggestion and send it to counsel-web-search.

Search

counsel-web-search searches and presents the results in the ivy minibuffer.

  • Press RET to browse to the selected result.
  • Type a new search and press C-j to update the search.
  • Press C-M-j (ivy-alternate-action) to choose a secondary action.
  • Press M-o to choose from a menu of alternate actions.

Settings

Change the default browser

To open the selected result in the operating system browser instead of Emacs:

(setq counsel-web-search-action #'browse-url)

Change the alternate browser

(setq counsel-web-search-alternate-action #'w3m)

Change Search Engines

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.

Update search results with each keystroke

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.

Installation

  1. Install counsel version 0.13.0 or later.
  2. Clone this repository, add it to load-path, and require it.
(add-to-list 'load-path "/path/to/counsel-web")
(require 'counsel-web)
  1. 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)

Similar Projects

counsel-search in counsel itself

counsel-search is very similar to counsel-web-suggest. However, counsel currently does not provide an equivalent to counsel-web-search.

Google this

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.

Engine-mode

https://github.com/hrs/engine-mode Engine-mode sends a search to the browser, it doesn’t parse the search and results in Emacs.

Helm-google

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.

License

counsel-web is released under the GNU General Public License 3.0.

About

Search the Web using Ivy

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published