mnewt / counsel-web

Search the Web using Ivy
GNU General Public License v3.0
33 stars 2 forks source link

** 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

+ATTR_HTML: :width 800px

[[file: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.

*** Settings

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

+begin_src emacs-lisp

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

+end_src

**** Change the alternate browser

+begin_src emacs-lisp

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

+end_src

**** Change Search Engines DuckDuckGo and Google are built in. DuckDuckGo is the default. Change to Google like this:

 #+begin_src emacs-lisp
 (setq counsel-web-engine 'google)
 #+end_src

 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:

+begin_src emacs-lisp

(setq counsel-web-search-dynamic-update t)

+end_src

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.

    +begin_src emacs-lisp

    (add-to-list 'load-path "/path/to/counsel-web") (require 'counsel-web)

    +end_src

  3. Optionally, create some key bindings.

    +begin_src emacs-lisp

    ;; 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)

    +end_src

** 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 [[https://www.gnu.org/licenses/gpl-3.0.en.html][GNU General Public License 3.0]].