1. Make a new project and create a file with the following lines:
from twisted.internet import reactor
reactor.run(|
where `|' indicates current point in emacs
2. M-: (rope-get-calltip) RET
Backtrace:
Debugger entered--Lisp error: (error "Python: Traceback (most recent call last):
File \"/emacs/share/emacs/site-lisp/etc/python/Pymacs.py\", line 268, in loop
value = eval(text)
File \"<string>\", line 1, in <module>
File \"/emacs/share/emacs/site-lisp/etc/python/ropemode/decorators.py\", line 53, in newfunc
return func(*args, **kwds)
File \"/emacs/share/emacs/site-lisp/etc/python/ropemode/interface.py\", line 194, in get_calltip
return self._base_get_doc(_get_doc)
File \"/emacs/share/emacs/site-lisp/etc/python/ropemode/interface.py\", line 217, in _base_get_doc
self.resource, maxfixes)
File \"/emacs/share/emacs/site-lisp/etc/python/ropemode/interface.py\", line 193, in _get_doc
return codeassist.get_calltip(project, text, offset, *args, **kwds)
File \"/emacs/share/emacs/site-lisp/etc/python/rope/contrib/codeassist.py\", line 94, in get_calltip
pyname = fixer.pyname_at(offset)
File \"/emacs/share/emacs/site-lisp/etc/python/rope/contrib/fixsyntax.py\", line 66, in pyname_at
return new_pyname()
File \"/emacs/share/emacs/site-lisp/etc/python/rope/contrib/fixsyntax.py\", line 61, in new_pyname
return rope.base.evaluate.eval_location(pymodule, newoffset)
File \"/emacs/share/emacs/site-lisp/etc/python/rope/base/evaluate.py\", line 11, in eval_location
return eval_location2(pymodule, offset)[1]
File \"/emacs/share/emacs/site-lisp/etc/python/rope/base/evaluate.py\", line 17, in eval_location2
return pyname_finder.get_primary_and_pyname_at(offset)
File \"/emacs/share/emacs/site-lisp/etc/python/rope/base/evaluate.py\", line 78, in get_primary_and_pyname_at
holding_scope = self.module_scope.get_inner_scope_for_line(lineno)
File \"/emacs/share/emacs/site-lisp/etc/python/rope/base/pyscopes.py\", line 132, in get_inner_scope_for_line
return self._scope_finder.get_holding_scope(self, lineno, indents)
File \"/emacs/share/emacs/site-lisp/etc/python/rope/base/pyscopes.py\", line 229, in get_holding_scope
line_indents = self.get_indents(lineno)
File \"/emacs/share/emacs/site-lisp/etc/python/rope/base/pyscopes.py\", line 222, in get_indents
self.lines.get_line(lineno))
File \"/emacs/share/emacs/site-lisp/etc/python/rope/base/codeanalyze.py\", line 62, in get_line
self.starts[lineno] - 1]
IndexError: list index out of range
")
Leo <sdl....@gmail.com> wrote:
> To reproduce this:
> 1. Make a new project and create a file with the following lines:
> from twisted.internet import reactor
> reactor.run(|
> where `|' indicates current point in emacs
> 2. M-: (rope-get-calltip) RET
> Backtrace:
> File \"/emacs/share/emacs/site-lisp/etc/python/rope/base/pyscopes.py\", line 222, in get_indents
> self.lines.get_line(lineno))
> File \"/emacs/share/emacs/site-lisp/etc/python/rope/base/codeanalyze.py\", line 62, in get_line
> self.starts[lineno] - 1]
> IndexError: list index out of range
> ")
I remember a similar problem being fixed a long time ago.
Are you using the latest versions of rope, ropemode and
ropemacs?
Leo <sdl....@gmail.com> wrote:
> To reproduce this:
> 1. Make a new project and create a file with the following lines:
> from twisted.internet import reactor
> reactor.run(|
> where `|' indicates current point in emacs
> 2. M-: (rope-get-calltip) RET
The problem is the file does not end with a newline. Although that's
an error in general, it may happen for code-assists, in which the
files may not compile. Does this patch fix it?
On 2012-11-01 22:24 +0800, Ali Gholami Rudi wrote:
> The problem is the file does not end with a newline. Although that's
> an error in general, it may happen for code-assists, in which the
> files may not compile. Does this patch fix it?
I am getting the same error with the patch even if the file ends with a
newline. The problem seems to be not having a closing ')'.
Leo <sdl....@gmail.com> wrote:
> On 2012-11-01 22:24 +0800, Ali Gholami Rudi wrote:
> > The problem is the file does not end with a newline. Although that's
> > an error in general, it may happen for code-assists, in which the
> > files may not compile. Does this patch fix it?
> I am getting the same error with the patch even if the file ends with a
> newline. The problem seems to be not having a closing ')'.
fixsyntax.py tries to fix syntax errors before parsing the
input string for code-assists.
I think some of python's error messages point to invalid
line numbers. How about this patch?
Leo <sdl....@gmail.com> wrote:
> On 2012-11-02 13:14 +0800, Ali Gholami Rudi wrote:
> > I think some of python's error messages point to invalid
> > line numbers. How about this patch?
> No luck here. I am getting the same error.
That's odd. The following script uses rope directly. Does
it work in your configuration?
from rope.base import project
from rope.contrib import codeassist
s = "from twisted.internet import reactor\nreactor.run("
p = project.Project('.')
print codeassist.code_assist(p, s, len(s))
Leo <sdl....@gmail.com> wrote:
> On 2012-11-02 13:59 +0800, Ali Gholami Rudi wrote:
> > from rope.base import project
> > from rope.contrib import codeassist
> > s = "from twisted.internet import reactor\nreactor.run("
> > p = project.Project('.')
> > print codeassist.code_assist(p, s, len(s))
Leo <sdl....@gmail.com> wrote:
> What would be the right thing to do?
> BTW,
> from twisted.internet import reactor
> reactor.|
> why no interesting completions (such as run, listenTCP etc.) at this
> point?
How about completing "reactor.r" (or any other letter after dot)?
By the way, fixsyntax.py uses heuristics to fix syntax errors: it
comments lines and blocks that contain errors. It is probably not
hard to improve it to handle more complex errors. Patches are
welcome.
On Sun, Nov 11, 2012 at 10:58 AM, Leo <sdl....@gmail.com> wrote:
> On 2012-11-11 03:29 +0800, Ali Gholami Rudi wrote:
> > How about completing "reactor.r" (or any other letter after dot)?
You're right. But adding twisted.internet.reactor to
extension_modules would have fixed it, if rope supported non-top-level
extension modules; I'm not sure, but as far as I remember it does not.
I think it was Darren Hoo who posted patches for fixing it (I guess it
is in the thread with the title "code completion with c-extension
modules not work") but unfortunately it was not merged, IIRC. It
would be wonderful if someone volunteers to update and test the
patches to get them merged.