[PATCH] emacs: functions to import sender or recipient into BBDB
authorDaniel Bergey <bergey@alum.mit.edu>
Thu, 26 Jul 2012 20:09:17 +0000 (16:09 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:48:37 +0000 (09:48 -0800)
6e/b90dd132e34137d23a77363a90dd639c523a6c [new file with mode: 0644]

diff --git a/6e/b90dd132e34137d23a77363a90dd639c523a6c b/6e/b90dd132e34137d23a77363a90dd639c523a6c
new file mode 100644 (file)
index 0000000..b848946
--- /dev/null
@@ -0,0 +1,117 @@
+Return-Path: <bergey@alum.mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 4B549431FAF\r
+       for <notmuch@notmuchmail.org>; Thu, 26 Jul 2012 13:09:20 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id pRUhVsNA2P8e for <notmuch@notmuchmail.org>;\r
+       Thu, 26 Jul 2012 13:09:19 -0700 (PDT)\r
+Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com\r
+       [66.111.4.27])\r
+       (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id A2B83431FAE\r
+       for <notmuch@notmuchmail.org>; Thu, 26 Jul 2012 13:09:19 -0700 (PDT)\r
+Received: from compute6.internal (compute6.nyi.mail.srv.osa [10.202.2.46])\r
+       by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id C9F152095D\r
+       for <notmuch@notmuchmail.org>; Thu, 26 Jul 2012 16:09:18 -0400 (EDT)\r
+Received: from frontend1.nyi.mail.srv.osa ([10.202.2.160])\r
+       by compute6.internal (MEProxy); Thu, 26 Jul 2012 16:09:18 -0400\r
+DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=\r
+       messagingengine.com; h=from:to:subject:date:message-id\r
+       :mime-version:content-type; s=smtpout; bh=3nqgk+45uXngWez2eLZIny\r
+       DNj3s=; b=Xa9kb+ggRgEVrk1tUWCfW9HQYqar8j+IlchDbN3XMTSpBGtqFCvAAm\r
+       mOvq7i/YZg5GvGreGfi/Lpwc6RnN0HbQ17JZJAgZNS/7Yb/UxestcfaZVVmi4xeR\r
+       VwX2Qm5ahyogdYZNnko6FNvcse/cy4dixbYZcUZClt9cU2Ak1ugxU=\r
+X-Sasl-enc: FJlfgQsaBc+25vmAKS5SUJhl4RxULsKA6LGy3h7IQn0z 1343333358\r
+Received: from localhost (unknown [66.80.90.109])\r
+       by mail.messagingengine.com (Postfix) with ESMTPA id 89BCE8E03C0\r
+       for <notmuch@notmuchmail.org>; Thu, 26 Jul 2012 16:09:18 -0400 (EDT)\r
+From: Daniel Bergey <bergey@alum.mit.edu>\r
+To: Notmuch Mail List <notmuch@notmuchmail.org>\r
+Subject: [PATCH] emacs: functions to import sender or recipient into BBDB\r
+User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.4.1\r
+       (i486-pc-linux-gnu)\r
+Date: Thu, 26 Jul 2012 16:09:17 -0400\r
+Message-ID: <87lii62sk2.fsf@wonderlust.lan>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 26 Jul 2012 20:09:20 -0000\r
+\r
+>From a show buffer, bbdb/notmuch-snarf-from imports the sender into\r
+bbdb.  bbdb/notmuch-snarf-to attempts to import all recipients.  BBDB\r
+displays a buffer with each contact; C-g displays the next contact, or\r
+returns to the notmuch-show buffer.\r
+\r
+Both functions assume that email contacts are seperated by commas.  If a\r
+comma is included in a name, it will try to make two separate\r
+contacts.\r
+---\r
+This is my first notmuch patch.  Comments very welcome.\r
+\r
+ emacs/notmuch-show.el |   28 ++++++++++++++++++++++++++++\r
+ 1 file changed, 28 insertions(+)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 6335d45..3bc1da0 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1895,6 +1895,34 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')."\r
+                      (button-get button :notmuch-filename)\r
+                      (button-get button :notmuch-content-type)))))))\r
+ \r
++;; bbdb interaction functions, awaiting user keybindings\r
++\r
++(defun bbdb/snarf-between-commas ()\r
++  ; What about names written "Surname, First M" <user@server.tld>?\r
++  (goto-char (point-min))\r
++  (let ((comma (point)))\r
++    (while (search-forward "," nil "end")\r
++      (bbdb-snarf-region comma (point))\r
++      (setq comma (point)))\r
++    (bbdb-snarf-region comma (point)) ; last entry\r
++   ))\r
++\r
++(defun bbdb/notmuch-snarf-header (header)\r
++  (let ((text (notmuch-show-get-header header)))\r
++    (with-temp-buffer\r
++      (insert text)\r
++      (bbdb/snarf-between-commas))))\r
++\r
++(defun bbdb/notmuch-snarf-from ()\r
++  "Import the sender of the current message into BBDB"\r
++  (interactive)\r
++  (bbdb/notmuch-snarf-header :From))\r
++\r
++(defun bbdb/notmuch-snarf-to ()\r
++  "Import all recipients of the current message into BBDB"\r
++  (interactive)\r
++  (bbdb/notmuch-snarf-header :To))\r
++\r
+ ;;\r
+ \r
+ (provide 'notmuch-show)\r
+-- \r
+1.7.10.4\r
+\r