Merge pull request #1 from fuxialexander/conda_add

Naming convention and add docs; Avoid conflicting pyenv.
This commit is contained in:
Edmund Miller 2018-06-09 01:19:03 -05:00 committed by GitHub
commit a0dc6e98c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 11 deletions

View file

@ -1,6 +1,9 @@
;;; lang/python/+conda.el -*- lexical-binding: t; -*- ;;; lang/python/+conda.el -*- lexical-binding: t; -*-
;;;###if (featurep! +conda) ;;;###if (featurep! +conda)
;; This file add conda support to doom-emacs. To get started, try `M-x'
;; `+python/set-conda-home' and then `M-x' `conda-env-activate'.
(def-package! conda (def-package! conda
:when (featurep! +conda) :when (featurep! +conda)
:after (python) :after (python)
@ -8,11 +11,11 @@
(defvar +python-conda-home '("~/.anaconda3" "/usr/bin/anaconda3" "~/.anaconda") (defvar +python-conda-home '("~/.anaconda3" "/usr/bin/anaconda3" "~/.anaconda")
"A list of host pattern and corresponding anaconda home.") "A list of host pattern and corresponding anaconda home.")
:config :config
(advice-add 'anaconda-mode-bootstrap :override #'*anaconda-mode-bootstrap) (advice-add 'anaconda-mode-bootstrap :override #'+python*anaconda-mode-bootstrap)
(conda-env-autoactivate-mode -1) (conda-env-autoactivate-mode -1)
;; (add-hook 'python-mode-hook #'conda-env-activate-for-buffer) ;; (add-hook 'python-mode-hook #'conda-env-activate-for-buffer)
(conda-env-initialize-interactive-shells) (conda-env-initialize-interactive-shells)
(conda-env-initialize-eshell) (conda-env-initialize-eshell)
;; Version management with conda ;; Version management with conda
(add-hook 'conda-postactivate-hook #'+python|add-version-to-modeline) (add-hook 'conda-postactivate-hook #'+python|add-conda-env-to-modeline)
(add-hook 'conda-postdeactivate-hook #'+python|add-version-to-modeline)) (add-hook 'conda-postdeactivate-hook #'+python|add-conda-env-to-modeline))

View file

@ -3,21 +3,28 @@
;;;###autoload ;;;###autoload
(defun +python/set-conda-home () (defun +python/set-conda-home ()
(interactive) "Set the CONDA HOME.
(ivy-read "Set conda home:" +python-conda-home Usually it's `~/.anaconda3' on local machine, but you can also set it to a
:history +python/set-conda-home--history remote directory using TRAMP syntax such as `/ssh:host:/usr/bin/anaconda3'. In
:action (lambda (cand) (setq conda-anaconda-home cand)))) that way you can use the remote conda environment as well as the corresponding
remote python executable and packages."
(interactive)
(ivy-read "Set conda home:" +python-conda-home
:history +python/set-conda-home--history
:action (lambda (cand) (setq conda-anaconda-home cand))))
;;;###autoload ;;;###autoload
(defun +python|add-version-to-modeline () (defun +python|add-conda-env-to-modeline ()
"Add version string to the major mode in the modeline." "Add conda environment string to the major mode in the modeline."
(setq mode-name (setq mode-name
(if conda-env-current-name (if conda-env-current-name
(format "Py:conda:%s" conda-env-current-name) (format "Py:conda:%s" conda-env-current-name)
"Python"))) "Python")))
;;;###autoload ;;;###autoload
(defun *anaconda-mode-bootstrap (&optional callback) (defun +python*anaconda-mode-bootstrap (&optional callback)
"Run `anaconda-mode' server. "Advice to set up the anaconda-mode even in remote environment.
Original doc:
Run `anaconda-mode' server.
CALLBACK function will be called when `anaconda-mode-port' will CALLBACK function will be called when `anaconda-mode-port' will
be bound." be bound."
(setq anaconda-mode-process (setq anaconda-mode-process