Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlighting doesn't work with ripgrep 0.5.1 #20

Open
vlevit opened this issue Apr 15, 2017 · 10 comments
Open

Highlighting doesn't work with ripgrep 0.5.1 #20

vlevit opened this issue Apr 15, 2017 · 10 comments

Comments

@vlevit
Copy link
Contributor

vlevit commented Apr 15, 2017

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

@seagle0128
Copy link

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

seagle0128 added a commit to seagle0128/.emacs.d that referenced this issue Apr 20, 2017
@vlevit
Copy link
Contributor Author

vlevit commented Apr 20, 2017

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

@seagle0128
Copy link

Any update for the PR?

@nlamirault
Copy link
Owner

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

@vlevit
Copy link
Contributor Author

vlevit commented Aug 10, 2017

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

@stardiviner
Copy link

stardiviner commented Mar 15, 2018

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)))
  )

@seagle0128
Copy link

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))

@stardiviner
Copy link

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

@stardiviner
Copy link

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

@seagle0128
Copy link

@stardiviner Sorry. It's different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants