Closed martibosch closed 1 year ago
Thank you @martibosch !
Hello again!
I tried using conda.el after the merging of this PR and autoactivation for buffer is now giving a "No Conda environment found for nil".
I am sorry because I think I did not review it properly and the function became over-complicated. I think it can be refactored to a cleaner version that ensures that buffer-file-name is used if present but uses default-directory otherwise:
(defun conda--infer-env-from-buffer ()
"Search up the project tree for an `environment.yml` defining a conda env."
(let* ((filename (buffer-file-name))
(working-dir (if filename
(f-dirname filename)
default-directory)))
(when working-dir
(or
(conda--get-name-from-env-yml (conda--find-env-yml working-dir))
(if (or
conda-activate-base-by-default
(alist-get 'auto_activate_base (conda--get-config)))
"base"
nil)))))
Maybe even the (when working-dir ...)
can be omitted.
I have tried it (with the function as defined in the snippet) and it seems to work properly. Should I submit a PR with a fix?
@martibosch please do!
Hi! I'm a new user of Emacs(the doomemacs flavor) and I want to use this package. After set (conda-env-autoactivate-mode t)
in config, I got Error: (void-function working-dir)
. Because the working-dir
is first appeared in this patch, maybe you guys know how to solve it.
Maybe working-dir
is a function too new or too old for Emacs 28.2 or something require another package installed?
Any help is welcomed!
In case you may interested in discord, there are some detailed information, I and another poor guy encountered the same thing. https://discord.com/channels/406534637242810369/1079338201157746738/1079338201157746738
In a few cases, e.g., when opening a ipynb notebook via
code-cells
,buffer-file-name
will return nil but the working directory can still obtained via thedefault-directory
variable.