I ask only for the first step. After I have all the referenced message IDs I will start working on the notmuch side to find and tag!
Emacs
A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!
Get Emacs
Rules
- Posts should be emacs related
- Be kind please
- Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.
Emacs Resources
Emacs Tutorials
- Beginner’s Guide to Emacs
- Absolute Beginner's Guide to Emacs
- How to Learn Emacs: A Hand-drawn One-pager for Beginners
Useful Emacs configuration files and distributions
Quick pain-saver tip
You can simply loop over all the org files, open one by one, and search within each file individually using (while (re-seacrch-forward ...) ...).
I plan on searching hundreds of files (all notes) so... some way that does not open all of them would be preferable.
If opening a file is a problem, you can create temporary buffer and then use insert-file-contents
+ search + erase-buffer
.
find . -name "*.org" -exec sed -nr 's/.*notmuch:id:([^]\n]*).*$/\1/p' {} \;
With filenames:
for file in `find . -name "*.org"`; do sed -nr "s;.*notmuch:id:([^]\n]*).*$;$file: \1;p" "$file"; done
This is r/emacs !! Looking for an Emacs Lisp solution 😁
Emacs can run subprocesses just fine. I assumed you wanted a solution to a problem rather than an exercise.
It's an opportunity to learn more lisp!
I do currently have a shell script using ripgrep & notmuch-tag, but felt it could be an interesting problem to solve within Emacs :)
The lispy/emacs-like solution is to open each file, search it, and close it. Don't optimize too early. Build the simplest most straightforward implementation and then worry about performance. But understand why the most emacs-like solution fails.
- dired open needed dir
- M-x grep-find (regexp)
Comes to my mind