S
Skip Montanaro
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
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