[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: |
Wed, 29 Sep 2021 14:15:47 +0800 |
On Wed, Sep 29, 2021 at 11:58 AM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> > (defun try/pyvenv-workon ()
> > (when (and (buffer-file-name)
> > (locate-dominating-file (buffer-file-name)
> > ".python-version"))
> > (let ((file (concat (locate-dominating-file (buffer-file-name)
> > ".python-version") ".python-version")))
> > (pyvenv-workon
> > (with-temp-buffer
> > (insert-file-contents file)
> > (nth 0 (split-string (buffer-string))))))))
>
> Use `let' so you don't have to hard-code the same data three
> times.
The code I’ve modified looks like this:
(defun try/pyvenv-workon ()
(when (buffer-file-name)
(let ((file (concat (locate-dominating-file (buffer-file-name)
".python-version") ".python-version")))
(when (file-exists-p file)
(pyvenv-workon
(with-temp-buffer
(insert-file-contents file)
(nth 0 (split-string (buffer-string)))))))))
Any further improvement tips?
HZ
- Re: let*: Wrong type argument: stringp, nil, (continued)
- Re: let*: Wrong type argument: stringp, nil, Emanuel Berg, 2021/09/27
- Re: let*: Wrong type argument: stringp, nil, Emanuel Berg, 2021/09/27
- Re: let*: Wrong type argument: stringp, nil, Hongyi Zhao, 2021/09/28
- Re: let*: Wrong type argument: stringp, nil, Emanuel Berg, 2021/09/28
- Re: let*: Wrong type argument: stringp, nil, Yuri Khan, 2021/09/28
- Re: let*: Wrong type argument: stringp, nil, Hongyi Zhao, 2021/09/28
- Re: let*: Wrong type argument: stringp, nil, Hongyi Zhao, 2021/09/28
- Re: let*: Wrong type argument: stringp, nil, Hongyi Zhao, 2021/09/28
- Re: let*: Wrong type argument: stringp, nil, Hongyi Zhao, 2021/09/28
- Re: let*: Wrong type argument: stringp, nil, Emanuel Berg, 2021/09/28
- Re: let*: Wrong type argument: stringp, nil,
Hongyi Zhao <=
- Re: let*: Wrong type argument: stringp, nil, Emanuel Berg, 2021/09/29
- Re: let*: Wrong type argument: stringp, nil, Hongyi Zhao, 2021/09/29
- Re: let*: Wrong type argument: stringp, nil, Emanuel Berg, 2021/09/29
- Re: let*: Wrong type argument: stringp, nil, Hongyi Zhao, 2021/09/29
- Re: let*: Wrong type argument: stringp, nil, Yuri Khan, 2021/09/29
- Re: let*: Wrong type argument: stringp, nil, Hongyi Zhao, 2021/09/29
- Re: let*: Wrong type argument: stringp, nil, Yuri Khan, 2021/09/29
- Re: let*: Wrong type argument: stringp, nil, Hongyi Zhao, 2021/09/29
- Re: let*: Wrong type argument: stringp, nil, Emanuel Berg, 2021/09/29
- Re: let*: Wrong type argument: stringp, nil, Emanuel Berg, 2021/09/29