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 2D250429E32 for ; Fri, 2 May 2014 07:12:10 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.502 X-Spam-Level: X-Spam-Status: No, score=0.502 tagged_above=-999 required=5 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, NML_ADSP_CUSTOM_MED=1.2, 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 TXoWjV+BTdKg for ; Fri, 2 May 2014 07:12:05 -0700 (PDT) Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 8C5A7429E28 for ; Fri, 2 May 2014 07:12:05 -0700 (PDT) Received: from smtp.qmul.ac.uk ([138.37.6.40]) by mail2.qmul.ac.uk with esmtp (Exim 4.71) (envelope-from ) id 1WgEC1-0008B8-3q; Fri, 02 May 2014 15:12:03 +0100 Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost) by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) (envelope-from ) id 1WgEC0-0004k7-IJ; Fri, 02 May 2014 15:12:00 +0100 From: Mark Walters To: Jani Nikula , notmuch@notmuchmail.org Subject: Re: [PATCH v2] emacs: allow functions in notmuch-show-stash-mlarchive-link-alist In-Reply-To: <1398947711-12658-1-git-send-email-jani@nikula.org> References: <874n1cbfyi.fsf@qmul.ac.uk> <1398947711-12658-1-git-send-email-jani@nikula.org> User-Agent: Notmuch/0.15.2+615~g78e3a93 (http://notmuchmail.org) Emacs/23.4.1 (x86_64-pc-linux-gnu) Date: Fri, 02 May 2014 15:11:59 +0100 Message-ID: <87mwf09snk.fsf@qmul.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Sender-Host-Address: 87.81.223.162 X-QM-Geographic: According to ripencc, this message was delivered by a machine in Britain (UK) (GB). X-QM-SPAM-Info: Sender has good ham record. :) X-QM-Body-MD5: b19d7b63756c8108ddef355123d34352 (of first 20000 bytes) X-SpamAssassin-Score: -0.1 X-SpamAssassin-SpamBar: / X-SpamAssassin-Report: The QM spam filters have analysed this message to determine if it is spam. We require at least 5.0 points to mark a message as spam. This message scored -0.1 points. Summary of the scoring: * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider * (markwalters1009[at]gmail.com) * -0.1 AWL AWL: From: address is in the auto white-list X-QM-Scan-Virus: ClamAV says the message is clean 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: Fri, 02 May 2014 14:12:10 -0000 This version LGTM +1. Best wishes Mark On Thu, 01 May 2014, Jani Nikula wrote: > 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