pymacs! :-)

Paul Winkler slinkp23 at yahoo.com
Fri Sep 7 17:22:12 EDT 2001


On 06 Sep 2001 11:39:18 -0400, François Pinard <pinard at iro.umontreal.ca> wrote:
(snip)
>It depends a bit on if there are many Emacs users who have practical
>interest in writing `.py'/`.pyc' files next to their `.el`/`.elc' files!

Very much so! I love emacs, but there is a lot I can do in python that
I haven't a clue how to do in emacs lisp. (well, almost anything!)

I hope you'll excuse the lisp-newbie questions, but I think a simple
example would really help me understand how this is going to work.
For example, let's say I have a a module, let's call it manglers.py,
containing this simple python function:

def break_on_whitespace(some_string):
	"""Yes, it's trivial."""
	words = some_string.split()
	return '\n'.join(words)

Now I want to tell Emacs about this function so that I can call it on
a region of text and replace the region with the result of the
call. And bind this action to a key, of course.

So what goes in my .emacs file?
First I import the module:
(import-python 'manglers')

Then I can refer to (manglers-break_on_whitespace), right?
And I think I can bind it to a key like so:
(global-set-key (quote [f7]) (quote manglers-break_on_whitespace))

But how do I pass and replace the current region?  I was hoping this
project of yours might enable me to avoid learning any more lisp, but
it looks like I won't be so lucky. :)

--PW









More information about the Python-list mailing list