[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: let*: Wrong type argument: stringp, nil
From: |
Hongyi Zhao |
Subject: |
Re: let*: Wrong type argument: stringp, nil |
Date: |
Fri, 8 Oct 2021 11:36:13 +0800 |
On Wed, Sep 29, 2021 at 8:49 PM Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>
> On Wed, Sep 29, 2021 at 8:30 PM Yuri Khan <yuri.v.khan@gmail.com> wrote:
> >
> > On Wed, 29 Sept 2021 at 17:29, Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
> >
> > > (defun try/pyvenv-workon ()
> > > (when (buffer-file-name)
> > > (let* ((python-version ".python-version")
> > > (project-dir (locate-dominating-file (buffer-file-name)
> > > python-version)))
> > > (when project-dir
> > > (pyvenv-workon
> > > (with-temp-buffer
> > > (insert-file-contents (expand-file-name python-version))
> >
> > You probably wanted (expand-file-name python-version project-dir) here.
>
> Good catch! You're absolutely right. Thanks again for your help.
>
> >
> > > (car (split-string (buffer-string)))))))))
Here is another implementation based on s and f given by pyenv-mode-auto [1]:
(require 's)
(require 'f)
(require 'pyenv-mode)
(defun pyenv-mode-auto-hook ()
"Automatically activates pyenv version if .python-version file exists."
(f-traverse-upwards
(lambda (path)
(let ((pyenv-version-path (f-expand ".python-version" path)))
(if (f-exists? pyenv-version-path)
(progn
(pyenv-mode-set (car (s-lines (s-trim (f-read-text pyenv-version-path
'utf-8)))))
t))))))
(add-hook 'find-file-hook 'pyenv-mode-auto-hook)
(provide 'pyenv-mode-auto)
[1]
https://github.com/ssbb/pyenv-mode-auto/blob/347b94cd5ad22e33cc41be661c102d4548767858/pyenv-mode-auto.el#L35-L51
HZ
- Re: let*: Wrong type argument: stringp, nil,
Hongyi Zhao <=