mirror of
https://github.com/SqrtMinusOne/micromamba.el.git
synced 2025-12-10 13:23:02 +03:00
Replace (if ... nil) with (when ...)
This commit is contained in:
parent
56897f586e
commit
443736121a
1 changed files with 6 additions and 9 deletions
|
|
@ -213,18 +213,16 @@ Returns an alist with the following keys:
|
||||||
;; TODO: implement an optimized finder with e.g. projectile? Or a series of
|
;; TODO: implement an optimized finder with e.g. projectile? Or a series of
|
||||||
;; finder functions, that stop at the project root when traversing
|
;; finder functions, that stop at the project root when traversing
|
||||||
(let ((containing-path (f-traverse-upwards 'micromamba--contains-env-yml? dir)))
|
(let ((containing-path (f-traverse-upwards 'micromamba--contains-env-yml? dir)))
|
||||||
(if containing-path
|
(when containing-path
|
||||||
(f-expand "environment.yml" containing-path)
|
(f-expand "environment.yml" containing-path))))
|
||||||
nil)))
|
|
||||||
|
|
||||||
(defun micromamba--get-name-from-env-yml (filename) ;; adapted from conda.el
|
(defun micromamba--get-name-from-env-yml (filename) ;; adapted from conda.el
|
||||||
"Pull the `name` property out of the YAML file at FILENAME."
|
"Pull the `name` property out of the YAML file at FILENAME."
|
||||||
;; TODO: find a better way than slurping it in and using a regex...
|
;; TODO: find a better way than slurping it in and using a regex...
|
||||||
(when filename
|
(when filename
|
||||||
(let ((env-yml-contents (f-read-text filename)))
|
(let ((env-yml-contents (f-read-text filename)))
|
||||||
(if (string-match "name:[ ]*\\([A-z0-9-_.]+\\)[ ]*$" env-yml-contents)
|
(when (string-match "name:[ ]*\\([A-z0-9-_.]+\\)[ ]*$" env-yml-contents)
|
||||||
(match-string 1 env-yml-contents)
|
(match-string 1 env-yml-contents)))))
|
||||||
nil))))
|
|
||||||
|
|
||||||
(defun micromamba--infer-env-from-buffer () ;; adapted from conda.el
|
(defun micromamba--infer-env-from-buffer () ;; adapted from conda.el
|
||||||
"Search up the project tree for an `environment.yml` defining a conda env."
|
"Search up the project tree for an `environment.yml` defining a conda env."
|
||||||
|
|
@ -235,11 +233,10 @@ Returns an alist with the following keys:
|
||||||
(when working-dir
|
(when working-dir
|
||||||
(or
|
(or
|
||||||
(micromamba--get-name-from-env-yml (micromamba--find-env-yml working-dir))
|
(micromamba--get-name-from-env-yml (micromamba--find-env-yml working-dir))
|
||||||
(if (or
|
(when (or
|
||||||
micromamba-activate-base-by-default
|
micromamba-activate-base-by-default
|
||||||
(alist-get 'auto_activate_base (micromamba--get-config)))
|
(alist-get 'auto_activate_base (micromamba--get-config)))
|
||||||
"base"
|
"base")))))
|
||||||
nil)))))
|
|
||||||
|
|
||||||
(defun micromamba--get-activation-parameters (prefix)
|
(defun micromamba--get-activation-parameters (prefix)
|
||||||
"Get activation parameters for the environment PREFIX.
|
"Get activation parameters for the environment PREFIX.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue