Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emacs hangs when using rope-goto-definition and rope-show-doc #127

Open
kajic opened this issue Jan 20, 2014 · 2 comments
Open

Emacs hangs when using rope-goto-definition and rope-show-doc #127

kajic opened this issue Jan 20, 2014 · 2 comments

Comments

@kajic
Copy link

kajic commented Jan 20, 2014

When using the rope-goto-definition and rope-show-doc functions to goto/show library symbols I can more or less consistently get emacs to hang.

To enable introspection of libraries I added the following to $PROJECT_ROOT/.ropeproject/config.py:

VIRTUAL_ENV = "$HOME/.virtualenvs/$PROJECT_ROOT/"
ACTIVATE_FILE = VIRTUAL_ENV + "bin/activate_this.py"
execfile(ACTIVATE_FILE, dict(__file__=ACTIVATE_FILE))

It never seems to happen when jumping to project-local definitions, and not necessarily always when jumping to a library function. However, once I'm looking around in a library, it seems to always happen after one or two additional jumps. The only thing I can do to execute C-g a number of times, and quickly kill the Pymacs buffer. If I'm too slow with doing that it freezes again.

What can I do to investigate the cause of the problem?

@gabrielelanaro
Copy link
Owner

I found that rope causes a lot of hanging problems too, I'll check if I can reproduce your behaviour and try to help you. As a workaround I would suggest you to ditch rope altogether and use https://github.com/tkf/emacs-jedi which is so much faster and reliable.

The reason why jedi is not included in emacs-for-python is that it has a weird installation procedure based on virtualenv and I should find a way to wrap and bundle it.

@kajic
Copy link
Author

kajic commented Jan 20, 2014

I decided to try jedi instead. Thanks for the tip.

I wrote this to make jedi use my project-specific virtualenv. Maybe it can be useful to someone else:

(defun project-directory (buffer-name)
  (interactive)
  (let ((git-dir (file-name-directory buffer-name)))
    (while (and (not (file-exists-p (concat git-dir ".git")))
                git-dir)
      (setq git-dir
            (if (equal git-dir "/")
                nil
              (file-name-directory (directory-file-name git-dir)))))
    git-dir))

(defun project-name (buffer-name)
  (let ((git-dir (project-directory buffer-name)))
    (if git-dir
        (file-name-nondirectory
         (directory-file-name git-dir))
      nil)))

(defun virtualenv-directory (buffer-name)
  (let ((venv-dir (expand-file-name
                   (concat "~/.virtualenvs/" (project-name buffer-name)))))
    (if (and venv-dir (file-exists-p venv-dir))
        venv-dir
      nil)))

(defun setup-jedi-server-args ()
  (let ((venv-dir (virtualenv-directory buffer-file-name)))
    (when venv-dir (set 'jedi:server-args (list "--virtual-env" venv-dir)))))

(setq jedi:setup-keys t)
(add-hook 'python-mode-hook 'setup-jedi-server-args)
(add-hook 'python-mode-hook 'jedi:setup)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants