emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/gnorb d090df9 007/449: gnorb-bbdb.el: New function gnor


From: Stefan Monnier
Subject: [elpa] externals/gnorb d090df9 007/449: gnorb-bbdb.el: New function gnorb-bbdb-mail-search
Date: Fri, 27 Nov 2020 23:14:57 -0500 (EST)

branch: externals/gnorb
commit d090df9c951d56590702b6782a73e64a59404f10
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>

    gnorb-bbdb.el: New function gnorb-bbdb-mail-search
    
    Search for mails from the visible record(s). Currently only works for
    the notmuch search backend.
---
 README.md          |  3 +++
 lisp/gnorb-bbdb.el | 27 ++++++++++++++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index f785acc..ab7d1ed 100644
--- a/README.md
+++ b/README.md
@@ -24,3 +24,6 @@ Current functions include:
 * gnorb-bbdb-tag-agenda: Give BBDB records an org-tag field
   (customizable), then call this function on the current records(s) to
   open an Org agenda tags search using those tags.
+* gnorb-bbdb-mail-search: Call with current records(s) to search for
+  all mail messages from those records. Currently only implemented for
+  the notmuch search backend.
diff --git a/lisp/gnorb-bbdb.el b/lisp/gnorb-bbdb.el
index 7b88ee9..25d9109 100644
--- a/lisp/gnorb-bbdb.el
+++ b/lisp/gnorb-bbdb.el
@@ -66,9 +66,34 @@ records. If you want both, use \"C-u\" before the \"*\"."
          (org-tags-view nil tag-string))
       (error "No org-tags field present"))))
 
+
+(defun gnorb-bbdb-mail-search (records)
+  "Initiate a mail search from the BBDB buffer. Use the prefix
+arg to edit the search string first."
+  ;; Currently only notmuch implemented, do the same for mairix,
+  ;; namazu, etc.
+  (interactive (list (bbdb-do-records))) 
+  (unless (and (eq major-mode 'bbdb-mode)
+              (equal (buffer-name) bbdb-buffer-name))
+    (error "Only works in the BBDB buffer"))
+  (setq records (bbdb-record-list records))
+  (let* ((mails (cl-mapcan 'bbdb-record-mail records))
+        (search-string  
+         (mapconcat
+          (lambda (m)
+            (replace-regexp-in-string "\\." "\\\\." m))
+          mails " OR ")))
+    (require 'notmuch)
+    (when (equal current-prefix-arg '(4))
+       (setq search-string
+             (read-from-minibuffer "Search string: " search-string)))
+    (notmuch-search search-string)
+    (delete-other-windows)))  
+
 ;; (eval-after-load "gnorb-bbdb"
 ;;   '(progn
-;;      (define-key bbdb-mode-map (kbd "O") 'gnorb-bbdb-tag-agenda)))
+;;      (define-key bbdb-mode-map (kbd "O") 'gnorb-bbdb-tag-agenda)
+;;      (define-key bbdb-mode-map (kbd "S") 'gnorb-bbdb-mail-search)))
 
 
 



reply via email to

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