help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Nick Dokos
Subject: Re: Saving results of grep-find in the original interactive format ?
Date: Tue, 19 Nov 2019 17:38:29 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

jonetsu <jonetsu@teksavvy.com> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]