[PATCH] emacs: allow functions in notmuch-show-stash-mlarchive-link-alist
Mark Walters
markwalters1009 at gmail.com
Tue Apr 29 03:14:13 PDT 2014
This basically looks good to me. I think the docstring to the defcustom needs
updating to mention functions and I would mildly prefer slightly
different indentation in one place mentioned below (it may take it over
80 chars so if you prefer leave it as it is)
On Tue, 29 Apr 2014, Jani Nikula <jani at nikula.org> 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 | 27 ++++++++++++++++-----------
> 1 files changed, 16 insertions(+), 11 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index df10d4b..b8bdbb9 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -183,7 +183,9 @@ each attachment handler is logged in buffers with names beginning
> These URIs are concatenated with the current message's
> Message-Id in `notmuch-show-stash-mlarchive-link'."
> :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 +2057,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
This is the indentation bit: I would prefer the "cdr" on the same line
as "url".
Best wishes
Mark
> + (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.7.2.5
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
More information about the notmuch
mailing list