]> git.bundesbrandschatzamt.de Git - emacsconfig.git/commitdiff
search the web with engine-mode.
authorAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Tue, 5 May 2015 19:04:53 +0000 (21:04 +0200)
committerAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Tue, 5 May 2015 19:04:53 +0000 (21:04 +0200)
Signed-off-by: Andreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
bba.org
elpa/engine-mode-20150323.2148/engine-mode-autoloads.el [new file with mode: 0644]
elpa/engine-mode-20150323.2148/engine-mode-pkg.el [new file with mode: 0644]
elpa/engine-mode-20150323.2148/engine-mode.el [new file with mode: 0644]
elpa/engine-mode-readme.txt [new file with mode: 0644]

diff --git a/bba.org b/bba.org
index 82231af72cbd1081c64558986a4505f7f4aed1f1..70678ec602b482d5543ff9aec8935a6e65213108 100644 (file)
--- a/bba.org
+++ b/bba.org
@@ -157,6 +157,49 @@ See [[https://github.com/toctan/smartparens][Smartparens on github]].
         (smartparens-global-mode 1)
         ))
 #+END_SRC
+*** [[https://github.com/hrs/engine-mode][engine-mode]]
+
+search the web on your fingertips. C-c /.
+
+|---+-------------|
+| a | amazon.de   |
+| b | bing        |
+| m | google maps |
+| w | wikipedia   |
+| y | youtube     |
+|---+-------------|
+
+
+#+BEGIN_SRC emacs-lisp
+  (require 'engine-mode)
+
+  (defengine amazon
+    "http://www.amazon.de/s/ref=nb_sb_noss?url=search-alias%3Daps&filed-keywords=%s"
+    "a"
+    )
+
+  (defengine bing
+    "http://www.bing.com/search?q=%s&qs=bs&form=QBLH"
+    "b"
+    )
+
+  (defengine google-maps
+    "http://maps.google.com/maps?q=%s"
+    "m"
+    )
+
+  (defengine wikipedia
+    "http://www.wikipedia.org/search-redirect.php?language=en&go=Go&search=%s"
+    "w"
+    )
+
+  (defengine youtube
+    "http://www.youtube.com/results?aq=f&oq=&search_query=%s"
+    "y"
+    )
+  (engine-mode 1)
+#+END_SRC
+
 *** expand-region
     [2015-04-02 Thu 10:32]
 
@@ -1363,6 +1406,7 @@ combine key strokes to access commands even faster.
   (define-prefix-command 'bba/toggle)
   (define-key global-map "\C-ct" 'bba/toggle)
 
+  (define-key bba/toggle "a" 'artbollocks-mode)
   (define-key bba/toggle "f" 'auto-fill-mode)
   (define-key bba/toggle "i" 'impatient-mode)
   (define-key bba/toggle "p" 'smartparens-mode)
diff --git a/elpa/engine-mode-20150323.2148/engine-mode-autoloads.el b/elpa/engine-mode-20150323.2148/engine-mode-autoloads.el
new file mode 100644 (file)
index 0000000..ac95c9e
--- /dev/null
@@ -0,0 +1,18 @@
+;;; engine-mode-autoloads.el --- automatically extracted autoloads
+;;
+;;; Code:
+
+\f
+;;;### (autoloads nil nil ("engine-mode-pkg.el" "engine-mode.el")
+;;;;;;  (21833 2755 502002 0))
+
+;;;***
+\f
+(provide 'engine-mode-autoloads)
+;; Local Variables:
+;; version-control: never
+;; no-byte-compile: t
+;; no-update-autoloads: t
+;; coding: utf-8
+;; End:
+;;; engine-mode-autoloads.el ends here
diff --git a/elpa/engine-mode-20150323.2148/engine-mode-pkg.el b/elpa/engine-mode-20150323.2148/engine-mode-pkg.el
new file mode 100644 (file)
index 0000000..fd5f1b1
--- /dev/null
@@ -0,0 +1 @@
+(define-package "engine-mode" "20150323.2148" "Define and query search engines from within Emacs." (quote nil))
diff --git a/elpa/engine-mode-20150323.2148/engine-mode.el b/elpa/engine-mode-20150323.2148/engine-mode.el
new file mode 100644 (file)
index 0000000..12be4a7
--- /dev/null
@@ -0,0 +1,132 @@
+;;; engine-mode.el --- Define and query search engines from within Emacs.
+
+;; Author: Harry R. Schwartz <helloNOSPAMharryrschwartz.com>
+;; Version: 2015.02.07
+;; Package-Version: 20150323.2148
+;; URL: https://github.com/hrs/engine-mode/engine-mode.el
+
+;; This file is NOT part of GNU Emacs.
+
+;;; Commentary:
+
+;; `engine-mode' is a global minor mode for Emacs. It enables you to
+;; easily define search engines, bind them to keybindings, and query
+;; them from the comfort of your editor.
+
+;; For example, suppose we want to be able to easily search GitHub:
+
+;; (defengine github
+;;   "https://github.com/search?ref=simplesearch&q=%s")
+
+;; This defines an interactive function `engine/search-github'. When
+;; executed it will take the selected region (or prompt for input, if
+;; no region is selected) and search GitHub for it, displaying the
+;; results in your default browser.
+
+;; The `defengine' macro can also take an optional key combination,
+;; prefixed with `engine/keymap-prefix' (which defaults to "C-c /"):
+
+;; (defengine duckduckgo
+;;   "https://duckduckgo.com/?q=%s"
+;;   "d")
+
+;; `C-c / d' is now bound to the new function
+;; engine/search-duckduckgo'! Nifty.
+
+;;; License:
+
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Code:
+(eval-when-compile (require 'cl))
+
+(define-minor-mode engine-mode
+  "Minor mode for defining and querying search engines through Emacs.
+
+\\{engine-mode-map}"
+  :global t
+  :keymap (make-sparse-keymap))
+
+(defcustom engine/keymap-prefix (kbd "C-c /")
+  "Engine-mode keymap prefix."
+  :group 'engine-mode
+  :type 'string)
+
+(defun engine/search-prompt (engine-name)
+  (concat "Search " (capitalize engine-name) ": "))
+
+(defun engine/prompted-search-term (engine-name)
+  (read-string (engine/search-prompt engine-name) (thing-at-point 'symbol)))
+
+(defun engine/get-query (engine-name)
+  "Return the selected region (if any) or prompt the user for a query."
+  (if (use-region-p)
+      (buffer-substring (region-beginning) (region-end))
+    (engine/prompted-search-term engine-name)))
+
+(defun engine/execute-search (search-engine-url search-term)
+  "Display the results of the query."
+  (interactive)
+  (browse-url
+   (format search-engine-url
+           (url-hexify-string search-term))))
+
+(defun engine/function-name (engine-name)
+  (intern (concat "engine/search-" (downcase (symbol-name engine-name)))))
+
+(defun engine/docstring (engine-name)
+  (concat "Search "
+          (capitalize (symbol-name engine-name))
+          " for the selected text. Prompt for input if none is selected."))
+
+(defun engine/scope-keybinding (keybinding)
+  (concat engine/keymap-prefix " " keybinding))
+
+(defun engine/bind-key (engine-name keybinding)
+  (when keybinding
+    `(define-key engine-mode-map (kbd ,(engine/scope-keybinding keybinding))
+       (quote ,(engine/function-name engine-name)))))
+
+(defmacro defengine (engine-name search-engine-url &optional keybinding)
+  "Define a custom search engine.
+
+`engine-name' is a symbol naming the engine.
+`search-engine-url' is the url to be queried, with a \"%s\"
+standing in for the search term.
+The optional value `keybinding' is a string describing the key to
+bind the new function.
+
+Keybindings are prefixed by the `engine/keymap-prefix', which
+defaults to `C-c /'.
+
+For example, to search Wikipedia, use:
+
+  (defengine wikipedia
+    \"http://www.wikipedia.org/search-redirect.php?language=en&go=Go&search=%s\"
+    \"w\")
+
+Hitting \"C-c / w\" will be bound to the newly-defined
+`engine/search-wikipedia' function."
+
+  (assert (symbolp engine-name))
+  `(prog1
+     (defun ,(engine/function-name engine-name) (search-term)
+       ,(engine/docstring engine-name)
+       (interactive
+        (list (engine/get-query ,(symbol-name engine-name))))
+       (engine/execute-search ,search-engine-url search-term))
+     ,(engine/bind-key engine-name keybinding)))
+
+(provide 'engine-mode)
+;;; engine-mode.el ends here
diff --git a/elpa/engine-mode-readme.txt b/elpa/engine-mode-readme.txt
new file mode 100644 (file)
index 0000000..ca2982b
--- /dev/null
@@ -0,0 +1,23 @@
+`engine-mode' is a global minor mode for Emacs. It enables you to
+easily define search engines, bind them to keybindings, and query
+them from the comfort of your editor.
+
+For example, suppose we want to be able to easily search GitHub:
+
+(defengine github
+  "https://github.com/search?ref=simplesearch&q=%s")
+
+This defines an interactive function `engine/search-github'. When
+executed it will take the selected region (or prompt for input, if
+no region is selected) and search GitHub for it, displaying the
+results in your default browser.
+
+The `defengine' macro can also take an optional key combination,
+prefixed with `engine/keymap-prefix' (which defaults to "C-c /"):
+
+(defengine duckduckgo
+  "https://duckduckgo.com/?q=%s"
+  "d")
+
+`C-c / d' is now bound to the new function
+engine/search-duckduckgo'! Nifty.