Factor the search engine installation to ease the future install of new ones.

This commit is contained in:
Antoine R. Dumont 2014-01-11 19:16:04 +01:00
parent 2c2855841c
commit 8e573e1eb8

View file

@ -71,21 +71,16 @@ PROMPT sets the `read-string prompt."
(buffer-substring (region-beginning) (region-end)) (buffer-substring (region-beginning) (region-end))
(read-string prompt)))))) (read-string prompt))))))
(defun prelude-google () (defmacro prelude-install-search-engine (search-engine-name search-engine-url search-engine-prompt)
"Googles a query or region if any." "Given some information regarding a search engine, install the interactive command to search through them"
`(defun ,(intern (format "prelude-%s" search-engine-name)) ()
,(format "Search %s with a query or region if any." search-engine-name)
(interactive) (interactive)
(prelude-search "http://www.google.com/search?q=" "Google: ")) (prelude-search ,search-engine-url ,search-engine-prompt)))
(defun prelude-youtube () (prelude-install-search-engine "google" "http://www.google.com/search?q=" "Google: ")
"Search YouTube with a query or region if any." (prelude-install-search-engine "youtube" "http://www.youtube.com/results?search_query=" "Search YouTube: ")
(interactive) (prelude-install-search-engine "github" "https://github.com/search?q=" "Search GitHub: ")
(prelude-search "http://www.youtube.com/results?search_query="
"Search YouTube: "))
(defun prelude-github ()
"Search GitHub with a query or region if any."
(interactive)
(prelude-search "https://github.com/search?q=" "Search GitHub: "))
(defun prelude-indent-rigidly-and-copy-to-clipboard (begin end arg) (defun prelude-indent-rigidly-and-copy-to-clipboard (begin end arg)
"Indent region between BEGIN and END by ARG columns and copy to clipboard." "Indent region between BEGIN and END by ARG columns and copy to clipboard."