From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hongyi Zhao Newsgroups: gmane.emacs.help Subject: Re: let*: Wrong type argument: stringp, nil Date: Fri, 8 Oct 2021 11:36:13 +0800 Message-ID: References: <87lf3lrmos.fsf@gmx.net> <87ee9csyp0.fsf@gmx.net> <87a6k0sogz.fsf@gmx.net> <87lf3gqbi7.fsf@zoho.eu> <87r1d7q4i1.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12344"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs , Emanuel Berg To: Yuri Khan Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Oct 08 05:38:37 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mYgiT-00030b-1P for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 08 Oct 2021 05:38:37 +0200 Original-Received: from localhost ([::1]:46222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYgiR-0003Nn-Kv for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 07 Oct 2021 23:38:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYggN-0001bs-U2 for help-gnu-emacs@gnu.org; Thu, 07 Oct 2021 23:36:28 -0400 Original-Received: from mail-vs1-xe2b.google.com ([2607:f8b0:4864:20::e2b]:38589) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mYggL-00040t-Vf for help-gnu-emacs@gnu.org; Thu, 07 Oct 2021 23:36:27 -0400 Original-Received: by mail-vs1-xe2b.google.com with SMTP id x192so6822864vsx.5 for ; Thu, 07 Oct 2021 20:36:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mB65bosb0r/qrehqdiqIpfnFODO8S8cwiMXPOpgud+E=; b=oWrVHXMPMJV96okWmvFALHn+JbXmtBeqk7q7ZIpmbdbvQ07csB+DV2wKwYQrBMxHfJ 8KDkfyo8fnu3URcPeq1e3PvtEZHqWW2QY/jUfzvU8AR2/N3zOyBb275CPLLGMaBOuxR9 K5nW5CnC/AtcPEeaKUIRxb325ON3DtirP4F0dR6eaKTho4rXJlBsgQWL5hm+hPArA3PI jxQIszU6IQyRCbtwNCGbzQBmFESxv2aqebjJcFYeZsvarg04zYkr1MDfWjvA9qtdNgFQ du8U0RlMwF4hpTrtneM4gXSAKMx61Qfqk+n7NDN/0aps+3zi9CFSPVlTxY9N8zHbe0ad 6U1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mB65bosb0r/qrehqdiqIpfnFODO8S8cwiMXPOpgud+E=; b=CvK1fNQhyePw4Vo67wCKTUTDI3OZfEHrH1y0a5qjKesFWBWtlg/W28aiYdXzTELV8s VeY+I8hUn5Jap+5l7qznqZHPy+a30bZiWmWvTJn+L7Hkct+EJHbscE9P1ncZwv/QOuqh WZ7oxHlq0Wg22pJi8Wk2ZPeO3JzEETreB1dpwqedfEK3SbRjwfGNLpDS5Tg4CAHD5koD 5ZPGkurqIsrMSoJ7iOzRc+Q0C4XuVHThJJOUKLlN7ORrwsHSDufZuUePa8zwcsRglYbK B8Us/niu/X3L58EgGR5YP36s3oxVaiYHvFQieNV7+iHmoyIOmEAPcXxO57vdj6sdbxKT DZQg== X-Gm-Message-State: AOAM533/9pwH8UCJw0Gy9IRbzSkip9QdS9eKL+fsHwRtjXlA2+wUHaQF mJhw2PNrSHv4Sdi67Cn20Qfu9yHEklaRgO2A5yY= X-Google-Smtp-Source: ABdhPJxkX4zqQbp59j5rFydlEiD7HaoVl7GZfRu2hFZD6fNzWLBZiNq/gMmqDNjlIHQjMfwydsG0TdeqwAIN84BlFdw= X-Received: by 2002:a67:c31c:: with SMTP id r28mr8883874vsj.10.1633664184415; Thu, 07 Oct 2021 20:36:24 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::e2b; envelope-from=hongyi.zhao@gmail.com; helo=mail-vs1-xe2b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:133652 Archived-At: On Wed, Sep 29, 2021 at 8:49 PM Hongyi Zhao wrote: > > On Wed, Sep 29, 2021 at 8:30 PM Yuri Khan wrote: > > > > On Wed, 29 Sept 2021 at 17:29, Hongyi Zhao 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