Hi there,

I use orgmode links extensively. In particular, I have hundreds (our thousands) of links to emails (in notmuch). I would very much like to add a tag to any email that is being referenced from org.

So, what I need to do first is be able to find all matches of a regular expression in all my org files. Non-interactively.

I have been playing around with xref-matches-in-directory but that would not cover when multiple emails are mentioned in the same line…

I have been looking and looking but everything I find missed the non-interactive part.

So: What is the function to “search for this REGEX in FILES in DIR and return the first capture group”? (the regex has a capture group for the msgid)

The regex:

  (rx-to-string
   (rx "notmuch:id:"
       (group (1+ (not "]")))))
You are viewing a single thread.
View all comments View context
1 point

I plan on searching hundreds of files (all notes) so… some way that does not open all of them would be preferable.

permalink
report
parent
reply
1 point

If opening a file is a problem, you can create temporary buffer and then use insert-file-contents + search + erase-buffer.

permalink
report
parent
reply

Emacs

!emacs@communick.news

Create post

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

  • Windows
  • Mac OS X
  • GNU/Linux and BSD (Just get it from your distribution’s package manager)

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for “emacs” and “vi” link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

Community stats

  • 18

    Monthly active users

  • 562

    Posts

  • 2.4K

    Comments