aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus@disroot.org>2024-10-25 19:29:58 +0200
committermarty hiatt <martianhiatus@disroot.org>2024-10-25 19:50:30 +0200
commit8c77159f4f33d37e5c443d780a5cd88ccb545235 (patch)
treea12c268c5ed338bae3b3ed0918fc238cc8377d54
parent5a2fd200faa067a6c8fec087d9c99a0d7fab0415 (diff)
factor out poll classes subbing off tp-option-var. FIX #601
-rw-r--r--lisp/mastodon-transient.el41
1 files changed, 12 insertions, 29 deletions
diff --git a/lisp/mastodon-transient.el b/lisp/mastodon-transient.el
index 38da285..67ea667 100644
--- a/lisp/mastodon-transient.el
+++ b/lisp/mastodon-transient.el
@@ -278,6 +278,18 @@ the format fields.X.keyname."
"An infix option class for our options.
We always read.")
+(defclass mastodon-transient-opt (tp-option tp-option-var)
+ (()))
+
+(defclass mastodon-transient-poll-bool (tp-bool tp-option-var)
+ ())
+
+(defclass mastodon-transient-poll-choice (tp-option-str tp-option-var)
+ ())
+
+(defclass mastodon-transient-expiry (tp-option tp-option-var)
+ ())
+
(cl-defmethod transient-init-value ((obj mastodon-transient-field))
"Initialize value of OBJ."
(let* ((prefix-val (oref transient--prefix value)))
@@ -307,35 +319,6 @@ CONS is a cons of the form \"(fields.1.name . val)\"."
(not (equal (cdr cons)
(alist-get server-key server-elt nil nil #'string=)))))
-(defclass mastodon-transient-poll-bool (tp-bool)
- ())
-
-(cl-defmethod transient-init-value ((obj mastodon-transient-poll-bool))
- "Initialize OBJ, a poll option.
-Pull value from `tp-transient-settings' if possible.'"
- (let ((key (oref obj alist-key)))
- (oset obj value
- (alist-get key tp-transient-settings))))
-
-(defclass mastodon-transient-poll-choice (tp-option-str)
- ())
-
-(cl-defmethod transient-init-value ((obj mastodon-transient-poll-choice))
- "Initialize OBJ, an expiry option.
-Pull value from `tp-transient-settings' if possible.'"
- (let ((key (oref obj alist-key)))
- (oset obj value
- (alist-get key tp-transient-settings))))
-
-(defclass mastodon-transient-expiry (tp-option)
- ())
-
-(cl-defmethod transient-init-value ((obj mastodon-transient-expiry))
- "Initialize OBJ, an expiry option.
-Pull value from `tp-transient-settings' if possible.'"
- (oset obj value
- (alist-get 'expiry tp-transient-settings)))
-
(cl-defmethod transient-infix-read ((_obj mastodon-transient-expiry))
"Reader function for OBJ, a poll expiry."
(cdr (mastodon-toot--read-poll-expiry)))