all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#68697: Add option to not always use *grep* buffer when executing `grep' or `vc-git-grep' command
@ 2024-01-24 20:16 Nafiz Islam
  2024-01-25  7:24 ` Eli Zaretskii
  2024-01-25  7:45 ` Juri Linkov
  0 siblings, 2 replies; 5+ messages in thread
From: Nafiz Islam @ 2024-01-24 20:16 UTC (permalink / raw)
  To: 68697

[-- Attachment #1: Type: text/plain, Size: 440 bytes --]

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. Maybe each new buffer could be given the name based on
the regexp or the grep shell command used.

[-- Attachment #2: Type: text/html, Size: 522 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#68697: Add option to not always use *grep* buffer when executing `grep' or `vc-git-grep' command
  2024-01-24 20:16 bug#68697: Add option to not always use *grep* buffer when executing `grep' or `vc-git-grep' command Nafiz Islam
@ 2024-01-25  7:24 ` Eli Zaretskii
  2024-01-25 14:58   ` Nafiz Islam
  2024-01-25  7:45 ` Juri Linkov
  1 sibling, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2024-01-25  7:24 UTC (permalink / raw)
  To: Nafiz Islam; +Cc: 68697

> From: Nafiz Islam <nafiz.islam1001@gmail.com>
> Date: Wed, 24 Jan 2024 15:16:12 -0500
> 
> 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.
> Maybe each new buffer could be given the name based on the regexp or the grep shell command
> used.

Did you try to define a compilation-buffer-name-function that would do
what you want?  Such a function can produce any buffer name you want.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#68697: Add option to not always use *grep* buffer when executing `grep' or `vc-git-grep' command
  2024-01-24 20:16 bug#68697: Add option to not always use *grep* buffer when executing `grep' or `vc-git-grep' command Nafiz Islam
  2024-01-25  7:24 ` Eli Zaretskii
@ 2024-01-25  7:45 ` Juri Linkov
  1 sibling, 0 replies; 5+ messages in thread
From: Juri Linkov @ 2024-01-25  7:45 UTC (permalink / raw)
  To: Nafiz Islam; +Cc: 68697

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





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#68697: Add option to not always use *grep* buffer when executing `grep' or `vc-git-grep' command
  2024-01-25  7:24 ` Eli Zaretskii
@ 2024-01-25 14:58   ` Nafiz Islam
  2024-01-25 15:12     ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Nafiz Islam @ 2024-01-25 14:58 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 68697

[-- Attachment #1: Type: text/plain, Size: 1079 bytes --]

Oh right, I can use compilation-buffer-name-function. My only issue is that
it doesn't have enough context to generate a meaningful buffer name; it
only takes a name-of-mode. A meaningful buffer name could consist of the
regexp or the entire grep shell command.

On Thu, Jan 25, 2024 at 2:24 AM Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Nafiz Islam <nafiz.islam1001@gmail.com>
> > Date: Wed, 24 Jan 2024 15:16:12 -0500
> >
> > 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.
> > Maybe each new buffer could be given the name based on the regexp or the
> grep shell command
> > used.
>
> Did you try to define a compilation-buffer-name-function that would do
> what you want?  Such a function can produce any buffer name you want.
>

[-- Attachment #2: Type: text/html, Size: 1486 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#68697: Add option to not always use *grep* buffer when executing `grep' or `vc-git-grep' command
  2024-01-25 14:58   ` Nafiz Islam
@ 2024-01-25 15:12     ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2024-01-25 15:12 UTC (permalink / raw)
  To: Nafiz Islam; +Cc: 68697

> From: Nafiz Islam <nafiz.islam1001@gmail.com>
> Date: Thu, 25 Jan 2024 09:58:10 -0500
> Cc: 68697@debbugs.gnu.org
> 
> Oh right, I can use compilation-buffer-name-function. My only issue is that it doesn't have enough
> context to generate a meaningful buffer name; it only takes a name-of-mode. A meaningful buffer
> name could consist of the regexp or the entire grep shell command.

You could include in the buffer name the default-directory instead.

Alternatively, you could advise "M-x grep" or write a wrapper around
it, and in that advice/wrapper bind some dynamic variable to the grep
command, and your compilation-buffer-name-function could then access
that variable.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-01-25 15:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-24 20:16 bug#68697: Add option to not always use *grep* buffer when executing `grep' or `vc-git-grep' command Nafiz Islam
2024-01-25  7:24 ` Eli Zaretskii
2024-01-25 14:58   ` Nafiz Islam
2024-01-25 15:12     ` Eli Zaretskii
2024-01-25  7:45 ` Juri Linkov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.