Subject: Re: bug#75379: 30.0.93; project-find-regexp expects "C" or "en" locale

From: Juri Linkov <[email-masked]>
Date: Wed, 08 Jan 2025 09:48:03 +0200

>> This is a known problem.  Since the exit status is unreliable,
>> this is why 'grep-exit-message' has to use such a trick that
>> no output (i.e. '(not (buffer-modified-p))') indicates no matches:
>
> What about errors, though? Missing programs, unsupported flags, etc.
>
> Maybe Grep gets by without that due to the explicit probing step in
> grep-compute-defaults, but I'm not sure it's worth building up its
> counterpart in xref.el.

I see no problem with displaying all error messages as is in the xref buffer.

>>    (if (eq status 'exit)
>>        ;; This relies on the fact that `compilation-start'
>>        ;; sets buffer-modified to nil before running the command,
>>        ;; so the buffer is still unmodified if there is no output.
>>        (cond ((and (zerop code) (buffer-modified-p))
>> 	     (if (> grep-num-matches-found 0)
>>                   (cons (format (ngettext "finished with %d match found\n"
>>                                           "finished with %d matches found\n"
>>                                           grep-num-matches-found)
>>                                 grep-num-matches-found)
>>                         "matched")
>>                 '("finished with matches found\n" . "matched")))
>> 	    ((not (buffer-modified-p))
>> 	     '("finished with no matches found\n" . "no match"))
>> 
>>> Also, when we know the format of come messages we can parse the file name
>>> out of them  and create a button in the output buffer. Simply copying any
>>> unhandled messages removes that possibility.
>> Can we detect a file name in any message, e.g. by matching a path separator?
>
> We use 'grep --null', so the file name separator is a zero byte.
>
> We could scan the buffer to see whether there are any zero bytes (and if
> none - that would mean no matches), but the "binary file matches" message
> doesn't use that separator ¯\_(ツ)_/¯
>
> Not does it start with a file name, so we have to have a separate
> understanding about that message's structure anyway:
>
> grep: test/lisp/gnus/mml-sec-resources/pubring.kbx: binary file matches
> grep: test/lisp/gnus/mml-sec-resources/secring.gpg: binary file matches
> grep: test/lisp/gnus/mml-sec-resources/trustdb.gpg: binary file matches

In the worst case there will be no button, and I see no problem with this too.