[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#44983: Truncate long lines of grep output
From: |
Juri Linkov |
Subject: |
bug#44983: Truncate long lines of grep output |
Date: |
Sun, 06 Dec 2020 23:54:53 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) |
>> 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.")
- bug#44983: Truncate long lines of grep output, (continued)
- bug#44983: Truncate long lines of grep output, Eli Zaretskii, 2020/12/01
- bug#44983: Truncate long lines of grep output, Juri Linkov, 2020/12/02
- bug#44983: Truncate long lines of grep output, Eli Zaretskii, 2020/12/02
- bug#44983: Truncate long lines of grep output, Juri Linkov, 2020/12/02
- bug#44983: Truncate long lines of grep output, Eli Zaretskii, 2020/12/03
- bug#44983: Truncate long lines of grep output, Rudolf Schlatte, 2020/12/03
- bug#44983: Truncate long lines of grep output, Juri Linkov, 2020/12/03
- bug#44983: Truncate long lines of grep output, Juri Linkov, 2020/12/05
- bug#44983: Truncate long lines of grep output, Juri Linkov, 2020/12/06
- bug#44983: Truncate long lines of grep output, Dmitry Gutov, 2020/12/06
- bug#44983: Truncate long lines of grep output,
Juri Linkov <=
- bug#44983: Truncate long lines of grep output, Dmitry Gutov, 2020/12/06
- bug#44983: Truncate long lines of grep output, Juri Linkov, 2020/12/08
- bug#44983: Truncate long lines of grep output, Dmitry Gutov, 2020/12/08
- bug#44983: Truncate long lines of grep output, Juri Linkov, 2020/12/09
- bug#44983: Truncate long lines of grep output, Dmitry Gutov, 2020/12/09
- bug#44983: Truncate long lines of grep output, Juri Linkov, 2020/12/10
- bug#44983: Truncate long lines of grep output, Dmitry Gutov, 2020/12/10
- bug#44983: Truncate long lines of grep output, Jean Louis, 2020/12/09
- bug#44983: Truncate long lines of grep output, Juri Linkov, 2020/12/10
- bug#44983: Truncate long lines of grep output, Jean Louis, 2020/12/10