Giter Club home page Giter Club logo

Comments (2)

gabrielelanaro avatar gabrielelanaro commented on August 16, 2024

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.

from emacs-for-python.

kajic avatar kajic commented on August 16, 2024

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)

from emacs-for-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.