emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/webpaste f860028 060/298: Migrate providers to macro


From: ELPA Syncer
Subject: [nongnu] elpa/webpaste f860028 060/298: Migrate providers to macro
Date: Thu, 9 Dec 2021 18:59:44 -0500 (EST)

branch: elpa/webpaste
commit f8600284a440ea369019f44c2cd884d614079d29
Author: Elis Axelsson <elis.axelsson@gmail.com>
Commit: Elis Axelsson <elis.axelsson@gmail.com>

    Migrate providers to macro
---
 webpaste.el | 68 ++++++++++++++++++++-----------------------------------------
 1 file changed, 22 insertions(+), 46 deletions(-)

diff --git a/webpaste.el b/webpaste.el
index da1569a..208b340 100644
--- a/webpaste.el
+++ b/webpaste.el
@@ -106,53 +106,29 @@ Usage:
 ;;; Define providers
 (defcustom webpaste-providers-alist
   '(("ix.io" .
-     (lambda (text)
-       "Paste TEXT to http://ix.io/.";
-
-       (let ((post-data))
-         ;; Add TEXT to POST-DATA
-         (cl-pushnew (cons "f:1" text) post-data)
-
-         ;; Use request.el to do request to ix.io to submit data
-         (request "http://ix.io/";
-                  :type "POST"
-                  :data post-data
-                  :parser 'buffer-string
-                  :success (cl-function (lambda (&key data &allow-other-keys)
-                                          (when data
-                                            (webpaste-return-url data))))
-                  :error
-                  (cl-function (lambda (&key error-thrown &allow-other-keys)
-                                 (message "Got error: %S" error-thrown)
-                                 (webpaste-paste-text text)))))
-       nil))
+     (webpaste-provider
+      :domain "http://ix.io/";
+      :parser 'buffer-string
+      :post-field "f:1"
+      :success
+      (cl-function (lambda (&key data &allow-other-keys)
+                     (when data
+                       (webpaste-return-url data))))))
+
     ("dpaste.com" .
-     (lambda (text)
-       "Paste TEXT to http://dpaste.com/.";
-
-       ;; Prepare post fields
-       (let ((post-data '(("syntax" . "text")
-                          ("title" . "")
-                          ("poster" . "")
-                          ("expiry_days" . "1"))))
-
-         ;; Add TEXT as content
-         (cl-pushnew (cons "content" text) post-data)
-
-         ;; Use request.el to do request to dpaste.com to submit data
-         (request "http://dpaste.com/api/v2/";
-                  :type "POST"
-                  :data post-data
-                  :parser 'buffer-string
-                  :success
-                  (cl-function (lambda (&key response &allow-other-keys)
-                                 (webpaste-return-url
-                                  (request-response-header response 
"Location"))))
-                  :error
-                  (cl-function (lambda (&key error-thrown &allow-other-keys)
-                                 (message "Got error: %S" error-thrown)
-                                 (webpaste-paste-text text)))))
-       nil)))
+     (webpaste-provider
+      :domain "http://dpaste.com/api/v2/";
+      :parser 'buffer-string
+      :post-data '(("syntax" . "text")
+                   ("title" . "")
+                   ("poster" . "")
+                   ("expiry_days" . "1"))
+      :post-field "content"
+      :success
+      (cl-function (lambda (&key response &allow-other-keys)
+                     (webpaste-return-url
+                      (request-response-header response "Location")))))))
+
   "Define all webpaste.el providers.
 Consists of provider name and lambda function to do the actuall call to the
 provider.  The lamda should call ‘webpaste-return-url’ with resulting url to



reply via email to

[Prev in Thread] Current Thread [Next in Thread]