[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/webpaste e12faa5 059/298: Added macro to create provider l
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/webpaste e12faa5 059/298: Added macro to create provider lambdas |
Date: |
Thu, 9 Dec 2021 18:59:44 -0500 (EST) |
branch: elpa/webpaste
commit e12faa58a4a9bf2247f6e7d2deca58f838775b21
Author: Elis Axelsson <elis.axelsson@gmail.com>
Commit: Elis Axelsson <elis.axelsson@gmail.com>
Added macro to create provider lambdas
---
webpaste.el | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/webpaste.el b/webpaste.el
index 0222d8c..da1569a 100644
--- a/webpaste.el
+++ b/webpaste.el
@@ -59,6 +59,50 @@ 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))
+ "Macro to create the lambda function for a provider.
+
+This macro accepts the parameters :domain, :type, :parser, :post-data,
+:post-field and :success.
+
+Usage:
+ (webpaste-provider
+ [:keyword [option]]...)
+
+:domain URL that we should do the request to to paste data.
+:type HTTP Request type, defaults to POST.
+:parser Defines how request.el parses the result. Look up :parser for
+ `request`.
+:post-data Default post fields sent to service. Defaults to nil.
+:post-field Name of the field to insert the code into.
+:success Callback sent to `requset`, 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))))
+ nil)))
+
+
;;; Define providers
(defcustom webpaste-providers-alist
'(("ix.io" .
- [nongnu] elpa/webpaste 81d3f9b 038/298: Namespace wrapper for save-mark-and-excursion, (continued)
- [nongnu] elpa/webpaste 81d3f9b 038/298: Namespace wrapper for save-mark-and-excursion, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste ba59c4e 039/298: Added comment for checkdock prettyness, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 4459071 040/298: Added description to group, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 6fc4065 041/298: Added install instructions and melpa images, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste c6ea45c 045/298: Specify type attribute of custom variable, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 4b9dfa9 049/298: Use cl-lib macros instead of cl.el, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste b8eb0ad 052/298: Change while to dolist, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste abe4fd5 053/298: Change from add-to-list to cl-pushnew, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 015bb9d 057/298: Refactored away add-to-list in favor of cl-pushnew in two more places, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 7688876 058/298: Interactive r for pasting region, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste e12faa5 059/298: Added macro to create provider lambdas,
ELPA Syncer <=
- [nongnu] elpa/webpaste f860028 060/298: Migrate providers to macro, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste ccef003 064/298: Replace away newlines from ix.io output, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 6039591 065/298: Added sprunge.us as provider, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 984f838 068/298: Added dpaste.de as provider, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 53dcac8 046/298: Move definition position, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 1c2a9b8 047/298: Merge pull request #1 from syohex/fix-package, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste 6d2e063 048/298: Spacing between blocks, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste d7700eb 050/298: Merge pull request #2 from syohex/cl-lib, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste c33f341 019/298: Added custom for provider priority, ELPA Syncer, 2021/12/09
- [nongnu] elpa/webpaste cc05738 025/298: Added some TODO notes, ELPA Syncer, 2021/12/09