Python/XEmacs scripting (was Re: [FAQTS] Python Knowledge Base Update -- August 9th, 2000)

Fiona Czuczman fiona at sitegnome.com
Thu Aug 10 20:11:34 EDT 2000


Hi Charles,

In the "Python Knowledge Base Update -- August 10th, 2000" this question
was answered by Alastair Burt, who wrote:

-----------

If this question means "Can I use Python instead of Emacs Lisp to add
extra modules to Emacs?", I am afraid you are out of luck.

If this question means "Can a running Python process control a running 
Emacs process?", then you probably want to use gnuserv.  This comes
standard with XEmacs. I do not know about the other Emacs.  You need to
get (X)Emacs to call the Elisp function "gnuserv-start", and then access

this process through the "gnuclient" program.  Here is an example:

 $ xemacs -f gnuserv-start &
 [1] 15069
 $ python
 Python 1.5.2 (#4, Feb  3 2000, 16:21:22)  [GCC 2.8.1] on sunos5
 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
 >>> import commands
 >>> commands.getoutput('gnuclient -batch -eval "(+ 1 1)"')
 '2'

----------

Cheers,

Fiona

Charles G Waldman wrote:
> 
> Fiona Czuczman <fiona at sitegnome.com> writes:
> 
> > -------------------------------------------------------------
> > Can I script or access the internal of (X)Emacs with Python?
> > http://www.faqts.com/knowledge-base/view.phtml/aid/5254
> > -------------------------------------------------------------
> > Shae Erisson
> 
> This is a great question.  You can use gnuclient/gnuserv to get a
> running XEmacs session to evaluate arbitrary Elisp forms; however I
> haven't been able to figure out exactly how to get the return values
> sent back to Python - the output wants to go into XEmacs's message
> area.  Gnuclient doesn't seem to be able to say "evaluate this form
> and return the expression to me".  (Maybe this can be done, I just
> don't know how).
> 
> There's a somewhat experimental feature in newer (maybe beta-only?)
> version of XEmacs which allow runtime loading of 'modules' in the form
> of shared object files.  One could conceivably write such a module for
> interfacing with Python - one could even embed a Python interpreter
> into XEmacs.  This to me sounds like a really fun project.

-- 

Site Gnome - site maintenance, documentation and proof reading

http://www.sitegnome.com



More information about the Python-list mailing list