os.spawn[*] help

John Hunter jdhunter at ace.bsd.uchicago.edu
Mon Jul 21 17:10:57 EDT 2003


>>>>> "Stephen" == Stephen Boulet <stephen.boulet at motorola.com> writes:

    Stephen> Can someone who understands the os module better than I
    Stephen> offer some insight?  I want to open some text in xemacs
    Stephen> (on Windows) using os.spawn[*], but I want the text to
    Stephen> appear in the current xemacs window, as opposed to
    Stephen> opening a new xemacs window.

    Stephen> Is this doable? Thanks.

Yep, check out emacs-server and emacs client.

http://www-2.cs.cmu.edu/cgi-bin/info2www?(emacs)Emacs%2520Server
http://www-2.cs.cmu.edu/cgi-bin/info2www?(emacs)Invoking%20emacsclient

I have only used this for GNU emacs, but I assume XEmacs has the same
or related functionality.

In a nutshell, from within emacs run the function server-start.

Then, create the text you want to feed to an existing emacs session,
by writing to a temporary file:

  >>> file('somebuffer', 'w').write('Some message\n')

and send it to the emacs server with

  >>> os.system('emacsclient "somebuffer")

This will open the buffer 'somebuffer' in the already running emacs
session with the text 'Some message'

Do you know about pymacs BTW http://www.iro.umontreal.ca/~pinard/pymacs?

John Hunter










More information about the Python-list mailing list