[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/webpaste 1114813 017/298: Move providers to customizable l
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/webpaste 1114813 017/298: Move providers to customizable list with lambdas |
Date: |
Thu, 9 Dec 2021 18:59:36 -0500 (EST) |
branch: elpa/webpaste
commit 11148135ce49f866409293ddb2455a7bdc7529ea
Author: Elis Axelsson <elis.axelsson@gmail.com>
Commit: Elis Axelsson <elis.axelsson@gmail.com>
Move providers to customizable list with lambdas
instead of having loose functions.
---
webpaste.el | 86 ++++++++++++++++++++++++++++++-------------------------------
1 file changed, 43 insertions(+), 43 deletions(-)
diff --git a/webpaste.el b/webpaste.el
index f80dc29..3a4d94b 100644
--- a/webpaste.el
+++ b/webpaste.el
@@ -48,7 +48,7 @@
(interactive)
(let ((text (buffer-substring (mark) (point))))
- (webpaste-providers-ix.io text)))
+ (funcall (cdr (car webpaste-providers)) text)))
;;;###autoload
@@ -63,49 +63,49 @@
;;; Define providers
+(defcustom webpaste-providers
+ '(("ix.io" .
+ (lambda (text)
+ "Paste TEXT to http://ix.io/."
+
+ (let ((post-data '()))
+ ;; Construct post data
+ (add-to-list 'post-data (cons "f:1" text))
+
+ ;; 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 (function* (lambda (&key data &allow-other-keys)
+ (when data
+ (webpaste-return-url data))))))
+ nil))
+ ("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
+ (add-to-list 'post-data (cons "content" text))
+
+ ;; 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
+ (function* (lambda (&key response &allow-other-keys)
+ (webpaste-return-url
+ (request-response-header response
"Location"))))))
+ nil)))
+ "Define all webpaste.el providers.")
-;; Provider for http://ix.io/
-(defun webpaste-providers-ix.io (text)
- "Paste TEXT to http://ix.io/."
-
- (let ((post-data '()))
- ;; Construct post data
- (add-to-list 'post-data (cons "f:1" text))
-
- ;; 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 (function* (lambda (&key data &allow-other-keys)
- (when data
- (webpaste-return-url data))))))
- nil)
-
-
-;; Provider for http://dpaste.com/
-(defun webpaste-providers-dpaste.com (text)
- "Paste TEXT to http://dpaste.com/."
-
- ;; Prepare post fields
- (let ((post-data '(("syntax" . "text")
- ("title" . "")
- ("poster" . "")
- ("expiry_days" . "1"))))
-
- ;; Add TEXT as content
- (add-to-list 'post-data (cons "content" text))
-
- ;; 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
- (function* (lambda (&key response &allow-other-keys)
- (webpaste-return-url
- (request-response-header response "Location"))))))
- nil)
(provide 'webpaste)
- [nongnu] elpa/webpaste 183b1a7 012/298: Construct post data correctly, (continued)
- [nongnu] elpa/webpaste 183b1a7 012/298: Construct post data correctly, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 830704a 003/298: Added base lisp file, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 96e76a7 002/298: Added LICENSE, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste ff47ecd 004/298: Added stub for the function to paste region, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste b4cd028 005/298: Added function to paste entire buffer, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 68ebb2c 006/298: Add request.el as dependency, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 6c9f1ff 007/298: Add ix.io as provider, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste f3794ea 009/298: Send data to ix.io, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 8f074b4 013/298: Autoload the two pasting functions, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste ff4194e 014/298: Make new code section for providers, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 1114813 017/298: Move providers to customizable list with lambdas,
ELPA Syncer <=
- [nongnu] elpa/webpaste 0c0f31b 020/298: Checkdoc checkup, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 6694269 018/298: Add resulting url to kill ring for easy pasting, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 1c7b313 021/298: Added variable for providers priority when running, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste bf8f03c 023/298: Spacing, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 14a1e6e 022/298: Added general function to paste text, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 0423f3f 024/298: Reorder file overall to have autoloads at the end, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 5b34fda 027/298: Rename providers list, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 3d18f0b 028/298: Added code to auto-populate webpaste-provider-priority if needed, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste e1b98bd 032/298: Updated readme, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 25f0b32 033/298: More documentation for webpaste-paste-text function, ELPA Syncer, 2021/12/09