Experimental recognize-action based sed for text in emacs buffer region

#1

I am almost finishing, I hope, amending codes in my pack pac. As a related final note, this is on sed-like functionality for editing text in emacs buffer region. A handle/2 below works for that as expected,
though it is tested only simple cases. A log of a run is attached below.

This handle is based on a simple recognize-action model, which
is simple engough.

Closures are used for the recognize and action as shown in the
example below. Of course, much work remains toward the powerful unix sed, but I should be satisfied with this prototype of integration of pac (= closure) and regex in DCG.

Handle definition for sed in recogniz-action model.

handle([sed | Optional]) --> region,
	    phrase((wl("[^\n]*", Text), wl("\n+"))),
		{	herbrand(_, Text, Term),
			let_sed(Sed, Term)
		},
		call(Sed),
		optional_overwrite(Optional).

Two examples of recognize-action pairs.

1.  wl("[\n\s\t]+") >> ""
%  Delete the filler characters codes.

2. wl("[a-z]+", X) >> pred(X, [["(", X, ")"]])
% Envelope lowercase letter series with the parens.

Before applying 2.

a 12 bc 345 def 67
gh

After Before applying 2.

(a) 12 (bc) 345 (def) 67
(gh)

Kuniaki Mukai