Skip to content

Arian-D/bang.el

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

Bang.el

DuckDuckGo-style bangs for Emacs

Installation

First, install all-the-icons for pretty icons. Then, use straight.el to install the package.

(use-package bang
  :straight
  (bang :host github :repo "Arian-D/bang.el"))

Usage

Try M-x !, and then go on from there 🙂

Configuration

Adding bangs

All the “bangs” are kept in the !bangs variable. A simple C-h v !bangs would show you the current value, and how it is structured, which is just an alist.

Let’s say you want to add a new bang for JustWatch. It would look something like this

(add-to-list '!bangs
             '("jwh" . ("JustWatch" "https:/justwatch.com/us/search?q=%s")))

You can think of it as a whole list or as nested cons cells. The car is the bang, the cadr is how you refer to the website, and lastly the url with the query slot left as %s which will be passed to format.

That’s it! Next time you try to run M-x ! you will see it as an option.

Default browser

By default, Emacs uses the default browser (duh!). If you want this behavior to change, you can easily modify the browse-url-browser-function variable.

For example, let’s say your default browser is Firefox, but you’d like your search results to be opened in Chrome. You can add this to your config:

(setq browse-url-browser-function #'browse-url-chrome)

Keybindings

This package intends to be non-intrusive, so no keybindings are set by default. A simple example to map it to C-! would be this:

(define-key (current-global-map) (kbd "C-!") #'!)

Another example for evil users leveraging <leader> would be this:

(evil-global-set-key 'normal (kbd "<leader> !") #'!)

Comments and Limitations

  • This is not a clone of DuckDuckGo, meaning this package is not meant to replicate duckduckgo’s behavior within Emacs (though it can). The purpose is to have control over the naming so that it would match your workflow.
  • Completions don’t show up while typing, which is a nice-to-have, but sadly most of these websites don’t have an open API, have rate limiting, and/or require authentication.

IN-PROGRESS [3/7] Todos

  • [ ] Increase the list to include most of the top duckduckgo bangs
  • [ ] Switch to a default search engine
  • [ ] Add a function/macro to create native functions out of each bang
  • [ ] Maybe defgroup?
  • [X] Add the configuration section
  • [X] Add icons to the !bangs list
  • [X] Fix space formatting

About

Bangs for Emacs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published