From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: project-find-file: switch to include non-tracked files Date: Fri, 15 Oct 2021 15:12:32 +0300 Message-ID: <3abfb5f5-a034-d234-fe6a-de00e01782b9@yandex.ru> References: <2b9ae9f3-a253-f4f4-c08c-05e3c8ef1115@yandex.ru> <9995e361-34f1-9aa6-f854-eb197723a8fd@yandex.ru> <792bff0a-7121-2830-f00c-794614e61350@yandex.ru> <3d7d8880-8cfd-51a8-1ccd-52afb04c95e6@inventati.org> <24fbdd11-d6a6-f7e6-0be2-3f7f199686f2@yandex.ru> <2b94e31a-1e20-ac07-e201-525e81b46363@inventati.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6778"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 To: Manuel Uberti , emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Oct 15 14:13:35 2021 Return-path: Envelope-to: ged-emacs-devel@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 1mbM5e-0001Yk-CG for ged-emacs-devel@m.gmane-mx.org; Fri, 15 Oct 2021 14:13:34 +0200 Original-Received: from localhost ([::1]:56214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mbM5c-0005NE-EP for ged-emacs-devel@m.gmane-mx.org; Fri, 15 Oct 2021 08:13:32 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mbM4k-0004bw-K3 for emacs-devel@gnu.org; Fri, 15 Oct 2021 08:12:38 -0400 Original-Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]:38449) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mbM4i-0006eD-Hl for emacs-devel@gnu.org; Fri, 15 Oct 2021 08:12:38 -0400 Original-Received: by mail-lf1-x12e.google.com with SMTP id x27so41076787lfu.5 for ; Fri, 15 Oct 2021 05:12:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=UFLNyhIPvMjS7Y2OAwH2zyfJXHGbcZ9b5x5XEYMoSuQ=; b=ZyX1tWcky+ajI4cZQvAQH+qDD7HRW0nzU4F9cShVFdsa130kyNGah1AR1brreI90el 5cmpV99kSwYGtUg9FXneAAsxA4sNQo5pK4h26JucrW4LvBmx4PUGwGNQN3oGjby+GdPv 7RxP2p7+2GczXINtTTugolCMZJN1xI55X95fGmVcftipcKE97Mkhgt8kBSEOSUm84u0U 9Wc4IH28+sKM9O5pmXVs1pD01bXrhXk9KQjLlrscof8VXulAnRfofWv2KfxPdgjD25sT pEmj9xhN4TqaTV0FfJ31QdGEPsmXKPkBGOZHLR6K3Uq30ZwoJ6ewrkx6702kzcyJNx+Y ADAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=UFLNyhIPvMjS7Y2OAwH2zyfJXHGbcZ9b5x5XEYMoSuQ=; b=WOm2GttAYJMP1Ak2yAN4gWV1YJ3QGrcQNjZfSpCV6KTjEPy/WBo4Z3wh2JGffHCrwe 8ZKsvIp+VdyIGnQZ7Z/VtMCC5xkvSJLirKBEzhHwpL9RKydjQN9W4zAzpMbXtNxjWnAr rYdVQ7t9JnLnee/52/fO82D9Vvx6/XDxciJy2upNx0qR5jD+bRRwtsH25O1PSpesUm4J WkqU5w+Osv53rAdnVnleI/xBfejjrrv6GmyinBRrEZwZy/ceaIeNzW0AQpUI3tEdm2Jk TT1IjJJwzOSZW4MFBf5D4AsPCakqw0KIV3pEqgsf1MB7sK99q89cElwFRyBZTX99qgJV EuFw== X-Gm-Message-State: AOAM531VX/cTbLZxk/ckP7ggGdDQbKW1fG0vfeYtTgrM7c0eVgk9qWW2 dX3N7jd4BLkxm05NB7VMW5i2mZFJIOg= X-Google-Smtp-Source: ABdhPJxuJmJEIurvS5SSZ8Rs5xjZ80Qq8Y5tlpFrmgPBRkEydRPUI/CzS/r8sVkt1ozH5/0xiHBnDA== X-Received: by 2002:a19:4891:: with SMTP id v139mr11154812lfa.435.1634299953816; Fri, 15 Oct 2021 05:12:33 -0700 (PDT) Original-Received: from [192.168.0.103] ([5.18.248.29]) by smtp.googlemail.com with ESMTPSA id a16sm489528lfb.236.2021.10.15.05.12.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Oct 2021 05:12:33 -0700 (PDT) In-Reply-To: <2b94e31a-1e20-ac07-e201-525e81b46363@inventati.org> Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::12e; envelope-from=raaahh@gmail.com; helo=mail-lf1-x12e.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:277111 Archived-At: On 15.10.2021 08:24, Manuel Uberti wrote: > On 14/10/21 23:55, Dmitry Gutov wrote: >> If we end up adding a new user option for this, what would you call it? > > Not sure actually. I see a project-ignores and a project-vc-ignores > already, maybe these can be leveraged instead of adding a new option? Both of these are for the default project-files behavior. How would we leverage them? >> We should probably try to handle this is a more transparent way, >> showing the exact error message to the user (when the buffer contains >> lots of output as well, the message becomes next to useless). >> >> Could you try applying the patch below, removing your recent >> customization and seeing whether the error message is better now? >> >> diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el >> index 79d2e050d9..7c3bb9229d 100644 >> --- a/lisp/progmodes/project.el >> +++ b/lisp/progmodes/project.el >> @@ -322,7 +322,15 @@ project--files-in-directory >>                (process-file-shell-command command nil t)) >>               (pt (point-min))) >>           (unless (zerop status) >> -          (error "File listing failed: %s" (buffer-string))) >> +          (goto-char (point-min)) >> +          (if (and >> +               (not (eql status 127)) >> +               (search-forward "Permission denied\n")) >> +              (let ((end (1- (point)))) >> +                (re-search-backward "\\`\\|\0") >> +                (error "File listing failed: %s" >> +                       (buffer-substring (1+ (point)) end))) >> +            (error "File listing failed: %s" (buffer-string)))) >>           (goto-char pt) >>           (while (search-forward "\0" nil t) >>             (push (buffer-substring-no-properties (1+ pt) (1- (point))) > > I did as you described and I got this message when I did C-u C-x p f: > > File listing failed: find: ‘./tmp/db’: Permission denied > > Two advantages of your approach: > - the message came up quickly > - it hinted directly to the problem Thanks for checking, I've pushed the patch (slightly tweaked). Perhaps ideally, we'd just ignore such directories, leaving it to the user to figure out why the files are not showing up. But 'find' doesn't make it easy. First, adding -o -type d -a ! -readable kinda works, but it's a GNU extension, not available on e.g, macOS, so it's a no-go. And even with the '-type d' qualifier it adds some runtime cost, somehow. I suppose we could just redirect stderr to null (like vc-git--out-ok does) and check for success by the presence of \0 chars in the output, but that's both quite lax and leaves us unable to print the error message when indeed some other kind of error happens. I guess redirecting stderr to a file is the remaining option...