Make post-fields-lambda take named parameters

master
Elis Axelsson 9 years ago
parent 0fa48e2387
commit dab97dd11b
No known key found for this signature in database
GPG Key ID: D57EFA625C9A925F
  1. 20
      webpaste.el

@ -94,10 +94,12 @@ each run.")
(defvar webpaste/providers-default-post-field-lambda (defvar webpaste/providers-default-post-field-lambda
(lambda (text post-field post-data) (cl-function (lambda (&key text
post-field
(post-data '()))
(cl-pushnew (cons post-field text) post-data) (cl-pushnew (cons post-field text) post-data)
post-data) post-data))
"Predefined lambda for building post fields.") "Predefined lambda for building post fields.")
@ -143,8 +145,9 @@ Optional params:
you need a provider that isn't allowed to failover. you need a provider that isn't allowed to failover.
:post-field-lambda Function that builds and returns the post data that should be :post-field-lambda Function that builds and returns the post data that should be
sent to the provider. It should accept the parameter TEXT, sent to the provider. It should accept named parameters by
POST-FIELD and POST-DATA. 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. TEXT contains the data that should be sent.
POST-FIELD cointains the name of the field to be sent. POST-FIELD cointains the name of the field to be sent.
@ -159,7 +162,10 @@ Optional params:
;; Do request ;; Do request
(request uri (request uri
:type type :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 :parser parser
:success success-lambda :success success-lambda
:sync sync :sync sync
@ -210,12 +216,12 @@ Optional params:
,(webpaste-provider ,(webpaste-provider
:uri "https://api.github.com/gists" :uri "https://api.github.com/gists"
:post-field nil :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") (json-encode `(("description" . "Pasted from Emacs with webpaste.el")
("public" . "false") ("public" . "false")
("files" . ("files" .
(("file.txt" . (("file.txt" .
(("content" . ,text)))))))) (("content" . ,text)))))))))
:success-lambda (cl-function (lambda (&key data &allow-other-keys) :success-lambda (cl-function (lambda (&key data &allow-other-keys)
(when data (when data
(webpaste-return-url (webpaste-return-url

Loading…
Cancel
Save