--- /dev/null
+Return-Path: <jani@nikula.org>\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 37CAC431FAE\r
+ for <notmuch@notmuchmail.org>; Thu, 1 May 2014 05:35:23 -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=[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 kx-hfv-iA-wU for <notmuch@notmuchmail.org>;\r
+ Thu, 1 May 2014 05:35:17 -0700 (PDT)\r
+Received: from mail-ee0-f52.google.com (mail-ee0-f52.google.com\r
+ [74.125.83.52]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ 85A09431FBD for <notmuch@notmuchmail.org>; Thu, 1 May 2014 05:35:17 -0700\r
+ (PDT)\r
+Received: by mail-ee0-f52.google.com with SMTP id e53so2212396eek.11\r
+ for <notmuch@notmuchmail.org>; Thu, 01 May 2014 05:35:15 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+ :references;\r
+ bh=hn63RtN4ksbbIq6maaVEV9iWTw98tBIkU+7OaGeeQZU=;\r
+ b=V17SxbsS1csZcpKYPx151bGys5Mc9ypvfnXNwpOjt2598tpBLEgTcMthK/bBC43b4y\r
+ F6wleZH3rKH3+NF9fiE+12RYF2DJt4eCdTl02ese9pmoiAYNb4X6cjGeKgvrNM/CyWGZ\r
+ 4L9+ObZz2wVqNh2THPEnjncvSNTf5VCR1WHJIBnJOj0e4tAuT52EULlGtrAW0xdRrYvY\r
+ YLft9S0ZF+7spqIfgyVz4sTHJKJtPW3v6VcqGndv2BtUAaRFBKG/GEljFt3C1SWVNvPB\r
+ +p7MUkHefqtSXrAORbB4WPE2CDcr/h8hBWrvGMBIVedKx2P20XWT/Lwa4smAxVoDTCMf\r
+ DGGA==\r
+X-Gm-Message-State:\r
+ ALoCoQmxOjddCDnGqe74n/TtEfPkV5qK8jN+Mfisuk+SzTzDU4/tgO2+qLHKn8GpbAd8nhmEnUUK\r
+X-Received: by 10.15.42.138 with SMTP id u10mr9670761eev.7.1398947713934;\r
+ Thu, 01 May 2014 05:35:13 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
+ [88.195.111.91])\r
+ by mx.google.com with ESMTPSA id y7sm76035412eev.5.2014.05.01.05.35.12\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Thu, 01 May 2014 05:35:12 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2] emacs: allow functions in\r
+ notmuch-show-stash-mlarchive-link-alist\r
+Date: Thu, 1 May 2014 15:35:11 +0300\r
+Message-Id: <1398947711-12658-1-git-send-email-jani@nikula.org>\r
+X-Mailer: git-send-email 1.9.2\r
+In-Reply-To: <874n1cbfyi.fsf@qmul.ac.uk>\r
+References: <874n1cbfyi.fsf@qmul.ac.uk>\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, 01 May 2014 12:35:23 -0000\r
+\r
+Some archives may use a more complicated scheme for referring to\r
+messages than just concatenated url and message-id. In particular,\r
+patchwork requires a query to translate message-id to a patchwork\r
+patch id. Allow functions in notmuch-show-stash-mlarchive-link-alist\r
+to facilitate this.\r
+\r
+For example, one could use something like this for patchwork.\r
+\r
+(lambda (message-id)\r
+ (concat\r
+ "http://patchwork.example.com/patch/"\r
+ (nth 0\r
+ (split-string\r
+ (car (last (process-lines "pwclient" "search" "-n" "1"\r
+ "-m" (concat "<" message-id ">"))))))))\r
+---\r
+ emacs/notmuch-show.el | 40 +++++++++++++++++++++++++++-------------\r
+ 1 file changed, 27 insertions(+), 13 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index df10d4bad93b..10fc872141dc 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -180,10 +180,21 @@ each attachment handler is logged in buffers with names beginning\r
+ )\r
+ "List of Mailing List Archives to use when stashing links.\r
+ \r
+-These URIs are concatenated with the current message's\r
+-Message-Id in `notmuch-show-stash-mlarchive-link'."\r
++This list is used for generating a Mailing List Archive reference\r
++URI with the current message's Message-Id in\r
++`notmuch-show-stash-mlarchive-link'.\r
++\r
++If the cdr of the alist element is not a function, the cdr is\r
++expected to contain a URI that is concatenated with the current\r
++message's Message-Id to create a ML archive reference URI.\r
++\r
++If the cdr is a function, the function is called with the\r
++Message-Id as the argument, and the function is expected to\r
++return the ML archive reference URI."\r
+ :type '(alist :key-type (string :tag "Name")\r
+- :value-type (string :tag "URL"))\r
++ :value-type (choice\r
++ (string :tag "URL")\r
++ (function :tag "Function returning the URL")))\r
+ :group 'notmuch-show)\r
+ \r
+ (defcustom notmuch-show-stash-mlarchive-link-default "Gmane"\r
+@@ -2055,16 +2066,19 @@ This presumes that the message is available at the selected Mailing List Archive\r
+ If optional argument MLA is non-nil, use the provided key instead of prompting\r
+ the user (see `notmuch-show-stash-mlarchive-link-alist')."\r
+ (interactive)\r
+- (notmuch-common-do-stash\r
+- (concat (cdr (assoc\r
+- (or mla\r
+- (let ((completion-ignore-case t))\r
+- (completing-read\r
+- "Mailing List Archive: "\r
+- notmuch-show-stash-mlarchive-link-alist\r
+- nil t nil nil notmuch-show-stash-mlarchive-link-default)))\r
+- notmuch-show-stash-mlarchive-link-alist))\r
+- (notmuch-show-get-message-id t))))\r
++ (let ((url (cdr (assoc\r
++ (or mla\r
++ (let ((completion-ignore-case t))\r
++ (completing-read\r
++ "Mailing List Archive: "\r
++ notmuch-show-stash-mlarchive-link-alist\r
++ nil t nil nil\r
++ notmuch-show-stash-mlarchive-link-default)))\r
++ notmuch-show-stash-mlarchive-link-alist))))\r
++ (notmuch-common-do-stash\r
++ (if (functionp url)\r
++ (funcall url (notmuch-show-get-message-id t))\r
++ (concat url (notmuch-show-get-message-id t))))))\r
+ \r
+ (defun notmuch-show-stash-mlarchive-link-and-go (&optional mla)\r
+ "Copy an ML Archive URI for the current message to the kill-ring and visit it.\r
+-- \r
+1.9.2\r
+\r