Saving results of grep-find in the original interactive format ?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Saving results of grep-find in the original interactive format ?

jonetsu
Is it possible to save the results of a grep-find search in such a
file format that would allow to load it back and have all the results
clickable again so that instantly it becomes possible to jump to those
files quickly as it was in the first place right after the search ?


Reply | Threaded
Open this post in threaded view
|

Re: Saving results of grep-find in the original interactive format ?

Nick Dokos-3
jonetsu <[hidden email]> writes:

> Is it possible to save the results of a grep-find search in such a
> file format that would allow to load it back and have all the results
> clickable again so that instantly it becomes possible to jump to those
> files quickly as it was in the first place right after the search ?

I just saved the grep buffer into a a file and killed the buffer. When
I opened the file again, everything was as before: you can jump to any
of the found places. What makes this possible is the first line of the
buffer that makes sure that when you open the file, it is in grep-mode
and the current directory is set to wherever the search was executed
in the first place:

,----
| -*- mode: grep; default-directory: "~/src/emacs/org/org-mode/worktrees/foo/" -*-
| Grep started at Tue Nov 19 17:29:57
|
| grep --color -nH --null -e foo lisp/*.el
| lisp/ob-core.el^@456:their `org-babel-default-header-args:foo' variable.
| lisp/ob-core.el^@1571:#+PROPERTY: var foo=1, bar=2"
| lisp/ox-texinfo.el^@851:   ((org-element-property :footnote-section-p headline) nil)
| ...
|
| Grep finished with 860 matches found at Tue Nov 19 17:29:57
`----

I replaced real NUL chars above with the string "^@" because gnus
warned me of potential problems when sending mail with NULs: in the
real file, they should be real NUL chars.

--
Nick

"There are only two hard problems in computer science: cache
invalidation, naming things, and off-by-one errors." -Martin Fowler


Reply | Threaded
Open this post in threaded view
|

Re: Saving results of grep-find in the original interactive format ?

jonetsu
On Tue, 19 Nov 2019 17:38:29 -0500
Nick Dokos <[hidden email]> wrote:

> I just saved the grep buffer into a a file and killed the buffer. When
> I opened the file again, everything was as before: you can jump to any
> of the found places.

Thanks !  This great and so much useful.

Cheers.