GNU bug report logs - #48321
27.2; Text copied from *grep* buffer has NUL (0x00) characters

Previous Next

Package: emacs;

Reported by: "R. Diez" <rdiezmail-emacs <at> yahoo.de>

Date: Sun, 9 May 2021 19:15:02 UTC

Severity: normal

Found in version 27.2

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 48321 in the body.
You can then email your comments to 48321 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#48321; Package emacs. (Sun, 09 May 2021 19:15:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to "R. Diez" <rdiezmail-emacs <at> yahoo.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 09 May 2021 19:15:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "R. Diez" <rdiezmail-emacs <at> yahoo.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.2; Text copied from *grep* buffer has NUL (0x00) characters
Date: Sun, 9 May 2021 21:14:38 +0200
Emacs' default "Grep Command" is "grep --color -nH --null -e ", which
includes option "--null". This means that grep is embedding an ASCII NUL
character (a binary 0x00) after the filenames.

This is what an rgrep text search occurrence looks like in the *grep* buffer:

./some/file.txt:123:some text line

The first ':' is actually a binary null, but the *grep* buffer hides this fact.

If you copy that text line to an Emacs text file buffer, it then looks like
this:

./some/file.txt^@123:some text line

The ^@ is the representation for the binary null, but that is easy to
miss in long text lines.

A text file with an embedded NUL character causes problems
everywhere. There are errors or warnings with Meld, Pluma, Geany,
Mousepad, and probably many more.

In my opinion, copying text from a *grep* buffer that looks like ":"
should not suddenly deliver a NUL character instead. That's just
unexpected and prone to problems down the line.

Stefan Monnier suggested the following:

----8<----8<----8<----
This "what you see in NOT what you get" is indeed undesirable.  I'm not
sure it's easy to fix in a reliable way in Emacs (beside not using
`--null` as Eli points out), but I suggest you `M-x report-emacs-bug`.
Maybe grep-mode can add a `filter-buffer-substring-function` that
converts those NUL into `:`.
----8<----8<----8<----

For more information, see the discussion starting with this mailing list
message:

Text copied from *grep* buffer has NUL (0x00) characters
https://lists.gnu.org/archive/html/help-gnu-emacs/2021-05/msg00360.html





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48321; Package emacs. (Tue, 11 May 2021 12:54:02 GMT) Full text and rfc822 format available.

Message #8 received at 48321 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: "R. Diez" <rdiezmail-emacs <at> yahoo.de>
Cc: 48321 <at> debbugs.gnu.org
Subject: Re: bug#48321: 27.2; Text copied from *grep* buffer has NUL (0x00)
 characters
Date: Tue, 11 May 2021 14:53:07 +0200
"R. Diez" <rdiezmail-emacs <at> yahoo.de> writes:

> In my opinion, copying text from a *grep* buffer that looks like ":"
> should not suddenly deliver a NUL character instead. That's just
> unexpected and prone to problems down the line.

Yup.  This is cleverly done by this bit in `grep-regexp-alist':

     nil nil
     (3 '(face nil display ":")))

That is -- the "highlight" we're applying is a `display' spec that says
that the separator should be displayed as ":".

Stefan's suggestion to transform the nul character in the filter in grep
wouldn't quite work, I think -- the filtering is done before the
matching.  So instead we need the thing that processes
`compilation-error-regexp-alist' to do the transformation after the
matches, I think?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48321; Package emacs. (Sat, 02 Jul 2022 16:00:02 GMT) Full text and rfc822 format available.

Message #11 received at 48321 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: "R. Diez" <rdiezmail-emacs <at> yahoo.de>
Cc: 48321 <at> debbugs.gnu.org
Subject: Re: bug#48321: 27.2; Text copied from *grep* buffer has NUL (0x00)
 characters
Date: Sat, 02 Jul 2022 17:59:26 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Stefan's suggestion to transform the nul character in the filter in grep
> wouldn't quite work, I think -- the filtering is done before the
> matching.  So instead we need the thing that processes
> `compilation-error-regexp-alist' to do the transformation after the
> matches, I think?

I've instead used kill-transform-function in Emacs 29 to translate the
nul chars to : chars.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 29.1, send any further explanations to 48321 <at> debbugs.gnu.org and "R. Diez" <rdiezmail-emacs <at> yahoo.de> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 02 Jul 2022 16:00:04 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 31 Jul 2022 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 267 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.