lang/python: make repl/eval handlers respect pipenv

This commit is contained in:
Henrik Lissner 2018-09-26 12:28:32 -04:00
parent fcd1e913c5
commit 68699c3d5b
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 16 additions and 1 deletions

View file

@ -131,6 +131,15 @@
:hook (python-mode . pipenv-mode)
:init (setq pipenv-with-projectile nil)
:config
(set-eval-handler! 'python-mode
'((:command . "python")
(:exec (lambda ()
(if-let* ((bin (executable-find "pipenv"))
(dir (pipenv-project-p)))
(format "cd %S && %s run %%c %%o %%s %%a" dir bin)
"%c %o %s %a")))
(:description . "Run Python script")))
(advice-add #'pipenv-activate :after-while #'+python|update-version-in-all-buffers)
(advice-add #'pipenv-deactivate :after-while #'+python|update-version-in-all-buffers))