Skip to content

Make searching things from emacs quicker and easier. This package provides a little prompt that opens your desired web browser with your selected search engine.

Notifications You must be signed in to change notification settings

lima-limon-inc/Emacs-Quick-Search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 

Repository files navigation

Quick Search

The purpose of this package is to facilitate searching things on the web directly from Emacs (without needing to resort to eww). You can customize specific search engines for specific modes (and even set engines globally).

Demonstration:

demonstration.mp4

Installation

Simply copy quick-search.el's source code into your init.el. After that, you can add the configuration code.

Configuration

There are 2 function that you need to set up in order to use quick-search

Preferred browser

quick-search/set-preferred-browser configures your browser of choice. It has two arguments:

  1. Your preferred browser's name
  2. Any command line arguments you'd like to pass

Examples:

  • (quick-search/set-preferred-browser "firefox" "")
  • (quick-search/set-preferred-browser "chromium" "--incognito")

Search engines

quick-search/add-search-engine adds a search engine to the search engine list. It has 3 arguments:

  1. The name of the search engine
  2. Search engine link (normally found on the URL of websites after searching for something)
  3. A quoted list of modes you'd like the search engine to be enabled in. Write nil if you'd like to enable it globally. Examples:
  • (quick-search/add-search-engine "Google" "https://google.com/search?q=" nil)
  • (quick-search/add-search-engine "YouTube" "https://www.youtube.com/results?search_query=" '(elisp-mode js-mode rust-mode))
  • (quick-search/add-search-engine "C plus plus" "https://cplusplus.com/search.do?q=" '(c++-mode c-mode))

Usage

Simply call the quick-search function after having it configured (you need to have a selected browser and at least 1 search engine)

Example configuration

; This sets firefox as the default browser with no extra arguments
(quick-search/set-preferred-browser "firefox" "")

; Adds google search engine to be enabled in all the modes
(quick-search/add-search-engine "Google" "https://google.com/search?q=" nil)

; Same thing as above but for Wikipedia
(quick-search/add-search-engine "Wikipedia" "https://en.wikipedia.org/w/index.php?search=" nil)

; Enables the python documentation for Python mode
(quick-search/add-search-engine "Python" "https://docs.python.org/3/search.html?q=" '(python-mode))

; Enables C Plus Plus website for both C and C++ mode
(quick-search/add-search-engine "C plus plus" "https://cplusplus.com/search.do?q=" '(c++-mode c-mode))

; Enables oxford dictionary for "Writing" modes
(quick-search/add-search-engine "Oxford Dictionary" "https://www.oxfordlearnersdictionaries.com/definition/english/" '(org-mode latex-mode LaTeX-mode tex-mode markdown-mode))

; Disable the async shell command window. Source: https://emacs.stackexchange.com/a/58341/39379
(add-to-list 'display-buffer-alist '("*Async Shell Command*" display-buffer-no-window (nil)))

You can even add the function to a keybinding.

(global-set-key "\C-c\C-s" 'quick-search)

evil-leader users can also do the following:

(evil-leader/set-key "s" 'quick-search)

Credits

  • Thanks to @heemayl for the original foundation. Check out their website
  • Thanks to Trey Jackson for this stackoverflow answer. Check out their website. If anyone can find his GitHub profile, please make a PR.
  • Thank you NickD for this stackoverflow answer.

Disclaimer

I am not affiliated with any of the search engines/browsers mentioned. Other options are available

About

Make searching things from emacs quicker and easier. This package provides a little prompt that opens your desired web browser with your selected search engine.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published