The Python integration is at an early stage and may crash or hang emacs when you experiment with it. However as Python is turned off by default it cannot effect the stablity of emacs until enabled.
If you wish to use python with emacs install a Python 2.2 kit. You can get a Windows python kit from www.python.org or www.activestate.com.
Before you can use the Python interface it is neccessary to initiailise Python inside bemacs. Use the Python-console command to initiailise Python.
If you do not have Python 2.2 installed Python-console will report an error.
stdin, stdout and stderr in Python are connect to the Python Console buffer. This means that the output of the Python print command will appear in the console window.
Command | Description |
---|---|
Python-console | enable Python integration. You can execute commands in the Python Console buffer by typing ENTER. |
Python-exec | execute the string parameter in Python. |
Python-eval | evaluate the string paramter in Python and return the result to emacs. |
Python-import | import the named module into Python |
From Python to access emacs use the bemacs module.
import bemacs
The bemacs module implements the following interface:
bemacs interface | Description |
---|---|
bemacs.variable.mlisp_var_name | get or set variables in emacs. To access mlisp variables with hypens in their names use underscore instead. E.g. to access journal-frequency use bemacs.variable.journal_frequency |
bemacs.call_function( mlisp-func-name, arg, arg ) | call the emacs function name mlisp-func-name. |
bemacs.function.mlisp_func_name( arg, arg ) | call emacs function. To access mlisp functions with hypens in their names use underscore instead. E.g. to access forward-character use bemacs.function.forward_character() |
bemacs.buffer | is a python dictionary like object of all the Emacs buffers. The indices of the dictionary can be either an integer index into the of buffers or a string with the name of a buffer. The values of the dictionary are "BEmacs buffer"objects. |
"BEmacs buffer" interface | Description |
---|---|
data | The data of the buffer. Acts like a string. Use slice syntax to access a range of characters.
For example:
|
syntax | The syntax infomation of the buffer. Acts like a list.
Use slice syntax to access a range of syntax information. For example:
|
extent | Returns a tuple of (first-buffer-possion,last-buffer-position) that the user wishs editing to effect. |
file_name | If buffer is a file buffer: the file name this buffer was read from and will be saved to. |
file_permissions | If buffer is a file buffer: the files permission bits |
file_time | If buffer is a file buffer: the files time stamp |
file_synchonise_permissions | If buffer is a file buffer: the files permission bits when last synchonised |
file_synchonise_time | If buffer is a file buffer: the files time stamp when last synchonised |
type | the buffer type. |