From d4e9005601be97914b7663faeaec8993bd14e03b Mon Sep 17 00:00:00 2001 From: Daniel Gopar Date: Wed, 29 Mar 2017 17:49:39 -0700 Subject: [PATCH] Move to virtualenv directory if chosen --- virtualenvwrapper.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/virtualenvwrapper.el b/virtualenvwrapper.el index fac8fd7..110c175 100644 --- a/virtualenvwrapper.el +++ b/virtualenvwrapper.el @@ -223,9 +223,17 @@ prompting the user with the string PROMPT" ;; keep eshell path in sync (setq eshell-path-env (getenv "PATH")) (setenv "VIRTUAL_ENV" venv-current-dir) + (venv--switch-to-project-dir) (venv--set-venv-gud-pdb-command-name) (run-hooks 'venv-postactivate-hook)) +(defun venv--switch-to-project-dir () + "If we find the project file, cd into that directory" + (let ((proj-file (expand-file-name ".project" venv-current-dir))) + (when (file-exists-p proj-file) + (cd (with-temp-buffer + (insert-file-contents proj-file) + (string-trim (buffer-string))))))) ;; potentially interactive user-exposed functions