unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: functions to import sender or recipient into BBDB
@ 2012-07-26 20:09 Daniel Bergey
  2012-10-19 22:52 ` Ethan Glasser-Camp
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Bergey @ 2012-07-26 20:09 UTC (permalink / raw)
  To: Notmuch Mail List

From a show buffer, bbdb/notmuch-snarf-from imports the sender into
bbdb.  bbdb/notmuch-snarf-to attempts to import all recipients.  BBDB
displays a buffer with each contact; C-g displays the next contact, or
returns to the notmuch-show buffer.

Both functions assume that email contacts are seperated by commas.  If a
comma is included in a name, it will try to make two separate
contacts.
---
This is my first notmuch patch.  Comments very welcome.

 emacs/notmuch-show.el |   28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 6335d45..3bc1da0 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1895,6 +1895,34 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')."
 		       (button-get button :notmuch-filename)
 		       (button-get button :notmuch-content-type)))))))
 
+;; bbdb interaction functions, awaiting user keybindings
+
+(defun bbdb/snarf-between-commas ()
+  ; What about names written "Surname, First M" <user@server.tld>?
+  (goto-char (point-min))
+  (let ((comma (point)))
+    (while (search-forward "," nil "end")
+      (bbdb-snarf-region comma (point))
+      (setq comma (point)))
+    (bbdb-snarf-region comma (point)) ; last entry
+   ))
+
+(defun bbdb/notmuch-snarf-header (header)
+  (let ((text (notmuch-show-get-header header)))
+    (with-temp-buffer
+      (insert text)
+      (bbdb/snarf-between-commas))))
+
+(defun bbdb/notmuch-snarf-from ()
+  "Import the sender of the current message into BBDB"
+  (interactive)
+  (bbdb/notmuch-snarf-header :From))
+
+(defun bbdb/notmuch-snarf-to ()
+  "Import all recipients of the current message into BBDB"
+  (interactive)
+  (bbdb/notmuch-snarf-header :To))
+
 ;;
 
 (provide 'notmuch-show)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-04-06 19:43 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-26 20:09 [PATCH] emacs: functions to import sender or recipient into BBDB Daniel Bergey
2012-10-19 22:52 ` Ethan Glasser-Camp
2012-10-20  9:14   ` Tomi Ollila
2012-10-20 18:23     ` Jameson Graef Rollins
2012-10-20 19:35       ` Tomi Ollila
2012-10-20 21:10         ` Jani Nikula
2012-10-21 12:16           ` Tomi Ollila
2012-11-19  0:08   ` Daniel Bergey
2013-02-07 18:51     ` Daniel Bergey
2013-02-19  7:24       ` Tomi Ollila
2013-03-31 18:20         ` Daniel Bergey
2013-03-31 18:40           ` Tomi Ollila
2013-04-06 11:37           ` David Bremner
2013-04-06 19:43             ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).