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. 22
      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

Loading…
Cancel
Save