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

Only rg-use-old-defaults seems to work with result buffer #149

Closed
PyB1l opened this issue Feb 19, 2023 · 6 comments
Closed

Only rg-use-old-defaults seems to work with result buffer #149

PyB1l opened this issue Feb 19, 2023 · 6 comments

Comments

@PyB1l
Copy link

PyB1l commented Feb 19, 2023

In emacs 28.2 new defaults seem not to be working as expected in results buffer.

Although a get results when pressing RET on result I get a popup that asks me to manually set the path for the file.

On the other hand, rg-use-old-defaults seem to work as expected, but is there any workaround to use the new defaults and have the
compilation / grep buffer work as usual?

@dajva
Copy link
Owner

dajva commented Feb 23, 2023

Works fine for me. Could you post the result of running M-x rg-print-environment?

@PyB1l
Copy link
Author

PyB1l commented Feb 24, 2023

I get the following error:

Not enough arguments for format string

GNU Emacs 28.2 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2023-01-30

@dajva
Copy link
Owner

dajva commented Feb 24, 2023

Sounds like you have some sort of error in your environment. Everything works fine for me in emacs 28.2. I suggest you try with the latest version of this package from master and use a clean emacs and see how it works.

@PyB1l
Copy link
Author

PyB1l commented Feb 25, 2023

Is it possible to happen due to xterm compilation filter?
My init.el looks like this

(use-package compile
  :config
  (progn
    (setq compilation-scroll-output t)))

(use-package xterm-color
  :ensure t
  :functions (xterm-color-filter my/advice-compilation-filter)
  :config
  (progn
    (setq compilation-environment '("TERM=xterm-256color"))
    (add-hook 'shell-mode-hook
          (lambda ()
            ;; Disable font-locking in this buffer to improve performance
            (font-lock-mode -1)
            ;; Prevent font-locking from being re-enabled in this buffer
            (make-local-variable 'font-lock-function)
            (setq font-lock-function (lambda (_) nil))
            (add-hook 'comint-preoutput-filter-functions 'xterm-color-filter nil t)))
    (defun my/advice-compilation-filter (f proc string)
      (funcall f proc (xterm-color-filter string)))
    (advice-add 'compilation-filter :around #'my/advice-compilation-filter)))

(use-package rg
  :demand t
  :commands (rg-use-old-defaults rg-enable-menu)
  :config
  (rg-use-old-defaults)
  (rg-enable-menu)
  (setq rg-buffer-name
       (lambda ()
	 (let ((p (project-current)))
	   (if p
	       (format "rg %s" (abbreviate-file-name (cdr p)))
	     "rg")))))

(when (executable-find "rg")
  (setq grep-program "rg"))

(use-package wgrep
  :custom
  (wgrep-auto-save-buffer t)
  (wgrep-change-readonly-file t))

@dajva
Copy link
Owner

dajva commented Feb 25, 2023

This is a known issue with xterm-color modifying the color sequences used by this package.
The main problem IMO, is that xterm-color is integrated by advising compilation-filter which breaks modes like this that is not supposed to work with xterm-color. There is a pretty long discussion in #65 in case you want to dig into the details and the maintainer of xterm-color and me does not really agree on the problem here.
My opinion is that you should probably hook in xterm-color the "normal" way by adding a compilation-filter-hook instead of using advise. Not sure how that works with that package TBH but in that way you should be able to make this package work even though it does not use the highlighting from xterm-color.

@dajva
Copy link
Owner

dajva commented Mar 2, 2023

Closing this since there is not anything to fix in this package.

@dajva dajva closed this as completed Mar 2, 2023
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

2 participants