all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 7378@debbugs.gnu.org
Subject: bug#7378: 23.2; grep buffer misinterprets result if filename contains colon character
Date: Thu, 08 Sep 2011 02:48:14 +0300	[thread overview]
Message-ID: <87obyvkgw9.fsf@mail.jurta.org> (raw)
In-Reply-To: <jwvhbfiimqr.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 15 Nov 2010 11:29:21 -0500")

> I.e. to resolve this kind of ambiguity, grep-mode would have to check
> all the possible interpretations and see which ones lead to an existing
> file name.  Such a change would require a good bit more work on grep.
> Furthermore such ambiguity would need to be resolved not only when
> the ":N:" comes from the file name but also when it comes from the
> file's content.

One more case where highlighting is currently incorrect is grepping mail
archives where each mail is located in a separate file with the timestamp
in its name like:

grep -inH -e "Date: " *
2011-08-31_11:57:03_1:7:Date: Wed, 31 Aug 2011 11:57:03 +0000
2011-08-31_12:08:20_2:7:Date: Wed, 31 Aug 2011 12:08:20 +0000

In the first line "2011-08-31_11" is highlighted as the file name and
"57" as the line number.  In the second line "2011-08-31_12:08:20_2" is
highlighted as the file name (correctly) and "7" as the line number
(the difference is because "03" has the leading zero).

I see no way to match file names and line numbers correctly
with a regexp in such cases.

The only way to do this reliably with GNU grep is to ask it to output
escape sequences around file names and line numbers.  From `man grep':

  fn=35 SGR substring for file names prefixing any content line.
  The default is a magenta text foreground over the terminal's
  default background.

  ln=32 SGR substring for line numbers prefixing any content line.
  The default is a green text foreground over the terminal's
  default background.

Then `grep-filter' could find these escape sequences and highlight,
and `grep-regexp-alist' could calculate column positions of the highlighted
file names and line numbers.

Is it worth a try?





  reply	other threads:[~2011-09-07 23:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-11 20:47 bug#7378: 23.2; grep buffer misinterprets result if filename contains colon character Robin Green
2010-11-11 23:09 ` Stefan Monnier
2010-11-13  9:39   ` Robin Green
2010-11-15 16:29     ` Stefan Monnier
2011-09-07 23:48       ` Juri Linkov [this message]
2011-09-08  2:52         ` Stefan Monnier
2017-06-28 12:00           ` npostavs
2017-07-20  0:04             ` bug#6843: " npostavs

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

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

  git send-email \
    --in-reply-to=87obyvkgw9.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=7378@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.