Entry
Can I script or access the internal of (X)Emacs with Python?
Nov 30th, 2004 10:28
Chris Burkhardt, Joe Bloggs, Alain Tesio, Alastair Burt, Shae Erisson,
If this question means "Can I use Python instead of Emacs Lisp to add
extra modules to Emacs?", have a look at PyMacs :
http://www.emacswiki.org/cgi-bin/wiki.pl?PyMacs
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'