別のプロジェクトでファイルを編集しているときに emacs-jedi がそれを検出し、対応する virtualenv が利用可能であればそれを使用したいと考えています。慣例により、私の virtualenv は私のプロジェクトと同じ名前です。彼らはに位置しています$HOME/.virtualenvs/
kenobi.elを見つけましたが、 virtualenvがプロジェクト ルートの bin ディレクトリにあることを前提としています。また、私がまったく必要としない機能が他にもいくつかあります。
kenobi.el からインスピレーションを得て、jedi の次の初期化を作成しました。かなりうまく機能しますが、完全ではありません。
A
プロジェクトからライブラリをインポートA
すると、 B
. によって定義された定義にジャンプすることはできますA
が、そこに到達すると、 からの定義にジャンプし続けることはできませんB
。
私の初期化:
(defun project-directory (buffer-name)
(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 jedi-setup-args ()
(let ((venv-dir (virtualenv-directory buffer-file-name)))
(when venv-dir
(set (make-local-variable 'jedi:server-args) (list "--virtual-env" venv-dir)))))
(setq jedi:setup-keys t)
(setq jedi:complete-on-dot t)
(add-hook 'python-mode-hook 'jedi-setup-args)
(add-hook 'python-mode-hook 'jedi:setup)
ジェダイを初期化する方法の何が問題になっていますか?