unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Manuel Uberti <manuel.uberti@inventati.org>,
	emacs-devel <emacs-devel@gnu.org>
Subject: Re: project-find-file: switch to include non-tracked files
Date: Fri, 15 Oct 2021 15:12:32 +0300	[thread overview]
Message-ID: <3abfb5f5-a034-d234-fe6a-de00e01782b9@yandex.ru> (raw)
In-Reply-To: <2b94e31a-1e20-ac07-e201-525e81b46363@inventati.org>

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...



  reply	other threads:[~2021-10-15 12:12 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-04  8:33 project-find-file: switch to include non-tracked files Manuel Uberti
2021-10-04 11:24 ` Philip Kaludercic
2021-10-04 13:44   ` Stefan Kangas
2021-10-04 13:50     ` Manuel Uberti
2021-10-04 14:06       ` Stefan Kangas
2021-10-05 19:28         ` Dmitry Gutov
2021-10-05 19:47 ` Dmitry Gutov
2021-10-06  5:18   ` Manuel Uberti
2021-10-06  6:05     ` Dmitry Gutov
2021-10-06  6:12       ` Manuel Uberti
2021-10-14  0:47         ` Dmitry Gutov
2021-10-14  6:37           ` Manuel Uberti
2021-10-14 12:01             ` Dmitry Gutov
2021-10-14 12:06               ` Manuel Uberti
2021-10-14 21:55                 ` Dmitry Gutov
2021-10-15  5:24                   ` Manuel Uberti
2021-10-15 12:12                     ` Dmitry Gutov [this message]
2021-10-15 13:05                       ` Manuel Uberti
2021-10-15 13:25                         ` Dmitry Gutov
  -- strict thread matches above, loose matches on Subject: below --
2021-05-04 13:39 Manuel Uberti
2021-05-04 14:04 ` Stefan Kangas
2021-05-04 14:16 ` Dmitry Gutov
2021-05-04 14:55   ` Manuel Uberti
2021-05-04 16:43     ` Dmitry Gutov
2021-05-04 16:57       ` Manuel Uberti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3abfb5f5-a034-d234-fe6a-de00e01782b9@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=manuel.uberti@inventati.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).