Here are 6 examples. To try them, copy the rest of this message
onto a Emacs buffer. Then move the cursor on the region of any
sample query below.
Example 1.
append([1,2],[3,4], R)
Move the cursor on the expression, then type "C-"
(control key + enter key). The following line
should appear in the buffer.
append([1,2],[3,4], R)['R'=[1,2,3,4]]
Example 2.
first thing
second thing
third thing
Select the region containing all of lines,
type "C-l", and type "eit" in the minibuffer
(without quotes). The region will be replaced with the following:
\begin{itemize}
\item first
\item second
\item third
\end{itemize}
Example 3.
@ pred([X, [X, X]]).
@ pred([X, [X, X]]).
@ pred([X, [X, X]]).
@ pred([X, [X, X]]).
hello
==
==
==
==
Select the region, type "M-" (option key + enter key).
Then 16 lines of hello will be appended to the region.
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
Note that 16 = 2 * 2 * 2 * 2.
Example 4.
elisp:lisp(+(1,2,3), R)
Move the cursor on the expression, type "C-".
Answer will be displayed like this.
elisp:lisp(+(1,2,3), R)['R'=6]
The prolog term +(1,2,3) corresponds the s-expression (+ 1 2 3).
Try following similar queries.
elisp:lisp(+(*(1,2),*(3,4),5), R)
elisp:lisp(car(quote([1,2,3])), R)
elisp:lisp(cdr(quote([1,2,3])), R)
elisp:lisp(append(quote([a,b]), quote([c,d])), R)
elisp:(lisp("\000\\n", R))
The last query will display ['R'="\000\\n"] correctly.
In older version of pac package, this query caused
an wierd error because of null byte ("\000\") appears
in the data. The current version requires no such
restriction.
Example 6.
@ ejockey:trim_white_nl,
pred(([X, []] :-
ejockey:set_working_directory(X))).
~/
==
@ ejockey:handle([list, regex]).
"[^\\.].*"
==
Select the region, and type "M-".
This sample script will display all names of files and directories
being directly under your home directory such that
the name does not start with period(.) .
The key "M-" is bound to a prolog goal (DCG phrase)
handle([eval, markup, text, append])//2,
which is defined in "pack/pac/prolog/pac/emacs-jockey.pl."
The letter @ indicates the starting point of a prolog
phrase as a tag up to fullstop (".\n"). The symbol ==
at the beginning of a line indicates
the end of argument data for the tag (DCG phrase).
These basic construct
"@" --- ".\n" ---- "=="
can be nested. The parser and interpreter for the constructs
is defined in "pac-engin/ml.pl". ('ml' stands for
markup language.)
I will appreciate any information if this post
is useful to run the pac package process on emacs.
Thank you for your interest.
Kuniaki Mukai