473,398 Members | 2,212 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Pymacs problem

I'm trying to use the Pymacs bridge to add a symbol completion facility to
Emacs's python-mode. Neither the Python nor Emacs Lisp portions are all
that complex, but I'm having trouble passing a list of strings from Emacs
Lisp into Python. On the Emacs Lisp side it looks like this:

(pymacs-load "pycomplete")

(defun py-complete ()
(interactive)
(pycomplete-pycomplete (py-symbol-near-point)
(py-find-global-imports)))

(py-find-global-imports) returns a (Lisp) list of strings, e.g.:

("import time", "import sys")

On the Python side I have this function:

def pycomplete(s, imports=None):
completions = get_all_completions(s, imports)
dots = s.split(".")
return os.path.commonprefix([k[len(dots[-1]):] for k in completions])

Unfortunately, the imports arg does not come across as a Python list of
strings (s does come across the bridge as a normal Python string). Its
repr() prints out like this:

lisp('("import time")')

What do I need to do to convert that object into a true Python list of
strings? I'm afraid I don't quite understand the description of the lisp
object in the Pymacs docs. I tried imports.value() but that just gave me

(aref pymacs-lisp 0)

Any help appreciated...

Skip
Jul 18 '05 #1
2 1520
On Thu, 21 Oct 2004 10:56:09 -0500, Skip Montanaro wrote:
I'm trying to use the Pymacs bridge to add a symbol completion facility to
Emacs's python-mode.
This sound quite cool! :-)

What do I need to do to convert that object into a true Python list of
strings? I'm afraid I don't quite understand the description of the lisp
object in the Pymacs docs. I tried imports.value() but that just gave me

(aref pymacs-lisp 0)

Any help appreciated...


Disclaimer: so far I've only played with Pymacs a little bit, I'm by no
means an expert. Anyway, from the manual:

"""
Proper Emacs Lisp lists, those for which the cdr of last cell is nil, are
normally transmitted opaquely to Python. If pymacs-forget-mutability is
set, or if Python later asks for these to be expanded, proper Emacs Lisp
lists get converted into Python lists, if we except the empty list, which
is always converted as Python None. In the other direction, Python lists
are always converted into proper Emacs Lisp lists.
"""

So, maybe try

(defun py-complete ()
(interactive)
(let ((pymacs-forget-mutability t))
(pycomplete-pycomplete (py-symbol-near-point)
(py-find-global-imports))))

HTH,
Alberto


Jul 18 '05 #2
Alberto> So, maybe try

Alberto> (defun py-complete ()
Alberto> (interactive)
Alberto> (let ((pymacs-forget-mutability t))
Alberto> (pycomplete-pycomplete (py-symbol-near-point)
Alberto> (py-find-global-imports))))

Thanks. Worked like a charm...

Skip
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alexandre Fayolle | last post by:
Hi there, I'm not an emacs power user at all, just getting started with pymacs to try to get BicycleRepairMan to run. I have pymacs 0.21 installed, and on init, I get an emacs error. The...
0
by: François Pinard | last post by:
Hello to everybody, and Emacs users in the Python community. The Pymacs project (described below) now has new maintainer: Syver Enstad <syver@inout.no>. I'm inviting Pymacs users to collaborate...
117
by: Peter Olcott | last post by:
www.halting-problem.com
0
by: pber | last post by:
Hi all, I'm on trouble with pymacs and python binding of DBus 0.23. Emacs/Xemacs have their gnuclient(s) to make remote calls to, but I wanted to (try to) make some xemacs functions callable...
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
0
by: Grant | last post by:
Hi there. Does anyone out there know what's going on with pymacs currently? Thanks, Grant.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.