pymacs! :-)

François Pinard pinard at iro.umontreal.ca
Sat Sep 8 12:40:09 EDT 2001


[Paul Winkler]

> You had written:

> lisp.global_set_key([lisp.f7], lisp.manglers_break_on_whitespace)

> So you want to put all the possible keys in the lisp namespace?  Seems
> messy.

My knowledge of English fails on me, here.  I do not understand your comment.
Would you be kind enough to explain?

Maybe you are worried with `[lisp.f7]' ?  There is nothing special with it.
[item] is a Python list, which yields a LISP vector.  `lisp.f7' merely
translates to the LISP symbol `f7'.  So, Python `[lisp.f7]' is LISP `[f7]'.

> And what about key combinations?  How would you say something like 'C-x w'?
> I would suggest simply writing them as strings, and the programmer
> will have to know the elisp way of naming them.  Example:

> lisp.global_set_key(['C-x w'], lisp.manglers_break_on_whitespace)

In LISP, this would be written:

   (global-set-key "\C-xw" manglers-break-on-whitespace)

Triggering this from Python requires that you write the string the
Python way, and Python does not recognise the "\C-" escape.  Knowing
that `C-x' is chr(0x18), one could write:

   lisp.global_set_key('\x18w', lisp.manglers_break_on_whitespace)

Maybe it could be useful to have a service function to help writing more
LISP-looking strings in Python?  `pymacs' does not have any service library
yet, but if the need arise, we can progressively build one.  Maybe there
would not be much things in it, if any.  Hard to know in advance.
I'd rather keep the API as bare as possible, if this is reasonable.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard




More information about the Python-list mailing list