<HTML> <HEAD> <!-- Created by texi2html 1.56k + clip patches and <A href="http://www.clip.dia.fi.upm.es/Software">lpdoc</A> from ciao.texi on 28 January 2007 --> <LINK rel="stylesheet" href="ciao.css" type="text/css"> <TITLE>The Ciao Prolog System - Calling emacs from Prolog</TITLE> </HEAD> <BODY> Go to the <A HREF="ciao_1.html">first</A>, <A HREF="ciao_160.html">previous</A>, <A HREF="ciao_162.html">next</A>, <A HREF="ciao_241.html">last</A> section, <A HREF="ciao_toc.html">table of contents</A>. <P><HR><P> <H1><A NAME="SEC676" HREF="ciao_toc.html#TOC676">Calling emacs from Prolog</A></H1> <P> <A NAME="IDX7631"></A> <P> <STRONG>Author(s):</STRONG> The CLIP Group. <P> <STRONG>Version:</STRONG> 1.10#7 (2006/4/26, 19:22:13 CEST) <P> <STRONG>Version of last change:</STRONG> 1.9#234 (2003/12/22, 18:14:10 CET) <P> This library provides a <A NAME="IDX7632"></A> <A NAME="IDX7633"></A> <EM>prolog-emacs interface</EM>. This interface is complementary to (and independent from) the <A NAME="IDX7634"></A> emacs mode, which is used to develop programs from within the <A NAME="IDX7635"></A> <CODE>emacs</CODE> editor/environment. Instead, this library allows calling <A NAME="IDX7636"></A> <CODE>emacs</CODE> from a running Prolog program. This facilitates the use of <A NAME="IDX7637"></A> <CODE>emacs</CODE> as a "user interface" for a Prolog program. Emacs can be made to: <UL> <LI>Visit a file, which can then be edited. <LI>Execute arbitrary <A NAME="IDX7638"></A> <A NAME="IDX7639"></A> <EM>emacs lisp</EM> code, sent from Prolog. </UL> <P> In order for this library to work correctly, the following is needed: <UL> <LI>You should be running the <A NAME="IDX7640"></A> <CODE>emacs</CODE> editor on the same machine where the executable calling this library is executing. <LI>This <A NAME="IDX7641"></A> <CODE>emacs</CODE> should be running the <A NAME="IDX7642"></A> <A NAME="IDX7643"></A> <EM>emacs server</EM>. This can be done by including the following line in your <A NAME="IDX7644"></A> <CODE>.emacs</CODE> file: <PRE> ;; Start a server that emacsclient can connect to. (server-start) </PRE> Or typing <CODE>M-x server-start</CODE> within <A NAME="IDX7645"></A> <CODE>emacs</CODE>. </UL> <P> This suffices for using <A NAME="IDX7646"></A> <CODE>emacs</CODE> to edit files. For running arbitrary code the following also needs to be added to the <A NAME="IDX7647"></A> <CODE>.emacs</CODE> file: <DL COMPACT> <DT><CODE>(setq enable-local-eval t)</CODE> <DD> Allows executing lisp code without asking. <DT><CODE>(setq enable-local-eval nil)</CODE> <DD> Does not allow executing lisp code without asking. <DT><CODE>(setq enable-local-eval 'maybe)</CODE> <DD> Allows executing lisp code only if user agrees after asking (asks interactively for every invocation). </DL> <P> <STRONG>Examples:</STRONG> <P> Assuming that a <CODE>.pl</CODE> file loads this library, then: <DL COMPACT> <DT><CODE>..., emacs_edit('foo'), ...</CODE> <DD> Opens file <CODE>foo</CODE> for editing in <A NAME="IDX7648"></A> <CODE>emacs</CODE>. <DT><CODE>..., emacs_eval_nowait("(run-ciao-toplevel)"), ...</CODE> <DD> Starts execution of a Ciao top-level within <A NAME="IDX7649"></A> <CODE>emacs</CODE>. </DL> <UL> <LI><A HREF="ciao_161.html#SEC677">Usage and interface (emacs)</A> <LI><A HREF="ciao_161.html#SEC678">Documentation on exports (emacs)</A> </UL> <H2><A NAME="SEC677" HREF="ciao_toc.html#TOC677">Usage and interface (<CODE>emacs</CODE>)</A></H2> <div class="cartouche"> <UL> <LI><STRONG>Library usage:</STRONG> <CODE>:- use_module(library(emacs)).</CODE> <LI><STRONG>Exports:</STRONG> <UL> <LI><EM>Predicates:</EM> <A NAME="IDX7650"></A> <CODE>emacs_edit/1</CODE>, <A NAME="IDX7651"></A> <CODE>emacs_edit_nowait/1</CODE>, <A NAME="IDX7652"></A> <CODE>emacs_eval/1</CODE>, <A NAME="IDX7653"></A> <CODE>emacs_eval_nowait/1</CODE>. <LI><EM>Regular Types:</EM> <A NAME="IDX7654"></A> <CODE>elisp_string/1</CODE>. </UL> <LI><STRONG>Other modules used:</STRONG> <UL> <LI><EM>System library modules:</EM> <A NAME="IDX7655"></A> <CODE>terms_check</CODE>, <A NAME="IDX7656"></A> <CODE>lists</CODE>, <A NAME="IDX7657"></A> <CODE>terms</CODE>, <A NAME="IDX7658"></A> <CODE>system</CODE>. </UL> </UL> </div class="cartouche"> <H2><A NAME="SEC678" HREF="ciao_toc.html#TOC678">Documentation on exports (<CODE>emacs</CODE>)</A></H2> <P> <A NAME="IDX7659"></A> <A NAME="IDX7660"></A> <DL> <DT><span class="define">PREDICATE:</span> <B>emacs_edit/1:</B> <DD><A NAME="IDX7661"></A> <P> <STRONG>Usage:</STRONG> <CODE>emacs_edit(+filename)</CODE> <UL> <LI><EM>Description:</EM> Opens the given file for editing in <A NAME="IDX7662"></A> <CODE>emacs</CODE>. Waits for editing to finish before continuing. </UL> </DL> <P> <A NAME="IDX7663"></A> <A NAME="IDX7664"></A> <DL> <DT><span class="define">PREDICATE:</span> <B>emacs_edit_nowait/1:</B> <DD><A NAME="IDX7665"></A> <P> <STRONG>Usage:</STRONG> <CODE>emacs_edit_nowait(+filename)</CODE> <UL> <LI><EM>Description:</EM> Opens the given file for editing in <A NAME="IDX7666"></A> <CODE>emacs</CODE> and continues without waiting for editing to finish. </UL> </DL> <P> <A NAME="IDX7667"></A> <A NAME="IDX7668"></A> <DL> <DT><span class="define">PREDICATE:</span> <B>emacs_eval/1:</B> <DD><A NAME="IDX7669"></A> <P> <STRONG>Usage:</STRONG> <CODE>emacs_eval(+elisp_string)</CODE> <UL> <LI><EM>Description:</EM> Executes in emacs the lisp code given as argument. Waits for the command to finish before continuing. </UL> </DL> <P> <A NAME="IDX7670"></A> <A NAME="IDX7671"></A> <DL> <DT><span class="define">PREDICATE:</span> <B>emacs_eval_nowait/1:</B> <DD><A NAME="IDX7672"></A> <P> <STRONG>Usage:</STRONG> <CODE>emacs_eval_nowait(+elisp_string)</CODE> <UL> <LI><EM>Description:</EM> Executes in emacs the lisp code given as argument and continues without waiting for it to finish. </UL> </DL> <P> <A NAME="IDX7673"></A> <A NAME="IDX7674"></A> <DL> <DT><span class="define">REGTYPE:</span> <B>elisp_string/1:</B> <DD><A NAME="IDX7675"></A> <P> <STRONG>Usage:</STRONG> <CODE>elisp_string(L)</CODE> <UL> <LI><EM>Description:</EM> <CODE>L</CODE> is a string containing <A NAME="IDX7676"></A> <CODE>emacs</CODE> lisp code. </UL> </DL> <P><HR><P> Go to the <A HREF="ciao_1.html">first</A>, <A HREF="ciao_160.html">previous</A>, <A HREF="ciao_162.html">next</A>, <A HREF="ciao_241.html">last</A> section, <A HREF="ciao_toc.html">table of contents</A>. </BODY> </HTML>