From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.help Subject: Re: let*: Wrong type argument: stringp, nil Date: Sat, 25 Sep 2021 12:09:39 +0200 Message-ID: <87lf3lrmos.fsf@gmx.net> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18343"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: help-gnu-emacs To: Hongyi Zhao Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Sep 25 12:10:33 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 1mU4dc-0004aJ-TY for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 25 Sep 2021 12:10:32 +0200 Original-Received: from localhost ([::1]:44042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mU4db-0007Zp-FW for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 25 Sep 2021 06:10:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU4cs-0007ZD-At for help-gnu-emacs@gnu.org; Sat, 25 Sep 2021 06:09:46 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:38727) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mU4cq-0007OM-0N for help-gnu-emacs@gnu.org; Sat, 25 Sep 2021 06:09:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=badeba3b8450; t=1632564580; bh=V1qGNmcNT8ek7s1IdsS9QuV9lB5aliZZoeGG2W/HkhA=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=GMY8mONccu4PwvYN7f32xC0wpzcerL1oHz7qT7I3ITEspIHanvRWfrz7UkExkmTFb wj98OfyuORRwVWp9drIEC2oYMX51WtOiWiTo8m1biyLJqQENT4SMrpoBP1JbR47NTT mRdnZ4cNcLoRIOtMuH/2wnCf6j0AfJU8lGDED/KM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from strobelfs ([188.109.144.155]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MKsjH-1m9NsX011B-00LCYh; Sat, 25 Sep 2021 12:09:40 +0200 In-Reply-To: (Hongyi Zhao's message of "Fri, 24 Sep 2021 22:52:45 +0800") X-Provags-ID: V03:K1:+kSDbp1uYVieDnuFEjNfJqH6pkDs1mO6rUgkQrLsWN7ZMyJiLPF NWpYuCweLA8NrPcQNP5nSy/GWHPTnVKz9Ltj6PlMlH5KOXwMTOCL+gSR2w/8dK+/rYXHCYa ph88cxzUI+bKpWmU+POkAijOrEyTl0IA3tmgby9hmeApl5oFeiYFndHhOwBRk8CzmWMd61C gxFBhsAYl4EXuUNhCAM6g== X-UI-Out-Filterresults: notjunk:1;V03:K0:/fscEj0O9/o=:QZJY/XxYaQrajjzJ351jNh Iq3b1CWrpJImeLS0RICM5VV5mcBBJh3dc8eBEqJzGCIx7m3zUOjhKdCAZALhbveFLFekMnAWy ES6gOs2ojSpgiCADOHvsT/EqiRkwqN6go44byfJ2X8Vi+0HR9k9cuDUhbjvS0YgawtKtqpz0F pJdRV2lihoPMmwqPq+8kxfoLfhlH14Imju/kbhwwC1uUXiXrGZrBWsRLMKUtETyeh7TdwR4MG DkOsez6cqhR7XHxavXrtF1q4JqenjkzqDhUfykTYC8MTs3Mc5Ar8/ttGAPeEFKuilfgE8reOk u92zG8EVV5pdg68osho2jCGv9L+BvqvNC3DMf8RULFWAMHOSQcHIXXvqfAMEx2itOo8CT7SyD UJ2KI40uBbkOVbxVpde71oB+5gZeLcOyDObYrMKbxO2n7OKShAFnKvAkqjU22LBl+tAZkI7ZU xMmL2qx96pXlyu8OZTFGz7ypBKSrrqr7BGJwQ48+GvDJuWxsWZ0NOl8PG0gCCb82TzpKadI0B 8Riox2pEUaCnib1JEPPmQeh/HEH1X6TVwI577K9HlDPZwMm0ySwUrsHVsgi687X7I5jon2l+j 6kBv5ymydvDBSgyyecPlyb/sflPdgLm2+DJ5T0vVrwsO4QhpqVrAYexFirDe06meMqevINI/B Ornymp/P+N874Q0nBfOOrVevWeH9JYg8hkjRq2bKMcDZdfcvt0ZBfL31pzyKanvLyyApI3V3h 9nmW7whvkh5ivPJoJZKiVIvKjFGP7zp6Kuh8XQCNgZo0MrDwPcmq95RzPNFF5JtKiOp9y1C9 Received-SPF: pass client-ip=212.227.15.18; envelope-from=stephen.berman@gmx.net; helo=mout.gmx.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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:133232 Archived-At: On Fri, 24 Sep 2021 22:52:45 +0800 Hongyi Zhao wrote: > According to the idea represented here [1], I wrote the following > function to activate the python virtual environment automatically > using the content of the ".python-version" file located in the project > directory of the current opened python file: > > (defun pyvenv-autoload () > (require 'projectile) > (let* ((pdir (file-name-directory buffer-file-name)) (pfile > (concat pdir ".python-version"))) > (if (file-exists-p pfile) > (pyvenv-workon (with-temp-buffer > (insert-file-contents pfile) > (nth 0 (split-string (buffer-string)))))))) > (add-hook 'python-mode-hook 'pyvenv-autoload) > > It seems the corresponding python virtual environment can be activated > automatically when I open the python file in Emacs. But when I try to > evaluate the file, the following message will be triggered, and defeat > the evaluate operation: > > let*: Wrong type argument: stringp, nil > > [1] https://github.com/jorgenschaefer/pyvenv/issues/51#issuecomment-253902450 > > Any hints for fixing this problem? Evidently buffer-file-name is nil when the sexp `(file-name-directory buffer-file-name)' is evaluated, which indicates the current buffer when that function is called is not visiting a file (e.g., you get the same error when you evaluate `(file-name-directory buffer-file-name)' in *scratch*). Steve Berman