Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 4B549431FAF for ; Thu, 26 Jul 2012 13:09:20 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pRUhVsNA2P8e for ; Thu, 26 Jul 2012 13:09:19 -0700 (PDT) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id A2B83431FAE for ; Thu, 26 Jul 2012 13:09:19 -0700 (PDT) Received: from compute6.internal (compute6.nyi.mail.srv.osa [10.202.2.46]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id C9F152095D for ; Thu, 26 Jul 2012 16:09:18 -0400 (EDT) Received: from frontend1.nyi.mail.srv.osa ([10.202.2.160]) by compute6.internal (MEProxy); Thu, 26 Jul 2012 16:09:18 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=from:to:subject:date:message-id :mime-version:content-type; s=smtpout; bh=3nqgk+45uXngWez2eLZIny DNj3s=; b=Xa9kb+ggRgEVrk1tUWCfW9HQYqar8j+IlchDbN3XMTSpBGtqFCvAAm mOvq7i/YZg5GvGreGfi/Lpwc6RnN0HbQ17JZJAgZNS/7Yb/UxestcfaZVVmi4xeR VwX2Qm5ahyogdYZNnko6FNvcse/cy4dixbYZcUZClt9cU2Ak1ugxU= X-Sasl-enc: FJlfgQsaBc+25vmAKS5SUJhl4RxULsKA6LGy3h7IQn0z 1343333358 Received: from localhost (unknown [66.80.90.109]) by mail.messagingengine.com (Postfix) with ESMTPA id 89BCE8E03C0 for ; Thu, 26 Jul 2012 16:09:18 -0400 (EDT) From: Daniel Bergey To: Notmuch Mail List Subject: [PATCH] emacs: functions to import sender or recipient into BBDB User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.4.1 (i486-pc-linux-gnu) Date: Thu, 26 Jul 2012 16:09:17 -0400 Message-ID: <87lii62sk2.fsf@wonderlust.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Jul 2012 20:09:20 -0000 >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" ? + (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