From dab97dd11b0e5886c4c401fff917474ee757c2aa Mon Sep 17 00:00:00 2001 From: Elis Axelsson Date: Wed, 3 May 2017 09:57:24 +0200 Subject: [PATCH] Make post-fields-lambda take named parameters --- webpaste.el | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/webpaste.el b/webpaste.el index 58bb624..4ff653e 100644 --- a/webpaste.el +++ b/webpaste.el @@ -94,10 +94,12 @@ each run.") (defvar webpaste/providers-default-post-field-lambda - (lambda (text post-field post-data) - (cl-pushnew (cons post-field text) post-data) + (cl-function (lambda (&key text + post-field + (post-data '())) + (cl-pushnew (cons post-field text) post-data) - post-data) + post-data)) "Predefined lambda for building post fields.") @@ -143,8 +145,9 @@ Optional params: you need a provider that isn't allowed to failover. :post-field-lambda Function that builds and returns the post data that should be - sent to the provider. It should accept the parameter TEXT, - POST-FIELD and POST-DATA. + sent to the provider. It should accept named parameters by + the names TEXT, POST-FIELD and POST-DATA. POST-DATA should + default to `nil' or empty list. TEXT contains the data that should be sent. POST-FIELD cointains the name of the field to be sent. @@ -159,7 +162,10 @@ Optional params: ;; Do request (request uri :type type - :data (funcall post-field-lambda text post-field post-data) + :data (funcall post-field-lambda + :text text + :post-field post-field + :post-data post-data) :parser parser :success success-lambda :sync sync @@ -210,12 +216,12 @@ Optional params: ,(webpaste-provider :uri "https://api.github.com/gists" :post-field nil - :post-field-lambda (lambda (text post-field post-data) + :post-field-lambda (cl-function (lambda (&key text post-field (post-data '())) (json-encode `(("description" . "Pasted from Emacs with webpaste.el") ("public" . "false") ("files" . (("file.txt" . - (("content" . ,text)))))))) + (("content" . ,text))))))))) :success-lambda (cl-function (lambda (&key data &allow-other-keys) (when data (webpaste-return-url