[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/webpaste f206653 074/298: Merge branch 'alphapapa-without-
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/webpaste f206653 074/298: Merge branch 'alphapapa-without-eval' |
Date: |
Thu, 9 Dec 2021 18:59:47 -0500 (EST) |
branch: elpa/webpaste
commit f20665341944d35ed4021acc75cfb729bb780685
Merge: 6e34759 78651c9
Author: Elis Axelsson <elis.axelsson@gmail.com>
Commit: Elis Axelsson <elis.axelsson@gmail.com>
Merge branch 'alphapapa-without-eval'
---
webpaste.el | 146 ++++++++++++++++++++++++++++--------------------------------
1 file changed, 69 insertions(+), 77 deletions(-)
diff --git a/webpaste.el b/webpaste.el
index 2f2ce55..96ce305 100644
--- a/webpaste.el
+++ b/webpaste.el
@@ -1,4 +1,4 @@
-;;; webpaste.el --- Paste to pastebin-like services
+;;; webpaste.el --- Paste to pastebin-like services -*- lexical-binding: t;
-*-
;; Copyright (c) 2016 Elis Axelsson
@@ -59,13 +59,7 @@ if that variable is nil, it will use the list of names from
‘webpaste-provider
each run.")
-(cl-defmacro webpaste-provider
- (&key (domain)
- (type "POST")
- (parser)
- (post-data ())
- (post-field)
- (success))
+(cl-defun webpaste-provider (&key domain (type "POST") parser post-data
post-field success)
"Macro to create the lambda function for a provider.
This macro accepts the parameters :domain, :type, :parser, :post-data,
@@ -83,78 +77,76 @@ Usage:
:post-field Name of the field to insert the code into.
:success Callback sent to `request`, look up how to write these in the
documentation for `request`"
- `(lambda (text)
- "Paste TEXT to provider"
-
- ;; Local variable post-data
- (let ((post-data ,post-data))
- ;; Push field with text to post-data
- (cl-pushnew (cons ,post-field text) post-data)
-
- ;; Do request
- (request ,domain
- :type ,type
- :data post-data
- :parser ,parser
- :success ,success
- :error
- (cl-function (lambda (&key error-thrown &allow-other-keys)
- (message "Got error: %S" error-thrown)
- (webpaste-paste-text text))))
- nil)))
+ (lambda (text)
+ "Paste TEXT to provider"
+
+ ;; Local variable post-data
+ (cl-pushnew (cons post-field text) post-data)
+
+ ;; Do request
+ (request domain
+ :type type
+ :data post-data
+ :parser parser
+ :success success
+ :error
+ (cl-function (lambda (&key error-thrown &allow-other-keys)
+ (message "Got error: %S" error-thrown)
+ (webpaste-paste-text text))))
+ nil))
;;; Define providers
(defcustom webpaste-providers-alist
- '(("ix.io" .
- (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
- (replace-regexp-in-string "\n$" "" data)))))))
-
- ("sprunge.us" .
- (webpaste-provider
- :domain "http://sprunge.us/"
- :parser 'buffer-string
- :post-field "sprunge"
- :success
- (cl-function (lambda (&key data &allow-other-keys)
- (when data
- (webpaste-return-url
- (replace-regexp-in-string "\n$" "" data)))))))
-
- ("dpaste.com" .
- (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"))))))
-
- ("dpaste.de" .
- (webpaste-provider
- :domain "https://dpaste.de/api/"
- :parser 'buffer-string
- :post-data '(("lexer" . "text")
- ("format" . "url")
- ("expires" . 86400))
- :post-field "content"
- :success
- (cl-function (lambda (&key data &allow-other-keys)
- (when data
- (webpaste-return-url
- (replace-regexp-in-string "\n$" "" data))))))))
+ (list (list "ix.io"
+ (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
+ (replace-regexp-in-string "\n$" "" data)))))))
+
+ (list "sprunge.us"
+ (webpaste-provider
+ :domain "http://sprunge.us/"
+ :parser 'buffer-string
+ :post-field "sprunge"
+ :success
+ (cl-function (lambda (&key data &allow-other-keys)
+ (when data
+ (webpaste-return-url
+ (replace-regexp-in-string "\n$" "" data)))))))
+
+ (list "dpaste.com"
+ (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"))))))
+
+ (list "dpaste.de"
+ (webpaste-provider
+ :domain "https://dpaste.de/api/"
+ :parser 'buffer-string
+ :post-data '(("lexer" . "text")
+ ("format" . "url")
+ ("expires" . 86400))
+ :post-field "content"
+ :success
+ (cl-function (lambda (&key data &allow-other-keys)
+ (when data
+ (webpaste-return-url
+ (replace-regexp-in-string "\n$" ""
data))))))))
"Define all webpaste.el providers.
Consists of provider name and lambda function to do the actuall call to the
@@ -216,7 +208,7 @@ When we run out of providers to try, it will restart since
(setq webpaste-tested-providers (cdr webpaste-tested-providers))
;; Run pasting function
- (funcall (eval (cdr (assoc provider-name webpaste-providers-alist)))
text)))
+ (funcall (cadr (assoc provider-name webpaste-providers-alist)) text)))
;;;###autoload
- [nongnu] elpa/webpaste 4867c58 113/298: Backquotes for compacter list, (continued)
- [nongnu] elpa/webpaste 4867c58 113/298: Backquotes for compacter list, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 8f37214 116/298: Update docs to match function, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 4dd2e1b 111/298: First test of creation of paste providers, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 0b67c54 117/298: Move code up to be defined before the webpaste-provider function, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste e11ce74 086/298: Refactor provider priority to own function, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste b2ffe99 091/298: Added emacs --version to output in build, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 993db7e 095/298: Added ptpb.pw as new and default provider, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 8861ed8 102/298: Added license-badge, renamed test-vars, stop providing webpaste-test, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste bdc204d 055/298: Autoload return function to always have it available, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 3e81264 067/298: Forgot call to retry sending on failure when refactoring to macro, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste f206653 074/298: Merge branch 'alphapapa-without-eval',
ELPA Syncer <=
- [nongnu] elpa/webpaste 87cee69 081/298: Added test for failover to the second provider and not random, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste dcc26da 084/298: Update melpa image links, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 6655ecc 085/298: Rename make compile to make build because it's easier to remember, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 346b5bc 087/298: Rename tests to be prefixed, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 3389b4a 089/298: Do not provide test-helper feature, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 7db5673 093/298: Added more emacs versions for tests, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 382e01d 105/298: Added page breaks to files, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste b7acc4e 100/298: Added test for returning of URL's, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 8027e6e 106/298: Run tests on emacs 25.2 since it's been released, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste e04d885 114/298: Add (prog1 nil ...) form to avoid having the nil hanging at the end, ELPA Syncer, 2021/12/09