From: Juri Linkov <juri@linkov.net>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 44983@debbugs.gnu.org
Subject: bug#44983: Truncate long lines of grep output
Date: Sun, 06 Dec 2020 23:54:53 +0200 [thread overview]
Message-ID: <87zh2q61n6.fsf@mail.linkov.net> (raw)
In-Reply-To: <b46f7e79-7420-95a8-537c-d0035da56c83@yandex.ru> (Dmitry Gutov's message of "Sun, 6 Dec 2020 23:37:11 +0200")
>> OTOH, ripgrep has the suitable options:
>> -M, --max-columns NUM
>> Don’t print lines longer than this limit in bytes. Longer lines are omitted,
>> and only the number of matches in that line is printed.
>> --max-columns-preview
>> When the --max-columns flag is used, ripgrep will by default completely
>> replace any line that is too long with a message indicating that a matching
>> line was removed. When this flag is combined with --max-columns, a preview
>> of the line (corresponding to the limit size) is shown instead, where the
>> part of the line exceeding the limit is not shown.
>
> You can experiment with these Right Now(tm) by customizing
> xref-search-program-alist (as well as xref-search-program). They'll only
> affect commands that use xref-matches-in-files, though.
You mean adding "-M 200 --max-columns-preview" to xref-search-program-alist?
It works nice, thanks. Should this be added by default?
>> Wouldn't it be unthinkable to add support of ripgrep to grep.el?
>> This will allow switching to ripgrep when there is a need to
>> search in files with long lines.
>
> I'm fairly sure nothing in terms of politics is stopping us here, but if we
> wanted to update grep.el's abstractions to use different search programs,
> it looks like a bigger job to me.
>
> Though maybe you can get away with customizing a select number of
> variables? Like grep-template, grep-find-template, etc.
I customized grep-find-template to "find <D> <X> -type f <F> -print0 | sort -z |
xargs -0 -e rg -inH --color always --no-heading -M 200 --max-columns-preview -e <R>"
But this also requires customizing grep-match-regexp to the value
"\033\\[[0-9]*m\033\\[[0-9]*1m\033\\[[0-9]*1m\\(.*?\\)\033\\[[0-9]*0m"
provided by Simon in bug#41766.
And also required a small fix in grep.el:
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index dafba22f77..0a5fd6bf5d 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -412,7 +412,7 @@ grep-regexp-alist
(- mend beg))))))
nil nil
(3 '(face nil display ":")))
- ("^Binary file \\(.+\\) matches$" 1 nil nil 0 1))
+ ("^Binary file \\(.+\\) matches" 1 nil nil 0 1))
"Regexp used to match grep hits.
See `compilation-error-regexp-alist' for format details.")
next prev parent reply other threads:[~2020-12-06 21:54 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-01 8:45 bug#44983: Truncate long lines of grep output Juri Linkov
2020-12-01 15:02 ` Dmitry Gutov
2020-12-01 16:09 ` Eli Zaretskii
2020-12-01 16:46 ` Andreas Schwab
2020-12-01 18:26 ` Eli Zaretskii
2020-12-01 20:35 ` Juri Linkov
2020-12-02 3:21 ` Eli Zaretskii
2020-12-02 9:35 ` Juri Linkov
2020-12-02 10:28 ` Eli Zaretskii
2020-12-02 20:53 ` Juri Linkov
2020-12-03 14:47 ` Eli Zaretskii
2020-12-03 16:30 ` Rudolf Schlatte
2020-12-03 21:17 ` Juri Linkov
2020-12-05 19:47 ` Juri Linkov
2020-12-06 20:39 ` Juri Linkov
2020-12-06 21:37 ` Dmitry Gutov
2020-12-06 21:54 ` Juri Linkov [this message]
2020-12-07 2:41 ` Dmitry Gutov
2020-12-08 19:41 ` Juri Linkov
2020-12-09 3:00 ` Dmitry Gutov
2020-12-09 19:17 ` Juri Linkov
2020-12-09 20:06 ` Dmitry Gutov
2020-12-10 8:18 ` Juri Linkov
2020-12-10 20:48 ` Dmitry Gutov
2020-12-09 21:43 ` Jean Louis
2020-12-10 8:06 ` Juri Linkov
2020-12-10 10:08 ` Jean Louis
2020-12-12 20:42 ` Juri Linkov
2020-12-13 10:57 ` Jean Louis
2020-12-13 15:11 ` Eli Zaretskii
2020-12-13 15:37 ` Jean Louis
2020-12-13 20:17 ` Juri Linkov
2020-12-14 16:15 ` Eli Zaretskii
2020-12-14 20:09 ` Dmitry Gutov
2020-12-24 20:33 ` Juri Linkov
2020-12-24 23:38 ` Dmitry Gutov
2020-12-08 5:35 ` Richard Stallman
2020-12-08 19:15 ` Dmitry Gutov
2022-04-29 11:39 ` Lars Ingebrigtsen
2022-04-29 12:22 ` Eli Zaretskii
2022-04-29 12:41 ` Lars Ingebrigtsen
2022-04-29 13:08 ` Eli Zaretskii
2022-04-30 9:24 ` Lars Ingebrigtsen
2022-04-30 9:36 ` Lars Ingebrigtsen
2022-04-30 10:15 ` Eli Zaretskii
2022-04-30 11:04 ` Lars Ingebrigtsen
2022-04-29 16:02 ` Dmitry Gutov
2022-04-30 9:40 ` Lars Ingebrigtsen
2022-04-30 9:56 ` Lars Ingebrigtsen
2022-04-30 10:09 ` Eli Zaretskii
2022-04-30 10:59 ` Lars Ingebrigtsen
2022-04-30 11:02 ` Lars Ingebrigtsen
2022-04-30 11:12 ` Eli Zaretskii
2022-04-29 17:15 ` Juri Linkov
2022-04-30 0:27 ` Dmitry Gutov
2022-05-01 17:14 ` Juri Linkov
2020-12-01 20:34 ` Juri Linkov
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=87zh2q61n6.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=44983@debbugs.gnu.org \
--cc=dgutov@yandex.ru \
/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).