Re: [PATCH] emacs: add missing paren to fix defun in notmuch-address.el.
authorKarl Fogel <kfogel@red-bean.com>
Fri, 4 Jul 2014 00:56:33 +0000 (19:56 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:03:23 +0000 (10:03 -0800)
e0/509cab1ee23c1946a2a18d437eb6a608a35eca [new file with mode: 0644]

diff --git a/e0/509cab1ee23c1946a2a18d437eb6a608a35eca b/e0/509cab1ee23c1946a2a18d437eb6a608a35eca
new file mode 100644 (file)
index 0000000..cbf3d15
--- /dev/null
@@ -0,0 +1,200 @@
+Return-Path: <kfogel@gmail.com>\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 1B3F9431FAF\r
+       for <notmuch@notmuchmail.org>; Thu,  3 Jul 2014 17:56:39 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.699\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001,\r
+       RCVD_IN_DNSWL_LOW=-0.7] 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 cKn2NNlR-FBY for <notmuch@notmuchmail.org>;\r
+       Thu,  3 Jul 2014 17:56:35 -0700 (PDT)\r
+Received: from mail-ig0-f172.google.com (mail-ig0-f172.google.com\r
+       [209.85.213.172]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id AFD7B431FAE\r
+       for <notmuch@notmuchmail.org>; Thu,  3 Jul 2014 17:56:35 -0700 (PDT)\r
+Received: by mail-ig0-f172.google.com with SMTP id hn18so8263255igb.17\r
+       for <notmuch@notmuchmail.org>; Thu, 03 Jul 2014 17:56:35 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=sender:from:to:cc:subject:references:reply-to:date:in-reply-to\r
+       :message-id:user-agent:mime-version:content-type;\r
+       bh=BKgDvd3dWuQBSuRg06t9jXorWKEHcSn9AA5UOOSML+Q=;\r
+       b=dS7SxtjGgngxWbJpe1poeH3kLgsHbcIdfEEvjlYoy7vC2WO6P7cTlRuBtiU5grsUlU\r
+       cq8A4J3MzqU2VgLkgdNowx3g1kpvN90LabZshmFliCzXpj2OWRCsZ0+tEOGk0bx1zEY0\r
+       MsbgdpqgOkORBw/zwBWPJLBpEpH8Z+EUqo76eCIy6wOxL3huaqjcui3YrmhlR0QqGANM\r
+       wVxzFvy/U4Rc4tn1HynP+8rZiJ94uEW2J//XsDO2nK2CSQJA2jNIBEvnJVrtc1hcgkOo\r
+       /MfL2UNh0/b7aXKKCelMqcXrIkqH4mzZApoTYTwa376fkOMRycSacHe/H4SJEDXILBaq\r
+       aSLw==\r
+X-Received: by 10.42.178.1 with SMTP id bk1mr5188239icb.75.1404435395197;\r
+       Thu, 03 Jul 2014 17:56:35 -0700 (PDT)\r
+Received: from ktab.red-bean.com\r
+       (74-92-190-113-Illinois.hfc.comcastbusiness.net. [74.92.190.113])\r
+       by mx.google.com with ESMTPSA id\r
+       u10sm57440285igz.21.2014.07.03.17.56.34 for <multiple recipients>\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Thu, 03 Jul 2014 17:56:34 -0700 (PDT)\r
+Sender: Karl Fogel <kfogel@gmail.com>\r
+From: Karl Fogel <kfogel@red-bean.com>\r
+To: Sebastian Lipp <bacuh@riseup.net>\r
+Subject: Re: [PATCH] emacs: add missing paren to fix defun in\r
+       notmuch-address.el.\r
+References: <87wqsfik5l.fsf@floss.red-bean.com>\r
+       <87mwtah2hd.fsf@zancas.localnet> <877gkeau42.fsf@floss.red-bean.com>\r
+       <m2ppy5v3mc.fsf@guru.guru-group.fi> <8738v1jtzc.fsf@nikula.org>\r
+       <87k3odgutd.fsf@zancas.localnet> <87ip3wbj7g.fsf@mcs.anl.gov>\r
+       <m2hajgxli5.fsf@guru.guru-group.fi> <87vc7vgbym.fsf@zancas.localnet>\r
+       <m2ehejykb1.fsf@guru.guru-group.fi>\r
+       <87pphmc604.fsf@verb.i-did-not-set--mail-host-address--so-tickle-me>\r
+Date: Thu, 03 Jul 2014 19:56:33 -0500\r
+In-Reply-To:\r
+ <87pphmc604.fsf@verb.i-did-not-set--mail-host-address--so-tickle-me>\r
+       (Sebastian Lipp's message of "Fri, 04 Jul 2014 02:38:51 +0200")\r
+Message-ID: <87oax6vt4u.fsf@ktab.red-bean.com>\r
+User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-Mailman-Approved-At: Fri, 04 Jul 2014 00:58:35 -0700\r
+Cc: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+Reply-To: Karl Fogel <kfogel@red-bean.com>\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: Fri, 04 Jul 2014 00:56:39 -0000\r
+\r
+Sebastian Lipp <bacuh@riseup.net> writes:\r
+>Tomi Ollila <tomi.ollila@iki.fi> writes:\r
+>> On Tue, Apr 09 2013, David Bremner wrote:\r
+>>> There seems to be a few warnings:\r
+>>>\r
+>>> In notmuch-bbdb/snarf-from:\r
+>>> notmuch-address.el:116:26:Warning: reference to free variable\r
+>>>     `bbdb-get-addresses-headers'\r
+>>>\r
+>>> In notmuch-bbdb/snarf-to:\r
+>>> notmuch-address.el:122:29:Warning: reference to free variable\r
+>>>     `bbdb-get-addresses-headers'\r
+>>>\r
+>>> In end of data:\r
+>>> notmuch-address.el:143:1:Warning: the following functions are not known to be\r
+>>>     defined: bbdb-get-addresses, bbdb-update-records, notmuch-show-get-header\r
+>>>\r
+>>> Do we need a few defvars?\r
+>>\r
+>> For the above set, something like:\r
+>>\r
+>> (defvar bbdb-get-addresses-headers)\r
+>>\r
+>> (declare-function notmuch-show-get-header "notmuch-show" (header &optional props))\r
+>>\r
+>> (declare-function bbdb-get-addresses "bbdb-com" \r
+>>   (only-first-address\r
+>>    uninteresting-senders\r
+>>    get-header-content-function\r
+>>    &rest get-header-content-function-args))\r
+>>\r
+>> (declare-function bbdb-update-records "bbdb-com" (addrs auto-create-p offer-to-create))\r
+>\r
+>As I'd like to see this in notmuch I made the change. The patch is\r
+>attached. As it is my first contribution to notmuch at all: Just tell me\r
+>if I'm supposed to do it in any other way.\r
+\r
+I think your patch includes much more than just the above, though.\r
+\r
+(It helps to include a log message with the patch -- then people can see\r
+what you intended the code change to be, and compare that against the\r
+code change the patch actually makes.)\r
+\r
+>diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el\r
+>index fa65cd5..ee7b169 100644\r
+>--- a/emacs/notmuch-address.el\r
+>+++ b/emacs/notmuch-address.el\r
+>@@ -113,6 +113,59 @@ to know how address selection is made by default."\r
+> (when (notmuch-address-locate-command notmuch-address-command)\r
+>   (notmuch-address-message-insinuate))\r
+> \r
+>+;; functions to add sender / recipients to BBDB\r
+>+\r
+>+(defvar bbdb-get-addresses-headers)\r
+\r
+I think it's good to include an initial value (even an invalid\r
+placeholder one, if the real initialization has not happened yet), and a\r
+doc string.  C-h f defvar RET will say more about how to do that.\r
+\r
+(By the way, this isn't a user-customizeable variable, right?  If it\r
+were, then `defcustom' would be better than `defvar'.)\r
+\r
+>+(declare-function notmuch-show-get-header "notmuch-show" (header &optional props))\r
+>+\r
+>+(declare-function bbdb-get-addresses "bbdb-com" \r
+>+  (only-first-address\r
+>+   uninteresting-senders\r
+>+   get-header-content-function\r
+>+   &rest get-header-content-function-args))\r
+>+\r
+>+(declare-function bbdb-update-records "bbdb-com" (addrs auto-create-p offer-to-create))\r
+\r
+At this point, your patch has accomplished what Tomi originally\r
+suggested.  But then the patch continues with what looks like\r
+substantive new code:\r
+\r
+>+(defun notmuch-bbdb/snarf-headers (headers)\r
+>+  ;; Helper function to avoid code duplication in the two below\r
+>+  ;; headers should have the same format as bbdb-get-addresses-headers\r
+>+\r
+>+  ;; bbdb-get-addresses reads these\r
+>+  ;; Ugh, pass-by-global\r
+>+  (let ((addrs (bbdb-get-addresses nil nil 'notmuch-bbdb/get-header-content))\r
+>+     (bbdb-get-addresses-headers headers) ; headers to read\r
+>+     (bbdb-gag-messages t)) ; suppress m/n processed message)\r
+>+    (bbdb-update-records addrs t t)))\r
+>+\r
+>+(defun notmuch-bbdb/snarf-from ()\r
+>+  "Import the sender of the current message into BBDB"\r
+>+  (interactive)\r
+>+  (notmuch-bbdb/snarf-headers\r
+>+   (list (assoc 'authors bbdb-get-addresses-headers))))\r
+>+\r
+>+(defun notmuch-bbdb/snarf-to ()\r
+>+  "Import all recipients of the current message into BBDB"\r
+>+  (interactive)\r
+>+  (notmuch-bbdb/snarf-headers\r
+>+   (list (assoc 'recipients bbdb-get-addresses-headers))))\r
+>+\r
+>+(defvar notmuch-bbdb/header-by-name\r
+>+  ;; both are case sensitive\r
+>+  '( ("From" . :From)\r
+>+     ("To" . :To)\r
+>+     ("CC" . :Cc)\r
+>+     ("BCC" . :Bcc)\r
+>+     ("Resent-From" . nil)\r
+>+     ("Reply-To" . nil)\r
+>+     ("Resent-To" . nil)\r
+>+     ("Resent-CC" . nil))\r
+>+  "Alist for dispatching header symbols as used by notmuch-show-get-header\r
+>+from strings as used by bbdb-get-addresses")\r
+>+\r
+>+(defun notmuch-bbdb/get-header-content (name)\r
+>+  (notmuch-show-get-header (cdr (assoc name notmuch-bbdb/header-by-name))))\r
+\r
+It looks like new code, but I suspect what actually happened is that\r
+this is just the original code, somehow mis-expressed as "+" lines in\r
+the patch.  Is that what happened?\r
+\r
+Best,\r
+-Karl\r