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