Skip to content

Instantly share code, notes, and snippets.

@unhammer
Created May 27, 2018 08:32
Show Gist options
  • Save unhammer/5d73bc42bbeaf78455affe80c26fec8d to your computer and use it in GitHub Desktop.
Save unhammer/5d73bc42bbeaf78455affe80c26fec8d to your computer and use it in GitHub Desktop.
search notmuch mail from bbdb
(require 'bbdb)
(defun my-bbdb-notmuch-search (&optional record)
"Search for emails to/from RECORD (or current record if interactive)."
(interactive)
(let* ((record (or record (bbdb-current-record)))
(mails (bbdb-record-field record 'mail))
(query (combine-and-quote-strings mails " OR ")))
(notmuch-search query)))
(define-key bbdb-mode-map (kbd "F") 'my-bbdb-notmuch-search)
(defun my-bbdb-notmuch-search-from (&optional record)
"Search for emails from RECORD (or current record if interactive)."
(interactive)
(let* ((record (or record (bbdb-current-record)))
(mails (bbdb-record-field record 'mail))
(from:mails (mapcar (lambda (m) (concat "from:" m)) mails))
(query (combine-and-quote-strings from:mails " OR ")))
(notmuch-search query)))
(define-key bbdb-mode-map (kbd "f") 'my-bbdb-notmuch-search-from)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment