Subject: bug#22627: 25.1.50; Wishlist: It would be nice if the grep buffer had a history

From: Drew Adams <[email-masked]>
Date: Thu, 11 Feb 2016 14:04:13 -0800 (PST)

> > `g' works fine for redoing, but it would be great if you could return to
> > the previous (and next) with the normal `r'/`n' commands.
> 
> We could have an optional feature whereby the Grep buffer is named
> something like "*grep-the-command-line-used*".  Then as long as the
> next Grep command is different, you will have a new buffer for its
> output, and Bob's your uncle.

FWIW, in my `grep+.el':

 . You can automatically rename the current grep buffer to reflect the args
   using (add-hook 'grep-mode-hook 'grepp-rename-buffer-to-last-no-confirm)

 . You can rename it thus on demand using `r'.

 . `+' renames current grep buffer uniquely (without the args) and switches
   to buffer `*grep*'

 . `b' reads a grep buffer name and switches to that buffer.  A grep buffer
   here is any buffer whose name matches `'\\*grep\\*', which includes those
   whose names include the arguments.

You might want to do something similar for grep.el.

https://www.emacswiki.org/emacs/download/grep%2b.el