branch: elpa/fedi
commit 821894b42371ca0fc7568a717c59e2a3bb1dee01
Author: marty hiatt <martianhiatus [a t] riseup [d o t] net>
Commit: marty hiatt <martianhiatus [a t] riseup [d o t] net>
build params alist in the macro. only for identical key-str val-arg
---
fedi.el | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/fedi.el b/fedi.el
index 1127f1b21d3..7fe6343b5cb 100644
--- a/fedi.el
+++ b/fedi.el
@@ -91,9 +91,10 @@ that handles auth by providing info using HEADERS or
AUTH-PARAM."
(let* ((req-url (fedi-http--api ,endpoint))
(url-request-method ,(upcase method))
(url-request-extra-headers ,headers)
+ (params-alist (list ,@(fedi-make-params-alist params)))
(params (if ,auth-param
- (append ,auth-param ,params)
- ,params))
+ (append ,auth-param params-alist)
+ params-alist))
(response
(cond ((or (equal ,method "post")
(equal ,method "put"))
@@ -106,5 +107,22 @@ that handles auth by providing info using HEADERS or
AUTH-PARAM."
(with-current-buffer response
(fedi-http--process-json))))))))
+(defun fedi-arg-when-expr (arg)
+ (let ((str
+ (string-replace "-" "_" ; for "type_"
+ (symbol-name arg))))
+ `(when ,arg
+ (cons ,str
+ ;;(symbol-name arg)
+ ,arg))))
+
+;; (fedi-arg-when-expr 'sort)
+
+(defun fedi-make-params-alist (args)
+ (cl-loop while args
+ collecting (fedi-arg-when-expr (pop args))))
+
+;; (fedi-make-params-alist '(sort type))
+
(provide 'fedi)
;;; fedi.el ends here