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 11:02:39 +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="2322"; 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 05:17:27 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 1mVQ63-0000Im-Ng for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 29 Sep 2021 05:17:27 +0200 Original-Received: from localhost ([::1]:36390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVQ62-0005Uo-Cc for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 28 Sep 2021 23:17:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33082) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVPrx-0003ae-SK for help-gnu-emacs@gnu.org; Tue, 28 Sep 2021 23:02:54 -0400 Original-Received: from mail-ua1-x932.google.com ([2607:f8b0:4864:20::932]:45871) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVPrw-0000n7-4F for help-gnu-emacs@gnu.org; Tue, 28 Sep 2021 23:02:53 -0400 Original-Received: by mail-ua1-x932.google.com with SMTP id 64so501140uab.12 for ; Tue, 28 Sep 2021 20:02:51 -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=WtSQwtM1doGuNPv8stNE/VlE9PerQHSr0Bcwl5d04ZA=; b=Dv/1l/gTcZaJOvWJ/XOXCbeyiKxIl+PgVs2jj789fxobm+Iiny70sFtqUgO/w9Bl2d 7R2K65RzXEYJ/15zy3vW4cXK+u5gEYyLGQGGON7783JViYHwYMuwnCu7A6wlqX/OC0Gw o9alIzUP3sS97nfsiCteqzfuRKLfmFKmQFt4x3WPV+jBb50g1wbLNA2fktBaDvgEoUsr co79dSbJBKPpIUF/iYPmFNaRWy22ipZTs39+hknOFkk7W/50Tzd5xDPsQPP9CDgjnI1x Ng49UW368cy6CFPWU935GsZliK4jsKRy9mzjC3fyN6ac7tRNr5/ipyfgI2yORfA66EfJ BEUw== 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=WtSQwtM1doGuNPv8stNE/VlE9PerQHSr0Bcwl5d04ZA=; b=opt/lc6l33RSqedqpEvy/TUSB3+wDg0LsVeADAAiNvcyF1isI1LaYsJzm168bm6KIw pbE5lDpJbfCag52OePZM27hBMzlXHtYNWmJV3A6fYDgPWQfP+NvweH3VdXZxJfQuMBvb z8N6WEV8MPISF5PvoLKB6hJKMBVqS8YuO7GU+BRjB5NP8TWKLoVg7FuFOBtZ2G8+Ta5X Xi2uEY/CB+vbuFxw8zbKMud7DVymKqEpb7uvVgUqYNUaN6ajbPZEBWFK3101vkATXN19 UyMYzSn/C6Rjj1zvBFOdDrNiHH5r9m+ylk98i0xu/KhQJEbcQYzZxc9ZvR9Ct71cQCI5 gVQA== X-Gm-Message-State: AOAM532yk4uQ35kifr5x0IyFP0cg+wADzEmJ11TcZeRG9g3XjwUcOfA3 KGYwidflfsdQtmhIFfH8xwWJjQZnPw4RLRSFr0M= X-Google-Smtp-Source: ABdhPJwsUDSR5TOgVQ/fm8BoETEkLOh4jGLoJZ52mYPvRQJjmF2qcAZVXa3k1sbWxnQB4wR5d0cT4XUGgi3/f3uGmjo= X-Received: by 2002:ab0:1001:: with SMTP id f1mr8227426uab.115.1632884571184; Tue, 28 Sep 2021 20:02:51 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::932; envelope-from=hongyi.zhao@gmail.com; helo=mail-ua1-x932.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:133367 Archived-At: On Wed, Sep 29, 2021 at 10:03 AM Hongyi Zhao wrote: > > 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 wr= ote: > > > > > > > Now I'm trying another test code snippet based on the idea posted h= ere [1]: > > > > > > > > (while (not (file-exists-p ".python-version")) > > > > (cd "..") > > > > )) > > > > > > > > But when I test the above code in scratch buffer, it seems to be st= uck > > > > in an endless loop and running there all the time. Any hints for th= is > > > > problem? > > > > > > You=E2=80=99re not handling the case here that you reached the root d= irectory > > > 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-thr= ows-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)))))))= ) The complete code for this purpose is as following now: (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)))))))) But I wonder if I can solve this problem by using `locate-dominating-file' only once? HZ