From 8e573e1eb80b562ebddf0e9153079adaed4d4f91 Mon Sep 17 00:00:00 2001 From: "Antoine R. Dumont" Date: Sat, 11 Jan 2014 19:16:04 +0100 Subject: [PATCH 1/3] Factor the search engine installation to ease the future install of new ones. --- core/prelude-core.el | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/core/prelude-core.el b/core/prelude-core.el index 7ce5060..e40f1f1 100644 --- a/core/prelude-core.el +++ b/core/prelude-core.el @@ -71,21 +71,16 @@ PROMPT sets the `read-string prompt." (buffer-substring (region-beginning) (region-end)) (read-string prompt)))))) -(defun prelude-google () - "Googles a query or region if any." - (interactive) - (prelude-search "http://www.google.com/search?q=" "Google: ")) - -(defun prelude-youtube () - "Search YouTube with a query or region if any." - (interactive) - (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: ")) +(defmacro prelude-install-search-engine (search-engine-name search-engine-url search-engine-prompt) + "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) + (prelude-search ,search-engine-url ,search-engine-prompt))) + +(prelude-install-search-engine "google" "http://www.google.com/search?q=" "Google: ") +(prelude-install-search-engine "youtube" "http://www.youtube.com/results?search_query=" "Search YouTube: ") +(prelude-install-search-engine "github" "https://github.com/search?q=" "Search GitHub: ") (defun prelude-indent-rigidly-and-copy-to-clipboard (begin end arg) "Indent region between BEGIN and END by ARG columns and copy to clipboard." From 7cca7f718e273304627a476f55782cda658dac83 Mon Sep 17 00:00:00 2001 From: "Antoine R. Dumont" Date: Sat, 11 Jan 2014 19:17:59 +0100 Subject: [PATCH 2/3] Add DuckDuckGo search engine in the default list. --- core/prelude-core.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/prelude-core.el b/core/prelude-core.el index e40f1f1..36b14d7 100644 --- a/core/prelude-core.el +++ b/core/prelude-core.el @@ -78,9 +78,10 @@ PROMPT sets the `read-string prompt." (interactive) (prelude-search ,search-engine-url ,search-engine-prompt))) -(prelude-install-search-engine "google" "http://www.google.com/search?q=" "Google: ") -(prelude-install-search-engine "youtube" "http://www.youtube.com/results?search_query=" "Search YouTube: ") -(prelude-install-search-engine "github" "https://github.com/search?q=" "Search GitHub: ") +(prelude-install-search-engine "google" "http://www.google.com/search?q=" "Google: ") +(prelude-install-search-engine "youtube" "http://www.youtube.com/results?search_query=" "Search YouTube: ") +(prelude-install-search-engine "github" "https://github.com/search?q=" "Search GitHub: ") +(prelude-install-search-engine "duckduckgo" "https://duckduckgo.com/?t=lm&q=" "Search DuckDuckGo: ") (defun prelude-indent-rigidly-and-copy-to-clipboard (begin end arg) "Indent region between BEGIN and END by ARG columns and copy to clipboard." From f83428f9f3d44d39fae45d39bb1633785ed75df3 Mon Sep 17 00:00:00 2001 From: "Antoine R. Dumont" Date: Sat, 11 Jan 2014 19:19:59 +0100 Subject: [PATCH 3/3] Add binding `C-c U` for DuckDuckGo search --- core/prelude-core.el | 1 + core/prelude-mode.el | 1 + 2 files changed, 2 insertions(+) diff --git a/core/prelude-core.el b/core/prelude-core.el index 36b14d7..fa630b3 100644 --- a/core/prelude-core.el +++ b/core/prelude-core.el @@ -401,6 +401,7 @@ Doesn't mess with special buffers." "Press to search in Google." "Press to search in GitHub." "Press to search in YouTube." + "Press to search in DuckDuckGo." "Press to rename the current buffer and file it's visiting." "Press to open a terminal in Emacs." "Press to kill all the buffers, but the active one." diff --git a/core/prelude-mode.el b/core/prelude-mode.el index 2258c0a..bd7a2ff 100644 --- a/core/prelude-mode.el +++ b/core/prelude-mode.el @@ -39,6 +39,7 @@ (define-key map (kbd "C-c g") 'prelude-google) (define-key map (kbd "C-c G") 'prelude-github) (define-key map (kbd "C-c y") 'prelude-youtube) + (define-key map (kbd "C-c U") 'prelude-duckduckgo) ;; mimic popular IDEs binding, note that it doesn't work in a terminal session (define-key map [(shift return)] 'prelude-smart-open-line) (define-key map (kbd "M-o") 'prelude-smart-open-line)