@@ -816,34 +816,38 @@ or one of its parent directories, or else returns nil."
816
816
;;;### autoload
817
817
(defun conda-env-manage-for-buffer (&optional arg )
818
818
" Edit the Conda environment YAML file implied by the current buffer,
819
- or create, update, remove the environment defined in it.
819
+ or create, update, remove environments using it.
820
820
821
- If called with two \\ [universal-argument] prefix, it prompts for an environment
822
- to be removed, suggesting the one defined in the YAML file as default.
821
+ If an environment YAML file named `conda-env-yaml-base-name' exists, then is used as the reference.
822
+
823
+ If called without \\ [universal-argument] prefix, and an environment file exists, then opens it for editing.
824
+ If called without \\ [universal-argument] prefix, and no environment file exists, then prompts for an
825
+ environment name, and generates a buffer for a new YAML file in the root directory of the current project,
826
+ or in the `default-directory' .
823
827
824
- If no environment file exists yet, then generates a buffer for a new YAML file
825
- in the root directory of the current project, or in the `default-directory' .
828
+ The newly generated environment YAML file takes its defaults from these variables:
826
829
827
- The values from `conda-env-yaml-default-channels' , `conda-env-yaml-base-name' ,
828
- `conda-env-yaml-default-pip-dependencies, are used as content. Additionally,
829
- if a file named `conda-pip-requirements-filename' exists in parent directories,
830
- then the new environment YAML file will be placed next to it, and will reference
831
- the PIP requirements file directly, instead of `conda-env-yaml-default-pip-dependencies' .
830
+ - `conda-env-yaml-default-channels' ,
831
+ - `conda-env-yaml-default-dependencies' ,
832
+ - `conda-env-yaml-default-pip-dependencies' .
832
833
833
- If the environment file exists, and has been called with one \\ [universal-argument] prefix,
834
- then it calls `conda-env-yaml-process-for-buffer' for the environment file.
834
+ If file named `conda-pip-requirements-filename' exists in one of the parent
835
+ directories, then the generated file will be placed next to it instead,
836
+ and will be referenced directly for PIP dependencies, instead of using
837
+ the `conda-env-yaml-default-pip-dependencies' variable.
835
838
836
- If called with two \\ [universal-argument] prefixes, then prompts for the name of
837
- an existing environment and calls `conda-env-yaml-process-for-buffer' with
838
- the prefix to remove it completely, after confirmation. The default candidate
839
- suggested is the one defined in the environment YAML file, if such file exists."
839
+ If called with one \\ [universal-argument] prefix, and an environment file exists,
840
+ then updates the environment from the file, or creates it if not yet exists.
841
+
842
+ If called with two \\ [universal-argument] prefix, it prompts for an environment
843
+ to be removed. In environment YAML file exists its name is used as default."
840
844
(interactive " P" )
841
845
(let* ((dir (if-let ((filename (buffer-file-name )))
842
846
(f-dirname filename) default-directory))
843
847
(env-file (conda--find-env-yaml dir))
844
848
(project (project-current dir)))
845
849
(cond
846
- ((and (not arg) (null env-file ))
850
+ ((and (not env-file) ( or ( not arg) (and ( consp arg) ( = ( car arg) 4 )) ))
847
851
(let* ((pip-reqs-file (conda--find-pip-requirements-file))
848
852
(env-dir (or (if pip-reqs-file (f-dirname pip-reqs-file))
849
853
(if project (project-root project)) dir))
@@ -869,6 +873,8 @@ suggested is the one defined in the environment YAML file, if such file exists."
869
873
(message " Generated new Conda environment file %s " env-file)))
870
874
((consp arg)
871
875
(conda-env-yaml-process-for-buffer (<= 14 (car arg)) env-file))
876
+ ; ; only interactive universal prefix arguments are expected
877
+ (arg (error " Unsupported prefix argument %s " arg))
872
878
(env-file (find-file env-file)
873
879
(message " Opened Conda environment file %s " env-file)))))
874
880
0 commit comments