https://github.com/cmpitg/wand.git
git clone 'git://github.com/cmpitg/wand.git'
Wand is an extension that allows users to select a piece of text and perform actions based on predefined patterns. Wand is inspired by Xiki and Acme editor.
Emacs 23+
Wand depends of cl
library (bundled with Emacs 23+) and
Dash.
Thanks to @yasuyk Wand is available in Melpa.
Installation process is now as simple as M-x package-install RET wand RET
.
It's probably the best to have a look at an example.
wand:execute
is a command (an interactive
function) that takes the current
selection (if selection is active) or a string and performs an action based on
current rules residing in wand:*rules*
. I use this command so frequently
that I bind it to <C-return>
and <C-mouse-1>
.
(require 'wand)
(global-set-key (kbd "<C-return>") 'wand:execute)
(global-set-key (kbd "<C-mouse-1>") 'wand:execute)
(global-set-key (kbd "<C-down-mouse-1>") nil)
Then, I want whenever wand:execute
is called upon a selection of a string
that:
$ command
, command
is executed as a shell command, and
its output is taken back to Emacs as a popup buffer (using
Popwin library),lisp
(wand:add-rule-by-pattern :match "\\$ "
:capture :after
:action popup-shell-command)
http://an-url
or https://a-url
, a-url
is opened in
Firefox with HTTP or HTTPS as its protocol respectively:lisp
(wand:add-rule-by-pattern :match "https?://"
:capture :whole
:action open-url-in-firefox)
file:path-to-a-file
, that corresponding file is open with
Emacs. This is particularly useful when using with
openwith
:lisp
(wand:add-rule-by-pattern :match "file:"
:capture :after
:action find-file)
#> an-emacs-lisp-expression
, brackets are added to that
expression if necessary and it's then evaluated:lisp
(wand:add-rule-by-pattern :match "#> "
:capture :after
:action add-bracket-and-eval)
Comments are skipped when the pattern-matching process is performed. The code is pretty self-explanatory.
Special thanks to:
@yasuyk for making Wand available in Melpa.
@MatthewDarling for correcting code example in README.
@syl20bnr for the issue report.
This project along with its source code and all materials are released under the terms of the GNU General Public License 3.0 (GPLv3). See COPYING for more details.
Copyright (C) 2014 Duong Nguyen