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: Wed, 29 Sep 2021 10:03:51 +0800 Message-ID: References: <87lf3lrmos.fsf@gmx.net> <87ee9csyp0.fsf@gmx.net> <87a6k0sogz.fsf@gmx.net> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37426"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs , Stephen Berman To: Yuri Khan Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 29 04:04:32 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 1mVOxU-0009aE-9C for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 29 Sep 2021 04:04:32 +0200 Original-Received: from localhost ([::1]:39016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVOxS-0006Ra-NW for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 28 Sep 2021 22:04:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53760) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVOx3-0006R9-2R for help-gnu-emacs@gnu.org; Tue, 28 Sep 2021 22:04:05 -0400 Original-Received: from mail-vk1-xa33.google.com ([2607:f8b0:4864:20::a33]:36567) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVOx1-00081E-Am for help-gnu-emacs@gnu.org; Tue, 28 Sep 2021 22:04:04 -0400 Original-Received: by mail-vk1-xa33.google.com with SMTP id t186so466632vkd.3 for ; Tue, 28 Sep 2021 19:04:02 -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:content-transfer-encoding; bh=cVgQrYwVAeBVb7F8sRaKsUSLwU2ujGc3cSZlbIhOh+E=; b=M8KMneFJgj3B4j84O3E42j4o38wVXdalCgTH4Li+AefhartVbY4XF0md7ElFhykzFg xe8KTxpwHXeD5XBlm2MllSo4dgMdmf3FgzyZtjLk9TWDmYqZ0Fwus+vmk/3mHboThA3j hrmaTBXGUgs3NxIRmfnjweKfAkP6HcqNrSxEHbC9EcIgN+TjPASOb7XRn7YD9xRwW53z q/2k9YDntnb0gr7RMrGmzbSzXRnc4TlbPkdLSAx0MXbITi0pR8s/RN7iUJO6zcwxneJW 4FTV18UgIRUTF6UdDHWeGqTWWjsMqSuS2jOmDxGoMwJKFtNn82kohQtuD61OGryH1V/J kxIw== 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:content-transfer-encoding; bh=cVgQrYwVAeBVb7F8sRaKsUSLwU2ujGc3cSZlbIhOh+E=; b=5V8hYafLuU/QdxlnNEFCdiEnanItsRHikva1AgZjHebfKla2eOQer83/z71cXpgsKC Qn3LF5Tzq9r6BvFZMCjXCd+UT7ain25uiZrdXz08vn9ZA/YZRGHFFV/M8pKIoRQUU21h s6OHz5S87eISu3Ud4HZr7TRIzUjXXjzDwZlb4+Y6OB9SnpYRVkMINXNs3XVMaeqr6tnB Z326Zb9uOojdVg2hb4qrqwaYVPGXOdk9SxV5H0F1dDcSTf2P5brx2OsS8iWZHb/eBs0y kgfPR5hgBHgHpUG0j0XWYWueCMHPTnda7wp8A1YhpqNBd6yBgnc22eHNSVY+5dSt85+1 E7dg== X-Gm-Message-State: AOAM530qujbRVXykJ9NruMjHvnweS95ORsIN1lY0CBAL/tjwXQ917K2V 86dgkjOwT86FlcG2pRMVxoWwn2R2UH767eQ3PwI= X-Google-Smtp-Source: ABdhPJxjOq4tPzPx0vkzOeh31jeE/t8A3qStZ1QFQDjEN96PBL1VOrVUYeSdjRk4kE+21dDZb95fIeDSB0LaGEHh5k0= X-Received: by 2002:a05:6122:2c3:: with SMTP id k3mr7789834vki.6.1632881042223; Tue, 28 Sep 2021 19:04:02 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::a33; envelope-from=hongyi.zhao@gmail.com; helo=mail-vk1-xa33.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:133366 Archived-At: On Wed, Sep 29, 2021 at 9:43 AM Hongyi Zhao wrote: > > On Tue, Sep 28, 2021 at 4:02 PM Yuri Khan wrote: > > > > On Tue, 28 Sept 2021 at 10:08, Hongyi Zhao wrot= e: > > > > > Now I'm trying another test code snippet based on the idea posted her= e [1]: > > > > > > (while (not (file-exists-p ".python-version")) > > > (cd "..") > > > )) > > > > > > But when I test the above code in scratch buffer, it seems to be stuc= k > > > in an endless loop and running there all the time. Any hints for this > > > problem? > > > > You=E2=80=99re not handling the case here that you reached the root dir= ectory > > without finding a .python-version file. > > > > You will really get better results if you use locate-dominating-file. > > If you=E2=80=99re trying to learn, learn by reading that function. As a= bonus, > > it does not mess with the buffer=E2=80=99s default directory. > > I work out the following code snippets using locate-dominating-file, > and it works as expected: > > (defun try/pyvenv-workon () > (when (locate-dominating-file (buffer-file-name) ".python-version") The following form should be used here: (when (and (buffer-file-name) (locate-dominating-file (buffer-file-name) ".python-version")) > ;https://emacs.stackexchange.com/questions/9474/let-statement-throw= s-error-on-assigning-a-form-to-a-variable > (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)))))))) > > > BTW, should I use `let' or `let*' here? > > HZ