wand

https://github.com/cmpitg/wand.git

git clone 'git://github.com/cmpitg/wand.git'
13

Wand

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.

Requirements

Installation

Thanks to @yasuyk Wand is available in Melpa. Installation process is now as simple as M-x package-install RET wand RET.

Usage

Example

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:

lisp (wand:add-rule-by-pattern :match "\\$ " :capture :after :action popup-shell-command)

lisp (wand:add-rule-by-pattern :match "https?://" :capture :whole :action open-url-in-firefox)

lisp (wand:add-rule-by-pattern :match "file:" :capture :after :action find-file)

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.

Thanks

Special thanks to:

License

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