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 6EA01431FB6 for ; Mon, 8 Apr 2013 18:12:40 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.301 X-Spam-Level: X-Spam-Status: No, score=0.301 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, 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 j4y2+773o4Kq for ; Mon, 8 Apr 2013 18:12:39 -0700 (PDT) Received: from mail-ie0-f171.google.com (mail-ie0-f171.google.com [209.85.223.171]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id B002F431FAE for ; Mon, 8 Apr 2013 18:12:39 -0700 (PDT) Received: by mail-ie0-f171.google.com with SMTP id e14so7873651iej.30 for ; Mon, 08 Apr 2013 18:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-type; bh=1AGfDchkhsWQvs66oviCZQsIxADueajtPP7OPxaaO6E=; b=svAB6DHkteCSRIExtN18wRdxHR5zGB/XnI5RvmGFEOldKG7nKZhTVBB9f0l8eG/ZTl 5cw7xTFtYm9z/o4v88MXLTX5nbT/oAd57AMuhEZ0z84CDeER/NdvX9r8JjLS1pOHPUjh g3BIKcRL9lzF5naMxbw6R3z0PKRbBCDvEH2R/68rlDIVGBMcMbxzOO5E1uKJt4+QYs0H t7eAc4uAg8nPL46IdJs0GapzUG40cbD/JsL0uFD0voaUB2apmWa3SS5n9B+taArPwX34 GfdX9pC3J88ZHqh0G/SzkHqvU8Gw4dtSgC70U0tYg5b/9mEMSqCjE3hkZm6gvKbPzK94 ck4Q== X-Received: by 10.50.114.37 with SMTP id jd5mr9345489igb.2.1365469957953; Mon, 08 Apr 2013 18:12:37 -0700 (PDT) Received: from localhost ([38.69.41.96]) by mx.google.com with ESMTPS id y5sm22761884igg.7.2013.04.08.18.12.36 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 08 Apr 2013 18:12:37 -0700 (PDT) Sender: Jed Brown From: Jed Brown To: David Bremner , Jani Nikula , Tomi Ollila , Karl Fogel , Daniel Bergey Subject: Re: [PATCH] emacs: add missing paren to fix defun in notmuch-address.el. In-Reply-To: <87k3odgutd.fsf@zancas.localnet> References: <87wqsfik5l.fsf@floss.red-bean.com> <87mwtah2hd.fsf@zancas.localnet> <877gkeau42.fsf@floss.red-bean.com> <8738v1jtzc.fsf@nikula.org> <87k3odgutd.fsf@zancas.localnet> User-Agent: Notmuch/0.15.2+78~g5404ac5 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-unknown-linux-gnu) Date: Mon, 08 Apr 2013 20:12:35 -0500 Message-ID: <87ip3wbj7g.fsf@mcs.anl.gov> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Cc: notmuch@notmuchmail.org 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: Tue, 09 Apr 2013 01:12:40 -0000 --=-=-= Content-Type: text/plain David Bremner writes: > Squashed sounds good to me too. Sorry I'm too lazy/busy at the moment to > do it myself. I tested the attached and it's working as expected. Sent as an attachment to preserve author information. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-emacs-functions-to-import-sender-or-recipient-into-B.patch >From 5404ac5bf13f8b5349d5b94f9f2000e9d1832b83 Mon Sep 17 00:00:00 2001 From: Daniel Bergey Date: Mon, 8 Apr 2013 19:55:04 -0500 Subject: [PATCH] emacs: functions to import sender or recipient into BBDB [v2] >From a show buffer, notmuch-bbdb/snarf-from imports the sender into bbdb. notmuch-bbdb/snarf-to imports all recipients. Newly imported contacts are reported in the minibuffer / Messages buffer. Both functions use the BBDB parser to recognize email address formats. [v2] Fixes missing close parenthesis in original. Spotted by Karl Fogel . --- emacs/notmuch-address.el | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el index 2bf762b..4eda098 100644 --- a/emacs/notmuch-address.el +++ b/emacs/notmuch-address.el @@ -96,6 +96,47 @@ line." (when (notmuch-address-locate-command notmuch-address-command) (notmuch-address-message-insinuate)) +;; functions to add sender / recipients to BBDB + +(defun notmuch-bbdb/snarf-headers (headers) + ;; Helper function to avoid code duplication in the two below + ;; headers should have the same format as bbdb-get-addresses-headers + + ;; bbdb-get-addresses reads these + ;; Ugh, pass-by-global + (let ((addrs (bbdb-get-addresses nil nil 'notmuch-bbdb/get-header-content)) + (bbdb-get-addresses-headers headers) ; headers to read + (bbdb-gag-messages t)) ; suppress m/n processed message) + (bbdb-update-records addrs t t))) + +(defun notmuch-bbdb/snarf-from () + "Import the sender of the current message into BBDB" + (interactive) + (notmuch-bbdb/snarf-headers + (list (assoc 'authors bbdb-get-addresses-headers)))) + +(defun notmuch-bbdb/snarf-to () + "Import all recipients of the current message into BBDB" + (interactive) + (notmuch-bbdb/snarf-headers + (list (assoc 'recipients bbdb-get-addresses-headers)))) + +(defvar notmuch-bbdb/header-by-name + ;; both are case sensitive + '( ("From" . :From) + ("To" . :To) + ("CC" . :Cc) + ("BCC" . :Bcc) + ("Resent-From" . nil) + ("Reply-To" . nil) + ("Resent-To" . nil) + ("Resent-CC" . nil)) + "Alist for dispatching header symbols as used by notmuch-show-get-header +from strings as used by bbdb-get-addresses") + +(defun notmuch-bbdb/get-header-content (name) + (notmuch-show-get-header (cdr (assoc name notmuch-bbdb/header-by-name)))) + ;; (provide 'notmuch-address) -- 1.8.2.1 --=-=-=--