tools/lookup: add autocompletion for google/duckduckgo providers

For +lookup/online, on `SPC s o`

- Change the signature of `+lookup/online`
- Change format of +lookup-provider-url-alist.
This commit is contained in:
Henrik Lissner 2019-12-15 17:59:20 -05:00
parent c522ca4fc0
commit dfb5a0cc54
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
3 changed files with 47 additions and 40 deletions

View file

@ -13,21 +13,26 @@
;; `dumb-jump' to find what you want.
(defvar +lookup-provider-url-alist
(append '(("Google" . "https://google.com/search?q=%s")
("Google images" . "https://www.google.com/images?q=%s")
("Google maps" . "https://maps.google.com/maps?q=%s")
("Project Gutenberg" . "http://www.gutenberg.org/ebooks/search/?query=%s")
("DuckDuckGo" . "https://duckduckgo.com/?q=%s")
("DevDocs.io" . "https://devdocs.io/#q=%s")
("StackOverflow" . "https://stackoverflow.com/search?q=%s")
("Github" . "https://github.com/search?ref=simplesearch&q=%s")
("Youtube" . "https://youtube.com/results?aq=f&oq=&search_query=%s")
("Wolfram alpha" . "https://wolframalpha.com/input/?i=%s")
("Wikipedia" . "https://wikipedia.org/search-redirect.php?language=en&go=Go&search=%s"))
(append '(("Google" counsel-search helm-google "https://google.com/search?q=%s")
("Google images" "https://www.google.com/images?q=%s")
("Google maps" "https://maps.google.com/maps?q=%s")
("Project Gutenberg" "http://www.gutenberg.org/ebooks/search/?query=%s")
("DuckDuckGo" counsel-search "https://duckduckgo.com/?q=%s")
("DevDocs.io" "https://devdocs.io/#q=%s")
("StackOverflow" "https://stackoverflow.com/search?q=%s")
("Github" "https://github.com/search?ref=simplesearch&q=%s")
("Youtube" "https://youtube.com/results?aq=f&oq=&search_query=%s")
("Wolfram alpha" "https://wolframalpha.com/input/?i=%s")
("Wikipedia" "https://wikipedia.org/search-redirect.php?language=en&go=Go&search=%s"))
(when (featurep! :lang rust)
'(("Rust Docs" . "https://doc.rust-lang.org/edition-guide/?search=%s"))))
"An alist that maps online resources to their search url or a function that
produces an url. Used by `+lookup/online'.")
'(("Rust Docs" "https://doc.rust-lang.org/edition-guide/?search=%s"))))
"An alist that maps online resources to either:
1. A search url (needs on '%s' to substitute with an url encoded query),
2. A non-interactive function that returns the search url in #1,
3. An interactive command that does its own search for that provider.
Used by `+lookup/online'.")
(defvar +lookup-open-url-fn #'browse-url
"Function to use to open search urls.")