Re: [PATCH] emacs: allow functions in notmuch-show-stash-mlarchive-link-alist
authorMark Walters <markwalters1009@gmail.com>
Tue, 29 Apr 2014 10:14:13 +0000 (11:14 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:02:00 +0000 (10:02 -0800)
1d/11cb2887bd82eb88ec6fd13e3cbd746fd80f5e [new file with mode: 0644]

diff --git a/1d/11cb2887bd82eb88ec6fd13e3cbd746fd80f5e b/1d/11cb2887bd82eb88ec6fd13e3cbd746fd80f5e
new file mode 100644 (file)
index 0000000..efa3c80
--- /dev/null
@@ -0,0 +1,162 @@
+Return-Path: <m.walters@qmul.ac.uk>\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 2F858431FC0\r
+       for <notmuch@notmuchmail.org>; Tue, 29 Apr 2014 03:14:28 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.502\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.502 tagged_above=-999 required=5\r
+       tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+       NML_ADSP_CUSTOM_MED=1.2, 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 dVbWcJ0dFogr for <notmuch@notmuchmail.org>;\r
+       Tue, 29 Apr 2014 03:14:22 -0700 (PDT)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 746B3431FBD\r
+       for <notmuch@notmuchmail.org>; Tue, 29 Apr 2014 03:14:22 -0700 (PDT)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+       by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+       (envelope-from <m.walters@qmul.ac.uk>)\r
+       id 1Wf53G-00034b-Jz; Tue, 29 Apr 2014 11:14:17 +0100\r
+Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost)\r
+       by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
+       (envelope-from <m.walters@qmul.ac.uk>)\r
+       id 1Wf53G-0001sR-94; Tue, 29 Apr 2014 11:14:14 +0100\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] emacs: allow functions in\r
+       notmuch-show-stash-mlarchive-link-alist\r
+In-Reply-To: <1398761130-26865-1-git-send-email-jani@nikula.org>\r
+References: <1398761130-26865-1-git-send-email-jani@nikula.org>\r
+User-Agent: Notmuch/0.15.2+615~g78e3a93 (http://notmuchmail.org) Emacs/23.4.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Tue, 29 Apr 2014 11:14:13 +0100\r
+Message-ID: <874n1cbfyi.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Sender-Host-Address: 87.81.223.162\r
+X-QM-Geographic: According to ripencc,\r
+       this message was delivered by a machine in Britain (UK) (GB).\r
+X-QM-SPAM-Info: Sender has good ham record.  :)\r
+X-QM-Body-MD5: 83eca9b1039e3fc154bfd85401ef5673 (of first 20000 bytes)\r
+X-SpamAssassin-Score: -0.1\r
+X-SpamAssassin-SpamBar: /\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+       determine if it is\r
+       spam. We require at least 5.0 points to mark a message as spam.\r
+       This message scored -0.1 points.\r
+       Summary of the scoring: \r
+       * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+       provider *      (markwalters1009[at]gmail.com)\r
+       * -0.1 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\r
+Cc: Carl Worth <carl.d.worth@intel.com>\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: Tue, 29 Apr 2014 10:14:28 -0000\r
+\r
+\r
+This basically looks good to me. I think the docstring to the defcustom needs\r
+updating to mention functions and I would mildly prefer slightly\r
+different indentation in one place mentioned below (it may take it over\r
+80 chars so if you prefer leave it as it is)\r
+\r
+On Tue, 29 Apr 2014, Jani Nikula <jani@nikula.org> wrote:\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 |   27 ++++++++++++++++-----------\r
+>  1 files changed, 16 insertions(+), 11 deletions(-)\r
+>\r
+> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+> index df10d4b..b8bdbb9 100644\r
+> --- a/emacs/notmuch-show.el\r
+> +++ b/emacs/notmuch-show.el\r
+> @@ -183,7 +183,9 @@ each attachment handler is logged in buffers with names beginning\r
+>  These URIs are concatenated with the current message's\r
+>  Message-Id in `notmuch-show-stash-mlarchive-link'."\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 +2057,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\r
+> +     (cdr (assoc\r
+\r
+This is the indentation bit: I would prefer the "cdr" on the same line\r
+as "url".\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+\r
+\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-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.7.2.5\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r