是否可以在 Emacs 中将 Ropemacs 与 TRAMP 一起使用?
我最近安装了 Ropemacs 的 hg Tip 版本,我想在使用 TRAMP 编辑远程文件时使用它。有人这样做过吗?当我尝试使用 M-/
完成变量名称时,系统要求我输入 Rope 项目根文件夹
,然后我输入:/ssh:myhost: /path/to/myproject/
,它给了我以下错误:
Opening [/ssh:myhost:/path/to/myproject/] project ...
pymacs-report-error: Python: Traceback (most recent call last):
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/Pymacs/pymacs.py", line 147, in loop
value = eval(text)
File "<string>", line 1, in <module>
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/ropemode/decorators.py", line 53, in newfunc
return func(*args, **kwds)
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/ropemode/interface.py", line 254, in code_assist
_CodeAssist(self, self.env).code_assist(prefix)
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/ropemode/interface.py", line 538, in code_assist
proposals = self._calculate_proposals()
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/ropemode/interface.py", line 597, in _calculate_proposals
self.interface._check_project()
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/ropemode/interface.py", line 448, in _check_project
self.open_project()
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/ropemode/decorators.py", line 53, in newfunc
return func(*args, **kwds)
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/ropemode/interface.py", line 88, in open_project
self.project = rope.base.project.Project(root)
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/rope/base/project.py", line 134, in __init__
os.mkdir(self._address)
OSError: [Errno 2] No such file or directory: '/ssh:myhost:/path/to/myproject'
我想 Ropemacs 不支持带有 TRAMP 的远程文件。只是想知道是否有人找到了解决方法。也许一些定制的 elisp?或者也许我应该使用 sshfs 并在本地挂载远程文件系统...
我在位于 /home/saltycrane/lib/python-environments/default
的 virtualenv 中安装了 Ropemacs。我在 Ubuntu Lucid 上使用 GNU Emacs 23.1.50.1。
我应该提到,当我不使用 TRAMP 时,使用 M-/
完成工作效果很好。
I recently installed the hg tip version of Ropemacs and I'd like to use it when editing remote files using TRAMP. Has anyone done this? When I try to use M-/
to complete a variable name, I am asked to enter the Rope project root folder
and I enter: /ssh:myhost:/path/to/myproject/
and it gives me the following error:
Opening [/ssh:myhost:/path/to/myproject/] project ...
pymacs-report-error: Python: Traceback (most recent call last):
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/Pymacs/pymacs.py", line 147, in loop
value = eval(text)
File "<string>", line 1, in <module>
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/ropemode/decorators.py", line 53, in newfunc
return func(*args, **kwds)
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/ropemode/interface.py", line 254, in code_assist
_CodeAssist(self, self.env).code_assist(prefix)
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/ropemode/interface.py", line 538, in code_assist
proposals = self._calculate_proposals()
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/ropemode/interface.py", line 597, in _calculate_proposals
self.interface._check_project()
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/ropemode/interface.py", line 448, in _check_project
self.open_project()
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/ropemode/decorators.py", line 53, in newfunc
return func(*args, **kwds)
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/ropemode/interface.py", line 88, in open_project
self.project = rope.base.project.Project(root)
File "/home/saltycrane/lib/python-environments/default/lib/python2.6/site-packages/rope/base/project.py", line 134, in __init__
os.mkdir(self._address)
OSError: [Errno 2] No such file or directory: '/ssh:myhost:/path/to/myproject'
I imagine ropemacs doesn't support remote files with TRAMP. Just wondering if anyone has found a workaround. Maybe some custom elisp? Or maybe I should use sshfs and mount the remote filesystem locally...
I installed ropemacs in a virtualenv located at /home/saltycrane/lib/python-environments/default
. I am using GNU Emacs 23.1.50.1 on Ubuntu Lucid.
I should mention that completion with M-/
works fine when I'm not using TRAMP.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,使用 TRAMP 是不可能的,因为当 Python
rope
库想要扫描文件系统中的 Python 文件以查找其类时,它不会调用回 Emacs函数 — 相反,它直接在文件系统上使用listdir()
和open()
等调用,而不给 Emacs 机会妨碍并拦截特殊的 TRAMP-您正在编辑的前缀路径。正如评论中提到的,使用 sshfs 可能是可能的,但对于绳索,我想这将是一个非常慢的解决方案,因为>rope 必须打开很多文件才能找出项目的状态。
在跨远程文件系统链接进行编辑时,我通常会关闭
rope
,或者弄清楚如何从远程系统导出 Emacs 会话。我想知道您是否可以使用rsync
或dropbox
甚至 DVCS 之类的东西,以便文件将作为可立即访问的副本存在于您的本地硬盘驱动器上,但是这样您保存的更改会被复制吗?No, this is not possible using TRAMP, because the Python
rope
library does not make calls back into Emacs when it wants to scan the filesystem for Python files to find their classes and functions — instead, it uses calls likelistdir()
andopen()
on the filesystem directly, without giving Emacs a chance to get in the way and intercept the special TRAMP-prefixed paths that you are editing.Using
sshfs
might be possible, as the comments have mentioned, but forrope
I imagine that it would be a very slow solution, sincerope
has to open so many files to find out the state of your project.I generally leave
rope
off, or else figure out how to export an Emacs session from the remote system, when editing across a remote-filesystem link. I wonder if you could use something likersync
ordropbox
or even a DVCS so that the files would be present on your local hard drive as immediately-accessible copies, but so that changes you save would get copied across?