branch: externals/urgrep commit 4fec944d5157fdb79f4918f619feb35e31ac3481 Author: Jim Porter <jporterb...@gmail.com> Commit: Jim Porter <jporterb...@gmail.com>
Fix output of git-grep and grep on Linux --- urgrep-tests.el | 2 +- urgrep.el | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/urgrep-tests.el b/urgrep-tests.el index 03812cc424..ec4d2c0e82 100644 --- a/urgrep-tests.el +++ b/urgrep-tests.el @@ -40,7 +40,7 @@ (ert-deftest urgrep-tests-command-git-grep () (let ((tool (assoc "git-grep" urgrep-tools)) - (common-args "git -c color.grep.filename\\=magenta grep -n --recurse-submodules --color ")) + (common-args "git --no-pager -c color.grep.filename\\=magenta -c color.grep.match\\=bold\\ red grep --color -n --recurse-submodules ")) (should (equal (urgrep-command "foo" :tool tool) (concat common-args "-F --heading --break -e foo"))) (should (equal (urgrep-command "foo" :tool tool :group nil) diff --git a/urgrep.el b/urgrep.el index 242afd1c0f..10451daa0d 100644 --- a/urgrep.el +++ b/urgrep.el @@ -90,8 +90,9 @@ ("git-grep" (executable-name "git") (vc-backend "Git") - (pre-arguments ("-c" "color.grep.filename=magenta" "grep" "-n" - "--recurse-submodules" "--color")) + (pre-arguments ("--no-pager" "-c" "color.grep.filename=magenta" + "-c" "color.grep.match=bold red" "grep" "--color" "-n" + "--recurse-submodules")) (post-arguments ("-e")) (group-arguments ((t ("--heading" "--break")))) (regexp-arguments ((nil ("-F")))) @@ -295,6 +296,15 @@ for MS shells." See `compilation-error-regexp-alist' for format details.") (defun urgrep-process-setup () + ;; XXX: Abstract this grep-specific code out so other tools can do stuff like + ;; this. + ;; `setenv' modifies `process-environment' let-bound in `compilation-start' + ;; Any TERM except "dumb" allows GNU grep to use `--color=auto'. + (setenv "TERM" "emacs-urgrep") + ;; GREP_COLOR is used in GNU grep 2.5.1, but deprecated in later versions. + (setenv "GREP_COLOR" "01;31") + ;; GREP_COLORS is used in GNU grep 2.5.2 and later versions. + (setenv "GREP_COLORS" "mt=01;31:fn=:ln=:bn=:se=:sl=:cx=:ne") (setq-local urgrep-num-matches-found 0 compilation-exit-message-function 'urgrep-exit-message))