[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#68697: Add option to not always use *grep* buffer when executing `gr
From: |
Juri Linkov |
Subject: |
bug#68697: Add option to not always use *grep* buffer when executing `grep' or `vc-git-grep' command |
Date: |
Thu, 25 Jan 2024 09:45:40 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) |
> The way `grep' and `vc-git-grep' works right now is that it will always
> output its result to a buffer called `*grep*'. So, if I perform another
> `grep' command, it will overwrite the previous grep result (unless I rename
> the buffer beforehand).
>
> I would like, at least, an option to create a new buffer each time a `grep'
> command is executed.
I'm using such config to create unique buffer names for
`compile' and `grep':
```
(setq compilation-buffer-name-function
(lambda (name-of-mode)
(generate-new-buffer-name
(concat "*" (downcase name-of-mode) "*"))))
```
Currently in bug#68570 we are discussing about adding an option
to `project-compilation-buffer-name-function' to create unique names
for project compilation buffers.
So the same way we could turn `compilation-buffer-name-function'
into a defcustom with an option for unique compilation/grep buffers.
> Maybe each new buffer could be given the name based on
> the regexp or the grep shell command used.
A name based on a regexp could be another option indeed.
Here is what I'm using for xref buffer names with a regexp:
```
(with-eval-after-load 'project
;; Instead of numbers append the regexp to the xref buffer name:
(define-advice project-find-regexp (:around (ofun &rest args) unique)
(require 'xref)
(let ((xref-buffer-name
(generate-new-buffer-name
(format "%s<%s>" xref-buffer-name (car args)))))
(apply ofun args))))
```