ripgrep.el icon indicating copy to clipboard operation
ripgrep.el copied to clipboard

Highlighting doesn't work with ripgrep 0.5.1

Open vlevit opened this issue 7 years ago • 10 comments

For me highlighting in ripgrep.el is not working with ripgrep 0.5.1 (I haven't tried significantly older versions) but I'm not sure what is the actual reason: if it's environment or ripgrep, but it might be the latter as it seems upstream ripgrep was introducing incompatible changes related to color handling.

I made ripgrep.el work with colors on my machine with the following changes:

configuration:

(setq ripgrep-executable "rg --color=always")

ripgrep-filter in ripgrep.el

-          (while (re-search-forward "\033\\[30;43m\\(.*?\\)\033\\[[0-9]*m" end 1)
+          (while (re-search-forward "\033\\[m\033\\[31m\033\\[1m\\(.*?\\)\033\\[[0-9]*m" end 1)

I wonder if anyone has a similar issue?

Relying on colors escape sequences seems very fragile. There is a discussion on providing machine-parseable matching results in ripgrep: BurntSushi/ripgrep/issues/244

vlevit avatar Apr 15 '17 15:04 vlevit

Same issue with ripgrep 0.5.1. The workaround works for me. I suggest to make a PR for it.

seagle0128 avatar Apr 20 '17 01:04 seagle0128

Sure, I'll create a PR if @nlamirault provides a feedback.

vlevit avatar Apr 20 '17 18:04 vlevit

Any update for the PR?

seagle0128 avatar Aug 08 '17 09:08 seagle0128

@vlevit sure create a PR i will merge it. i'm on holiday :)

nlamirault avatar Aug 08 '17 10:08 nlamirault

Thanks! I think the issue can be closed if someone can confirm the change is working.

vlevit avatar Aug 10 '17 18:08 vlevit

This fix does not work for me. I still have this issue. With test in command-line, rg does have match highlighting for results.

Emacs version: GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.28) of 2018-03-09 ripgrep version ripgrep 0.8.1 -SIMD -AVX ripgrep.el version: MELPA latest version. And here is my config:

(use-package ripgrep
  :ensure t
  :ensure-system-package (rg . "cargo install ripgrep")
  :defer t
  :bind (:map ripgrep-prefix ("r" . ripgrep-regexp))
  :init
  (add-to-list 'ripgrep-arguments "--color=auto")
  (add-to-list 'display-buffer-alist
               '("^\\*ripgrep-search\\*" (display-buffer-below-selected)))
  )

stardiviner avatar Mar 15 '18 08:03 stardiviner

It works for me. My config is below

(use-package rg
  :init
  (add-hook 'after-init-hook #'rg-enable-default-bindings)
  (if (fboundp 'wgrep-ag-setup)
      (add-hook 'rg-mode-hook #'wgrep-ag-setup))
  :config
  (setq rg-custom-type-aliases nil)
  (setq rg-group-result t)
  (setq rg-show-columns t))

seagle0128 avatar Mar 15 '18 09:03 seagle0128

@seagle0128 They are two different packages, rg repo is here: https://github.com/dajva/rg.el

stardiviner avatar Mar 15 '18 12:03 stardiviner

After testing rg.el, it does support matching highlight. Thanks.

stardiviner avatar Mar 15 '18 12:03 stardiviner

@stardiviner Sorry. It's different.

seagle0128 avatar Mar 15 '18 12:03 seagle0128