dajva / rg.el

Emacs search tool based on ripgrep
https://rgel.readthedocs.io
GNU General Public License v3.0
484 stars 41 forks source link

Allow to customize results buffer name #58

Closed muffinmad closed 5 years ago

muffinmad commented 5 years ago

If one work in two different projects simultaneously it is very handy to have search results separated by project.

This patch allows to separate search results by project like this:

(defun my/rg-buffer-name (&rest _mode_name)
  (let ((p (project-current)))
    (if p
        (format "*rg - %s*" (abbreviate-file-name (cdr p)))
      "*rg*")))

(custom-set-variables
  '(rg-buffer-name-function 'myd/rg-buffer-name))
coveralls commented 5 years ago

Coverage Status

Coverage decreased (-0.3%) to 84.19% when pulling 6dacc6c4a4b0a8f61ad274ef00a6064e73468581 on muffinmad:buffer-name into 450a1e54fb7c690166e61856b0d2002a71ccdf10 on dajva:master.

coveralls commented 5 years ago

Coverage Status

Coverage increased (+1.3%) to 85.853% when pulling 6bf0a15c648ec2bcc8990e46b3936fcf6ee4db7a on muffinmad:buffer-name into 450a1e54fb7c690166e61856b0d2002a71ccdf10 on dajva:master.

dajva commented 5 years ago

Are you using this with projectile or other project tool? Do you think it would be beneficial/possible to make a tighter integration with such tools?

I use it with built-in project tool. Code from README is from my setup. I think it's possible to integrate same tools used in rg-project-root - some predefined function to compose results buffer name based on those tools can be used as choice for rg-buffer-name.

Yeah, I don't know the inner workings on any of this tools although I started using projectile recently. Something like your example might be worth integrating into rg.el actually. Maybe for another pr...