Created
November 11, 2011 19:11
-
-
Save jl2/1358912 to your computer and use it in GitHub Desktop.
Emacs Lisp to search for the current region on DuckDuckGo. To use, type \C-\M-g and enter a bang command or just press enter to search plain duckduckgo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(global-set-key "\C-\M-g" 'ddg-bang-search) | |
(defun ddg-bang-search (bang) | |
(interactive "s!") | |
(let* ((search-query (replace-regexp-in-string " " "+" (buffer-substring-no-properties (region-beginning) (region-end)))) | |
(search-string (if (> (length bang) 0) | |
(concat "!" bang "+" search-query) | |
search-query))) | |
(browse-url (concat "http://duckduckgo.com/?ka=h&kh=1&kj=b2&km=m&ko=1&ks=n&kt=h&ku=-1&kv=1&kw=s&kx=e&ky=b&k1=-1&q=" search-string)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment